| OLD | NEW |
| 1 /** | 1 /** |
| 2 * `Polymer.IronMenuBehavior` implements accessible menu behavior. | 2 * `Polymer.IronMenuBehavior` implements accessible menu behavior. |
| 3 * | 3 * |
| 4 * @demo demo/index.html | 4 * @demo demo/index.html |
| 5 * @polymerBehavior Polymer.IronMenuBehavior | 5 * @polymerBehavior Polymer.IronMenuBehavior |
| 6 */ | 6 */ |
| 7 Polymer.IronMenuBehaviorImpl = { | 7 Polymer.IronMenuBehaviorImpl = { |
| 8 | 8 |
| 9 properties: { | 9 properties: { |
| 10 | 10 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 * Given a KeyboardEvent, this method will focus the appropriate item in the | 105 * Given a KeyboardEvent, this method will focus the appropriate item in the |
| 106 * menu (if there is a relevant item, and it is possible to focus it). | 106 * menu (if there is a relevant item, and it is possible to focus it). |
| 107 * | 107 * |
| 108 * @param {KeyboardEvent} event A KeyboardEvent. | 108 * @param {KeyboardEvent} event A KeyboardEvent. |
| 109 */ | 109 */ |
| 110 _focusWithKeyboardEvent: function(event) { | 110 _focusWithKeyboardEvent: function(event) { |
| 111 for (var i = 0, item; item = this.items[i]; i++) { | 111 for (var i = 0, item; item = this.items[i]; i++) { |
| 112 var attr = this.attrForItemTitle || 'textContent'; | 112 var attr = this.attrForItemTitle || 'textContent'; |
| 113 var title = item[attr] || item.getAttribute(attr); | 113 var title = item[attr] || item.getAttribute(attr); |
| 114 | 114 |
| 115 if (!item.hasAttribute('disabled') && title && | 115 if (!item.hasAttribute('disabled') && title && |
| 116 title.trim().charAt(0).toLowerCase() === String.fromCharCode(event.k
eyCode).toLowerCase()) { | 116 title.trim().charAt(0).toLowerCase() === String.fromCharCode(event.k
eyCode).toLowerCase()) { |
| 117 this._setFocusedItem(item); | 117 this._setFocusedItem(item); |
| 118 break; | 118 break; |
| 119 } | 119 } |
| 120 } | 120 } |
| 121 }, | 121 }, |
| 122 | 122 |
| 123 /** | 123 /** |
| 124 * Focuses the previous item (relative to the currently focused item) in the | 124 * Focuses the previous item (relative to the currently focused item) in the |
| 125 * menu, disabled items will be skipped. | 125 * menu, disabled items will be skipped. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 }, | 186 }, |
| 187 | 187 |
| 188 /** | 188 /** |
| 189 * A handler that responds to mutation changes related to the list of items | 189 * A handler that responds to mutation changes related to the list of items |
| 190 * in the menu. | 190 * in the menu. |
| 191 * | 191 * |
| 192 * @param {CustomEvent} event An event containing mutation records as its | 192 * @param {CustomEvent} event An event containing mutation records as its |
| 193 * detail. | 193 * detail. |
| 194 */ | 194 */ |
| 195 _onIronItemsChanged: function(event) { | 195 _onIronItemsChanged: function(event) { |
| 196 var mutations = event.detail; | 196 if (event.detail.addedNodes.length) { |
| 197 var mutation; | 197 this._resetTabindices(); |
| 198 var index; | |
| 199 | |
| 200 for (index = 0; index < mutations.length; ++index) { | |
| 201 mutation = mutations[index]; | |
| 202 | |
| 203 if (mutation.addedNodes.length) { | |
| 204 this._resetTabindices(); | |
| 205 break; | |
| 206 } | |
| 207 } | 198 } |
| 208 }, | 199 }, |
| 209 | 200 |
| 210 /** | 201 /** |
| 211 * Handler that is called when a shift+tab keypress is detected by the menu. | 202 * Handler that is called when a shift+tab keypress is detected by the menu. |
| 212 * | 203 * |
| 213 * @param {CustomEvent} event A key combination event. | 204 * @param {CustomEvent} event A key combination event. |
| 214 */ | 205 */ |
| 215 _onShiftTabDown: function(event) { | 206 _onShiftTabDown: function(event) { |
| 216 var oldTabIndex = this.getAttribute('tabindex'); | 207 var oldTabIndex = this.getAttribute('tabindex'); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 }; | 307 }; |
| 317 | 308 |
| 318 Polymer.IronMenuBehaviorImpl._shiftTabPressed = false; | 309 Polymer.IronMenuBehaviorImpl._shiftTabPressed = false; |
| 319 | 310 |
| 320 /** @polymerBehavior Polymer.IronMenuBehavior */ | 311 /** @polymerBehavior Polymer.IronMenuBehavior */ |
| 321 Polymer.IronMenuBehavior = [ | 312 Polymer.IronMenuBehavior = [ |
| 322 Polymer.IronMultiSelectableBehavior, | 313 Polymer.IronMultiSelectableBehavior, |
| 323 Polymer.IronA11yKeysBehavior, | 314 Polymer.IronA11yKeysBehavior, |
| 324 Polymer.IronMenuBehaviorImpl | 315 Polymer.IronMenuBehaviorImpl |
| 325 ]; | 316 ]; |
| OLD | NEW |