Ox.IconList: make value method accept (id, {key: value})
This commit is contained in:
parent
5001a47cf8
commit
9d189c55da
1 changed files with 22 additions and 15 deletions
|
@ -251,25 +251,32 @@ Ox.IconList = function(options, self) {
|
||||||
(id) -> <o> get all data for item
|
(id) -> <o> get all data for item
|
||||||
(id, key) -> <s> get value of key of item with id
|
(id, key) -> <s> get value of key of item with id
|
||||||
(id, key, value) -> <f> set value, returns IconList
|
(id, key, value) -> <f> set value, returns IconList
|
||||||
|
(id, {key: value, ...}) -> <f> set values, returns IconList
|
||||||
@*/
|
@*/
|
||||||
that.value = function(id, key, value) {
|
that.value = function() {
|
||||||
// fixme: make this accept id, {k: v, ...}
|
var args = Ox.slice(arguments),
|
||||||
|
id = args.shift(),
|
||||||
|
sort = false;
|
||||||
if (arguments.length == 1) {
|
if (arguments.length == 1) {
|
||||||
return that.$element.value(id);
|
return that.$element.value(id);
|
||||||
} else if (arguments.length == 2) {
|
} else if (arguments.length == 2 && Ox.isString(arguments[1])) {
|
||||||
return that.$element.value(id, key);
|
return that.$element.value(id, arguments[1]);
|
||||||
} else {
|
} else {
|
||||||
that.$element.value(id, key, value);
|
Ox.forEach(Ox.makeObject(args), function(value, key) {
|
||||||
if (key == self.unique) {
|
that.$element.value(id, key, value);
|
||||||
// unique id has changed
|
if (key == self.unique) {
|
||||||
self.options.selected = self.options.selected.map(function(id_) {
|
// unique id has changed
|
||||||
return id_ == id ? value : id_
|
self.options.selected = self.options.selected.map(function(id_) {
|
||||||
});
|
return id_ == id ? value : id_
|
||||||
}
|
});
|
||||||
if (key == self.options.sort[0].key) {
|
id = value;
|
||||||
// sort key has changed
|
}
|
||||||
that.$element.sort();
|
if (key == self.options.sort[0].key) {
|
||||||
}
|
// sort key has changed
|
||||||
|
sort = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
sort && that.$element.sort();
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue