Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(713)

Side by Side Diff: third_party/polymer/v1_0/components-chromium/iron-selector/iron-selectable-extracted.js

Issue 1401633002: Update Polymer from 1.1.4 -> 1.1.5 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dzhioev@ review Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 1 /** @polymerBehavior */
2
3 /** @polymerBehavior */
4 Polymer.IronSelectableBehavior = { 2 Polymer.IronSelectableBehavior = {
5 3
6 /** 4 /**
7 * Fired when iron-selector is activated (selected or deselected). 5 * Fired when iron-selector is activated (selected or deselected).
8 * It is fired before the selected items are changed. 6 * It is fired before the selected items are changed.
9 * Cancel the event to abort selection. 7 * Cancel the event to abort selection.
10 * 8 *
11 * @event iron-activate 9 * @event iron-activate
12 */ 10 */
13 11
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 value: null 90 value: null
93 }, 91 },
94 92
95 /** 93 /**
96 * The set of excluded elements where the key is the `localName` 94 * The set of excluded elements where the key is the `localName`
97 * of the element that will be ignored from the item list. 95 * of the element that will be ignored from the item list.
98 * 96 *
99 * @type {object} 97 * @type {object}
100 * @default {template: 1} 98 * @default {template: 1}
101 */ 99 */
102 excludedLocalNames: { 100 _excludedLocalNames: {
103 type: Object, 101 type: Object,
104 value: function() { 102 value: function() {
105 return { 103 return {
106 'template': 1 104 'template': 1
107 }; 105 };
108 } 106 }
109 } 107 }
110 }, 108 },
111 109
112 observers: [ 110 observers: [
113 '_updateSelected(attrForSelected, selected)' 111 '_updateSelected(attrForSelected, selected)'
114 ], 112 ],
115 113
116 created: function() { 114 created: function() {
117 this._bindFilterItem = this._filterItem.bind(this); 115 this._bindFilterItem = this._filterItem.bind(this);
118 this._selection = new Polymer.IronSelection(this._applySelection.bind(this )); 116 this._selection = new Polymer.IronSelection(this._applySelection.bind(this ));
117 // TODO(cdata): When polymer/polymer#2535 lands, we do not need to do this
118 // book keeping anymore:
119 this.__listeningForActivate = false;
119 }, 120 },
120 121
121 attached: function() { 122 attached: function() {
122 this._observer = this._observeItems(this); 123 this._observer = this._observeItems(this);
123 this._contentObserver = this._observeContent(this); 124 this._contentObserver = this._observeContent(this);
124 if (!this.selectedItem && this.selected) { 125 if (!this.selectedItem && this.selected) {
125 this._updateSelected(this.attrForSelected,this.selected) 126 this._updateSelected(this.attrForSelected,this.selected)
126 } 127 }
128 this._addListener(this.activateEvent);
127 }, 129 },
128 130
129 detached: function() { 131 detached: function() {
130 if (this._observer) { 132 if (this._observer) {
131 this._observer.disconnect(); 133 this._observer.disconnect();
132 } 134 }
133 if (this._contentObserver) { 135 if (this._contentObserver) {
134 this._contentObserver.disconnect(); 136 this._contentObserver.disconnect();
135 } 137 }
136 this._removeListener(this.activateEvent); 138 this._removeListener(this.activateEvent);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 * Selects the next item. 185 * Selects the next item.
184 * 186 *
185 * @method selectNext 187 * @method selectNext
186 */ 188 */
187 selectNext: function() { 189 selectNext: function() {
188 var index = (Number(this._valueToIndex(this.selected)) + 1) % this.items.l ength; 190 var index = (Number(this._valueToIndex(this.selected)) + 1) % this.items.l ength;
189 this.selected = this._indexToValue(index); 191 this.selected = this._indexToValue(index);
190 }, 192 },
191 193
192 _addListener: function(eventName) { 194 _addListener: function(eventName) {
195 if (!this.isAttached || this.__listeningForActivate) {
196 return;
197 }
198
199 this.__listeningForActivate = true;
193 this.listen(this, eventName, '_activateHandler'); 200 this.listen(this, eventName, '_activateHandler');
194 }, 201 },
195 202
196 _removeListener: function(eventName) { 203 _removeListener: function(eventName) {
197 this.unlisten(this, eventName, '_activateHandler'); 204 this.unlisten(this, eventName, '_activateHandler');
205 this.__listeningForActivate = false;
198 }, 206 },
199 207
200 _activateEventChanged: function(eventName, old) { 208 _activateEventChanged: function(eventName, old) {
201 this._removeListener(old); 209 this._removeListener(old);
202 this._addListener(eventName); 210 this._addListener(eventName);
203 }, 211 },
204 212
205 _updateSelected: function() { 213 _updateSelected: function() {
206 this._selectSelected(this.selected); 214 this._selectSelected(this.selected);
207 }, 215 },
208 216
209 _selectSelected: function(selected) { 217 _selectSelected: function(selected) {
210 this._selection.select(this._valueToItem(this.selected)); 218 this._selection.select(this._valueToItem(this.selected));
211 }, 219 },
212 220
213 _filterItem: function(node) { 221 _filterItem: function(node) {
214 return !this.excludedLocalNames[node.localName]; 222 return !this._excludedLocalNames[node.localName];
215 }, 223 },
216 224
217 _valueToItem: function(value) { 225 _valueToItem: function(value) {
218 return (value == null) ? null : this.items[this._valueToIndex(value)]; 226 return (value == null) ? null : this.items[this._valueToIndex(value)];
219 }, 227 },
220 228
221 _valueToIndex: function(value) { 229 _valueToIndex: function(value) {
222 if (this.attrForSelected) { 230 if (this.attrForSelected) {
223 for (var i = 0, item; item = this.items[i]; i++) { 231 for (var i = 0, item; item = this.items[i]; i++) {
224 if (this._valueForItem(item) == value) { 232 if (this._valueForItem(item) == value) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 312 }
305 }, 313 },
306 314
307 _itemActivate: function(value, item) { 315 _itemActivate: function(value, item) {
308 if (!this.fire('iron-activate', 316 if (!this.fire('iron-activate',
309 {selected: value, item: item}, {cancelable: true}).defaultPrevented) { 317 {selected: value, item: item}, {cancelable: true}).defaultPrevented) {
310 this.select(value); 318 this.select(value);
311 } 319 }
312 } 320 }
313 321
314 }; 322 };
315
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698