From 4b844248690723d7a47a246034a2ac164be8cd2a Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Fri, 26 Sep 2014 10:59:06 +0200 Subject: [PATCH] Ox.List: use Ox.contains --- source/Ox.UI/js/List/List.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/source/Ox.UI/js/List/List.js b/source/Ox.UI/js/List/List.js index 6684a3f5..6ff9c777 100644 --- a/source/Ox.UI/js/List/List.js +++ b/source/Ox.UI/js/List/List.js @@ -219,7 +219,7 @@ Ox.List = function(options, self) { self.selected = self.options.items.map(function(item, i) { return Ox.extend(item, {_index: i}) }).filter(function(item) { - return self.options.selected.indexOf(item[self.options.unique]) > -1; + return Ox.contains(self.options.selected, item[self.options.unique]); }).map(function(item) { return item['_index']; }); @@ -765,7 +765,7 @@ Ox.List = function(options, self) { var ids = [], rest = [], useRest = self.selected.length > self.listLength / 2; result.data.items.forEach(function(item, i) { - if (self.selected.indexOf(i) > -1) { + if (isSelected(i)) { ids.push(item[self.options.unique]); } else if (useRest) { rest.push(item[self.options.unique]); @@ -787,7 +787,7 @@ Ox.List = function(options, self) { } function isSelected(pos) { - return self.selected.indexOf(pos) > -1; + return Ox.contains(self.selected, pos); } function isSpecialTarget(e) { @@ -1463,7 +1463,7 @@ Ox.List = function(options, self) { getSelectedIds(function(oldIds) { var newIds = []; Ox.forEach(self.options.items, function(item) { - if (oldIds.indexOf(item.id) > -1) { + if (Ox.contains(oldIds, item.id)) { newIds.push(item.id); } if (newIds.length == oldIds.length) { @@ -1508,7 +1508,7 @@ Ox.List = function(options, self) { if (selectedIds.length) { self.selected = []; self.options.items.forEach(function(item, i) { - if (selectedIds.indexOf(item.id) > -1) { + if (Ox.contains(selectedIds, item.id)) { self.selected.push(i); } }); @@ -1681,7 +1681,7 @@ Ox.List = function(options, self) { }); } else { // remove items from pos to pos+length Ox.range(pos, pos + length).forEach(function(i) { - self.selected.indexOf(i) > -1 && deselect(i); + isSelected(i) && deselect(i); self.$items[i].remove(); }); self.options.items.splice(pos, length); @@ -1744,7 +1744,7 @@ Ox.List = function(options, self) { }; /*@ - size fixme: not a good function name + size Update list size () -> List Object @*/ that.size = function() { // fixme: not a good function name