| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 @license | 2 @license |
| 3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | 3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
| 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
| 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
| 7 Code distributed by Google as part of the polymer project is also | 7 Code distributed by Google as part of the polymer project is also |
| 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 9 --> | 9 --> |
| 10 | 10 |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 * | 234 * |
| 235 * Use the `keyBindings` prototype property to express what combination of k
eys | 235 * Use the `keyBindings` prototype property to express what combination of k
eys |
| 236 * will trigger the event to fire. | 236 * will trigger the event to fire. |
| 237 * | 237 * |
| 238 * Use the `key-event-target` attribute to set up event handlers on a specif
ic | 238 * Use the `key-event-target` attribute to set up event handlers on a specif
ic |
| 239 * node. | 239 * node. |
| 240 * The `keys-pressed` event will fire when one of the key combinations set w
ith the | 240 * The `keys-pressed` event will fire when one of the key combinations set w
ith the |
| 241 * `keys` property is pressed. | 241 * `keys` property is pressed. |
| 242 * | 242 * |
| 243 * @demo demo/index.html | 243 * @demo demo/index.html |
| 244 * @polymerBehavior IronA11yKeysBehavior | 244 * @polymerBehavior |
| 245 */ | 245 */ |
| 246 Polymer.IronA11yKeysBehavior = { | 246 Polymer.IronA11yKeysBehavior = { |
| 247 properties: { | 247 properties: { |
| 248 /** | 248 /** |
| 249 * The HTMLElement that will be firing relevant KeyboardEvents. | 249 * The HTMLElement that will be firing relevant KeyboardEvents. |
| 250 */ | 250 */ |
| 251 keyEventTarget: { | 251 keyEventTarget: { |
| 252 type: Object, | 252 type: Object, |
| 253 value: function() { | 253 value: function() { |
| 254 return this; | 254 return this; |
| 255 } | 255 } |
| 256 }, | 256 }, |
| 257 | 257 |
| 258 /** |
| 259 * If true, this property will cause the implementing element to |
| 260 * automatically stop propagation on any handled KeyboardEvents. |
| 261 */ |
| 262 stopKeyboardEventPropagation: { |
| 263 type: Boolean, |
| 264 value: false |
| 265 }, |
| 266 |
| 258 _boundKeyHandlers: { | 267 _boundKeyHandlers: { |
| 259 type: Array, | 268 type: Array, |
| 260 value: function() { | 269 value: function() { |
| 261 return []; | 270 return []; |
| 262 } | 271 } |
| 263 }, | 272 }, |
| 264 | 273 |
| 265 // We use this due to a limitation in IE10 where instances will have | 274 // We use this due to a limitation in IE10 where instances will have |
| 266 // own properties of everything on the "prototype". | 275 // own properties of everything on the "prototype". |
| 267 _imperativeKeyBindings: { | 276 _imperativeKeyBindings: { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 keyHandlerTuple = this._boundKeyHandlers.pop(); | 400 keyHandlerTuple = this._boundKeyHandlers.pop(); |
| 392 keyEventTarget = keyHandlerTuple[0]; | 401 keyEventTarget = keyHandlerTuple[0]; |
| 393 eventName = keyHandlerTuple[1]; | 402 eventName = keyHandlerTuple[1]; |
| 394 boundKeyHandler = keyHandlerTuple[2]; | 403 boundKeyHandler = keyHandlerTuple[2]; |
| 395 | 404 |
| 396 keyEventTarget.removeEventListener(eventName, boundKeyHandler); | 405 keyEventTarget.removeEventListener(eventName, boundKeyHandler); |
| 397 } | 406 } |
| 398 }, | 407 }, |
| 399 | 408 |
| 400 _onKeyBindingEvent: function(keyBindings, event) { | 409 _onKeyBindingEvent: function(keyBindings, event) { |
| 410 if (this.stopKeyboardEventPropagation) { |
| 411 event.stopPropagation(); |
| 412 } |
| 413 |
| 401 keyBindings.forEach(function(keyBinding) { | 414 keyBindings.forEach(function(keyBinding) { |
| 402 var keyCombo = keyBinding[0]; | 415 var keyCombo = keyBinding[0]; |
| 403 var handlerName = keyBinding[1]; | 416 var handlerName = keyBinding[1]; |
| 404 | 417 |
| 405 if (!event.defaultPrevented && keyComboMatchesEvent(keyCombo, event))
{ | 418 if (!event.defaultPrevented && keyComboMatchesEvent(keyCombo, event))
{ |
| 406 this._triggerKeyHandler(keyCombo, handlerName, event); | 419 this._triggerKeyHandler(keyCombo, handlerName, event); |
| 407 } | 420 } |
| 408 }, this); | 421 }, this); |
| 409 }, | 422 }, |
| 410 | 423 |
| 411 _triggerKeyHandler: function(keyCombo, handlerName, keyboardEvent) { | 424 _triggerKeyHandler: function(keyCombo, handlerName, keyboardEvent) { |
| 412 var detail = Object.create(keyCombo); | 425 var detail = Object.create(keyCombo); |
| 413 detail.keyboardEvent = keyboardEvent; | 426 detail.keyboardEvent = keyboardEvent; |
| 414 | 427 |
| 415 this[handlerName].call(this, new CustomEvent(keyCombo.event, { | 428 this[handlerName].call(this, new CustomEvent(keyCombo.event, { |
| 416 detail: detail | 429 detail: detail |
| 417 })); | 430 })); |
| 418 } | 431 } |
| 419 }; | 432 }; |
| 420 })(); | 433 })(); |
| 421 </script> | 434 </script> |
| OLD | NEW |