make lists fire select events when updating the query changes, i.e. removes, its previous selection (fixes #238)
This commit is contained in:
parent
33eb986c59
commit
1ea9524cb1
1 changed files with 5 additions and 92 deletions
|
@ -600,13 +600,8 @@ Ox.List = function(options, self) {
|
|||
}
|
||||
|
||||
function getPositions(callback) {
|
||||
//Ox.Log('List', 'getPositions', self.options.selected);
|
||||
// fixme: optimize: send non-selected ids if more than half of the items are selected
|
||||
if (self.options.selected.length /*&& ids.length < self.listLength*/) {
|
||||
/*Ox.Log('List', '-------- request', {
|
||||
positions: ids,
|
||||
sort: self.options.sort
|
||||
});*/
|
||||
if (self.options.selected.length/* && ids.length < self.listLength*/) {
|
||||
self.requests.push(self.options.items({
|
||||
positions: self.options.selected,
|
||||
sort: self.options.sort
|
||||
|
@ -620,7 +615,7 @@ Ox.List = function(options, self) {
|
|||
|
||||
function getPositionsCallback(result, callback) {
|
||||
//Ox.Log('List', 'getPositionsCallback', result);
|
||||
var pos = 0;
|
||||
var pos = 0, previousSelected = self.options.selected;
|
||||
if (result) {
|
||||
self.options.selected = [];
|
||||
self.positions = {};
|
||||
|
@ -635,6 +630,9 @@ Ox.List = function(options, self) {
|
|||
pos = Ox.min(self.selected);
|
||||
self.page = getPageByPosition(pos);
|
||||
}
|
||||
if (!Ox.isEqual(self.options.selected, previousSelected)) {
|
||||
that.triggerEvent('select', {ids: self.options.selected});
|
||||
}
|
||||
} else if (self.stayAtPosition) {
|
||||
self.page = getPageByScrollPosition(self.stayAtPosition);
|
||||
}
|
||||
|
@ -947,91 +945,6 @@ Ox.List = function(options, self) {
|
|||
open(isSpecialTarget(data));
|
||||
}
|
||||
|
||||
/*
|
||||
function _mousedown(e) { // fixme: no longer used, remove
|
||||
var pos = findItemPosition(e),
|
||||
clickable, editable,
|
||||
clickTimeout = false,
|
||||
selectTimeout = false,
|
||||
$element,
|
||||
hadFocus = that.hasFocus();
|
||||
//Ox.Log('List', 'mousedown', pos)
|
||||
that.gainFocus();
|
||||
if (pos > -1) {
|
||||
if (!self.clickTimeout) {
|
||||
// click
|
||||
if (e.metaKey) {
|
||||
if (!isSelected(pos) && (self.options.max == -1 || self.options.max > self.selected.length)) {
|
||||
addToSelection(pos);
|
||||
} else if (isSelected(pos) && self.options.min < self.selected.length) {
|
||||
deselect(pos);
|
||||
}
|
||||
} else if (e.shiftKey) {
|
||||
if (self.options.max == -1) {
|
||||
addAllToSelection(pos);
|
||||
}
|
||||
} else if (!isSelected(pos)) {
|
||||
Ox.Log('List', 'select', pos)
|
||||
select(pos);
|
||||
} else if (self.selected.length > 1) {
|
||||
// this could be the first click
|
||||
// of a double click on multiple items
|
||||
// or the mousedown of a drag of multiple items
|
||||
selectTimeout = true;
|
||||
that.$content.one({
|
||||
mousemove: function() {
|
||||
self.clickTimeout && clearTimeout(self.clickTimeout);
|
||||
}
|
||||
});
|
||||
} else if (self.options.type == 'text' && hadFocus) {
|
||||
var $cell = findCell(e),
|
||||
$element = $cell || self.$items[pos];
|
||||
clickable = $element.is('.OxClickable');
|
||||
editable = $element.is('.OxEditable') && !$element.is('.OxEdit');
|
||||
if (clickable || editable) {
|
||||
if (self.options.sortable && self.listLength > 1) {
|
||||
clickTimeout = true;
|
||||
} else {
|
||||
!$cell && that.editItem(pos);
|
||||
triggerClickEvent(clickable ? 'click' : 'edit', self.$items[pos], $cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
self.clickTimeout = setTimeout(function() {
|
||||
self.clickTimeout = 0;
|
||||
if (selectTimeout) {
|
||||
select(pos);
|
||||
}
|
||||
}, 250);
|
||||
if (self.options.sortable && self.listLength > 1) {
|
||||
self.dragTimeout = setTimeout(function() {
|
||||
if (self.dragTimeout) {
|
||||
dragItem(pos, e);
|
||||
self.dragTimeout = 0;
|
||||
}
|
||||
}, 250);
|
||||
Ox.UI.$window.one('mouseup', function(e) {
|
||||
if (self.dragTimeout) {
|
||||
clearTimeout(self.dragTimeout);
|
||||
self.dragTimeout = 0;
|
||||
if (clickTimeout) {
|
||||
triggerClickEvent(clickable ? 'click' : 'edit', self.$items[pos], $cell);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// dblclick
|
||||
clearTimeout(self.clickTimeout);
|
||||
self.clickTimeout = 0;
|
||||
open();
|
||||
}
|
||||
} else if (!$(e.target).is('.OxToggle') && self.options.min == 0) {
|
||||
selectNone();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
function moveItem(startPos, stopPos) {
|
||||
var $item = self.$items[startPos],
|
||||
insert = startPos < stopPos ? 'insertAfter' : 'insertBefore';
|
||||
|
|
Loading…
Reference in a new issue