From f0a603467c657b98dff2240c5cf02e24fb339dfb Mon Sep 17 00:00:00 2001 From: frankiefu Date: Mon, 17 Jun 2013 16:21:57 -0700 Subject: [PATCH 01/41] polymer-selector: filter template nodes in items and add selectedProperty; add workbench file; remove using in --- polymer-selector/index.html | 45 ++++++++++++++++++++ polymer-selector/polymer-selection.html | 28 ++++++------- polymer-selector/polymer-selector.html | 56 ++++++++++++++++--------- 3 files changed, 96 insertions(+), 33 deletions(-) create mode 100644 polymer-selector/index.html diff --git a/polymer-selector/index.html b/polymer-selector/index.html new file mode 100644 index 0000000..fd22e89 --- /dev/null +++ b/polymer-selector/index.html @@ -0,0 +1,45 @@ + + + + polymer-selector + + + + + + +
Item 1
+
Item 2
+
Item 3
+
Item 4
+
Item 5
+
+

Multi-select

+ +
Item 1
+
Item 2
+
Item 3
+
Item 4
+
Item 5
+
+ + diff --git a/polymer-selector/polymer-selection.html b/polymer-selector/polymer-selection.html index 3fbdd2e..e6e5632 100644 --- a/polymer-selector/polymer-selection.html +++ b/polymer-selector/polymer-selection.html @@ -30,34 +30,34 @@ getSelection: function() { return this.multi ? this.selection : this.selection[0]; }, - isSelected: function(inItem) { - return this.selection.indexOf(inItem) >= 0; + isSelected: function(item) { + return this.selection.indexOf(item) >= 0; }, - setItemSelected: function(inItem, inIsSelected) { - if (inItem) { - if (inIsSelected) { - this.selection.push(inItem); + setItemSelected: function(item, isSelected) { + if (item) { + if (isSelected) { + this.selection.push(item); } else { - var i = this.selection.indexOf(inItem); + var i = this.selection.indexOf(item); if (i >= 0) { this.selection.splice(i, 1); } } // TODO(sjmiles): consider replacing with summary // notifications (asynchronous job) - this.asyncFire("polymer-select", {isSelected: inIsSelected, item: inItem}); + this.asyncFire("polymer-select", {isSelected: isSelected, item: item}); } }, - select: function(inItem) { + select: function(item) { if (this.multi) { - this.toggle(inItem); - } else if (this.getSelection() !== inItem) { + this.toggle(item); + } else if (this.getSelection() !== item) { this.setItemSelected(this.getSelection(), false); - this.setItemSelected(inItem, true); + this.setItemSelected(item, true); } }, - toggle: function(inItem) { - this.setItemSelected(inItem, !this.isSelected(inItem)); + toggle: function(item) { + this.setItemSelected(item, !this.isSelected(item)); } }); diff --git a/polymer-selector/polymer-selector.html b/polymer-selector/polymer-selector.html index f9b995b..667a6e2 100644 --- a/polymer-selector/polymer-selector.html +++ b/polymer-selector/polymer-selector.html @@ -25,7 +25,7 @@ * to style the selected element. * * @@ -47,7 +47,9 @@ */ --> - + +