support list.options({selected: []})

This commit is contained in:
rlx 2011-01-10 00:07:48 +00:00
parent 07dd8d0190
commit 53fb84425e

View file

@ -5858,6 +5858,8 @@ requires
self.onChange = function(key, value) { self.onChange = function(key, value) {
if (key == 'request') { if (key == 'request') {
that.$element.options(key, value); that.$element.options(key, value);
} else if (key == 'selected') {
that.$element.options(key, value);
} }
} }
@ -6125,7 +6127,6 @@ requires
} }
updateQuery(self.options.selected); updateQuery(self.options.selected);
Ox.print('s.o', self.options)
that.bindEvent(self.keyboardEvents); that.bindEvent(self.keyboardEvents);
$window.resize(that.size); $window.resize(that.size);
@ -6242,9 +6243,8 @@ requires
function deselect(pos) { function deselect(pos) {
if (isSelected(pos)) { if (isSelected(pos)) {
self.selected.splice(self.selected.indexOf(pos), 1); self.selected.splice(self.selected.indexOf(pos), 1);
if (!Ox.isUndefined(self.$items[pos])) { !Ox.isUndefined(self.$items[pos]) &&
self.$items[pos].removeClass('OxSelected'); self.$items[pos].removeClass('OxSelected');
}
triggerSelectEvent(); triggerSelectEvent();
} }
} }
@ -6744,6 +6744,35 @@ requires
}); });
} }
function setSelected(ids) {
if (ids.length == 0) {
// fixme: can't use selectNone here,
// since it'd trigger a select event
$.each(self.$items, function(pos) {
if (isSelected(pos)) {
self.selected.splice(self.selected.indexOf(pos), 1);
!Ox.isUndefined(self.$items[pos]) &&
self.$items[pos].removeClass('OxSelected');
}
});
}
// fixme: implement the rest of this
/*
self.selected.forEach(function(pos) {
if (value.indexOf(self.ids[pos]) == -1) {
deselect(pos);
}
});
value.forEach(function(id) {
if (self.ids.indexOf(id) > -1) {
addToSelection(pos)
} else {
}
});
*/
}
function toggleSelection(pos) { function toggleSelection(pos) {
if (!isSelected(pos)) { if (!isSelected(pos)) {
addToSelection(pos); addToSelection(pos);
@ -6852,10 +6881,12 @@ requires
Ox.print('list onChange', key, value); Ox.print('list onChange', key, value);
if (key == 'request') { if (key == 'request') {
updateQuery(); updateQuery();
} else if (key == 'selected') {
setSelected(value);
} }
}; };
that.clearCache = function() { // was used by TextList resizeColumn, now probably no longer necessary that.clearCache = function() { // fixme: was used by TextList resizeColumn, now probably no longer necessary
self.$pages = []; self.$pages = [];
return that; return that;
}; };