| OLD | NEW |
| 1 /** @polymerBehavior */ | 1 /** @polymerBehavior */ |
| 2 Polymer.IronSelectableBehavior = { | 2 Polymer.IronSelectableBehavior = { |
| 3 | 3 |
| 4 /** | 4 /** |
| 5 * Fired when iron-selector is activated (selected or deselected). | 5 * Fired when iron-selector is activated (selected or deselected). |
| 6 * It is fired before the selected items are changed. | 6 * It is fired before the selected items are changed. |
| 7 * Cancel the event to abort selection. | 7 * Cancel the event to abort selection. |
| 8 * | 8 * |
| 9 * @event iron-activate | 9 * @event iron-activate |
| 10 */ | 10 */ |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * Fired when the list of selectable items changes (e.g., items are | 25 * Fired when the list of selectable items changes (e.g., items are |
| 26 * added or removed). The detail of the event is a list of mutation | 26 * added or removed). The detail of the event is a list of mutation |
| 27 * records that describe what changed. | 27 * records that describe what changed. |
| 28 * | 28 * |
| 29 * @event iron-items-changed | 29 * @event iron-items-changed |
| 30 */ | 30 */ |
| 31 | 31 |
| 32 properties: { | 32 properties: { |
| 33 | 33 |
| 34 /** | 34 /** |
| 35 * If you want to use the attribute value of an element for `selected` ins
tead of the index, | 35 * If you want to use an attribute value or property of an element for |
| 36 * set this to the name of the attribute. | 36 * `selected` instead of the index, set this to the name of the attribute |
| 37 * or property. Hyphenated values are converted to camel case when used to |
| 38 * look up the property of a selectable element. Camel cased values are |
| 39 * *not* converted to hyphenated values for attribute lookup. It's |
| 40 * recommended that you provide the hyphenated form of the name so that |
| 41 * selection works in both cases. (Use `attr-or-property-name` instead of |
| 42 * `attrOrPropertyName`.) |
| 37 */ | 43 */ |
| 38 attrForSelected: { | 44 attrForSelected: { |
| 39 type: String, | 45 type: String, |
| 40 value: null | 46 value: null |
| 41 }, | 47 }, |
| 42 | 48 |
| 43 /** | 49 /** |
| 44 * Gets or sets the selected element. The default is to use the index of t
he item. | 50 * Gets or sets the selected element. The default is to use the index of t
he item. |
| 45 * @type {string|number} | 51 * @type {string|number} |
| 46 */ | 52 */ |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 var item = this.items[index]; | 273 var item = this.items[index]; |
| 268 if (item) { | 274 if (item) { |
| 269 return this._valueForItem(item); | 275 return this._valueForItem(item); |
| 270 } | 276 } |
| 271 } else { | 277 } else { |
| 272 return index; | 278 return index; |
| 273 } | 279 } |
| 274 }, | 280 }, |
| 275 | 281 |
| 276 _valueForItem: function(item) { | 282 _valueForItem: function(item) { |
| 277 var propValue = item[this.attrForSelected]; | 283 var propValue = item[Polymer.CaseMap.dashToCamelCase(this.attrForSelected)
]; |
| 278 return propValue != undefined ? propValue : item.getAttribute(this.attrFor
Selected); | 284 return propValue != undefined ? propValue : item.getAttribute(this.attrFor
Selected); |
| 279 }, | 285 }, |
| 280 | 286 |
| 281 _applySelection: function(item, isSelected) { | 287 _applySelection: function(item, isSelected) { |
| 282 if (this.selectedClass) { | 288 if (this.selectedClass) { |
| 283 this.toggleClass(this.selectedClass, isSelected, item); | 289 this.toggleClass(this.selectedClass, isSelected, item); |
| 284 } | 290 } |
| 285 if (this.selectedAttribute) { | 291 if (this.selectedAttribute) { |
| 286 this.toggleAttribute(this.selectedAttribute, isSelected, item); | 292 this.toggleAttribute(this.selectedAttribute, isSelected, item); |
| 287 } | 293 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 }, | 332 }, |
| 327 | 333 |
| 328 _itemActivate: function(value, item) { | 334 _itemActivate: function(value, item) { |
| 329 if (!this.fire('iron-activate', | 335 if (!this.fire('iron-activate', |
| 330 {selected: value, item: item}, {cancelable: true}).defaultPrevented) { | 336 {selected: value, item: item}, {cancelable: true}).defaultPrevented) { |
| 331 this.select(value); | 337 this.select(value); |
| 332 } | 338 } |
| 333 } | 339 } |
| 334 | 340 |
| 335 }; | 341 }; |
| OLD | NEW |