| 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 */ |
| 11 | 11 |
| 12 /** | 12 /** |
| 13 * Fired when an item is selected | 13 * Fired when an item is selected |
| 14 * | 14 * |
| 15 * @event iron-select | 15 * @event iron-select |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * Fired when an item is deselected | 19 * Fired when an item is deselected |
| 20 * | 20 * |
| 21 * @event iron-deselect | 21 * @event iron-deselect |
| 22 */ | 22 */ |
| 23 | 23 |
| 24 /** | 24 /** |
| 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 mutation record that |
| 27 * records that describe what changed. | 27 * describes 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 an attribute value or property of an element for | 35 * If you want to use an attribute value or property of an element for |
| 36 * `selected` instead of the index, 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 | 37 * or property. Hyphenated values are converted to camel case when used to |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 this._selectionChange(); | 324 this._selectionChange(); |
| 325 this.fire('iron-' + (isSelected ? 'select' : 'deselect'), {item: item}); | 325 this.fire('iron-' + (isSelected ? 'select' : 'deselect'), {item: item}); |
| 326 }, | 326 }, |
| 327 | 327 |
| 328 _selectionChange: function() { | 328 _selectionChange: function() { |
| 329 this._setSelectedItem(this._selection.get()); | 329 this._setSelectedItem(this._selection.get()); |
| 330 }, | 330 }, |
| 331 | 331 |
| 332 // observe items change under the given node. | 332 // observe items change under the given node. |
| 333 _observeItems: function(node) { | 333 _observeItems: function(node) { |
| 334 return Polymer.dom(node).observeNodes(function(mutations) { | 334 return Polymer.dom(node).observeNodes(function(mutation) { |
| 335 this._updateItems(); | 335 this._updateItems(); |
| 336 | 336 |
| 337 if (this._shouldUpdateSelection) { | 337 if (this._shouldUpdateSelection) { |
| 338 this._updateSelected(); | 338 this._updateSelected(); |
| 339 } | 339 } |
| 340 | 340 |
| 341 // Let other interested parties know about the change so that | 341 // Let other interested parties know about the change so that |
| 342 // we don't have to recreate mutation observers everywhere. | 342 // we don't have to recreate mutation observers everywhere. |
| 343 this.fire('iron-items-changed', mutations, { | 343 this.fire('iron-items-changed', mutation, { |
| 344 bubbles: false, | 344 bubbles: false, |
| 345 cancelable: false | 345 cancelable: false |
| 346 }); | 346 }); |
| 347 }); | 347 }); |
| 348 }, | 348 }, |
| 349 | 349 |
| 350 _activateHandler: function(e) { | 350 _activateHandler: function(e) { |
| 351 var t = e.target; | 351 var t = e.target; |
| 352 var items = this.items; | 352 var items = this.items; |
| 353 while (t && t != this) { | 353 while (t && t != this) { |
| 354 var i = items.indexOf(t); | 354 var i = items.indexOf(t); |
| 355 if (i >= 0) { | 355 if (i >= 0) { |
| 356 var value = this._indexToValue(i); | 356 var value = this._indexToValue(i); |
| 357 this._itemActivate(value, t); | 357 this._itemActivate(value, t); |
| 358 return; | 358 return; |
| 359 } | 359 } |
| 360 t = t.parentNode; | 360 t = t.parentNode; |
| 361 } | 361 } |
| 362 }, | 362 }, |
| 363 | 363 |
| 364 _itemActivate: function(value, item) { | 364 _itemActivate: function(value, item) { |
| 365 if (!this.fire('iron-activate', | 365 if (!this.fire('iron-activate', |
| 366 {selected: value, item: item}, {cancelable: true}).defaultPrevented) { | 366 {selected: value, item: item}, {cancelable: true}).defaultPrevented) { |
| 367 this.select(value); | 367 this.select(value); |
| 368 } | 368 } |
| 369 } | 369 } |
| 370 | 370 |
| 371 }; | 371 }; |
| OLD | NEW |