| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 observers: [ | 84 observers: [ |
| 85 '_detectKeyboardFocus(focused)' | 85 '_detectKeyboardFocus(focused)' |
| 86 ], | 86 ], |
| 87 | 87 |
| 88 keyBindings: { | 88 keyBindings: { |
| 89 'enter:keydown': '_asyncClick', | 89 'enter:keydown': '_asyncClick', |
| 90 'space:keydown': '_spaceKeyDownHandler', | 90 'space:keydown': '_spaceKeyDownHandler', |
| 91 'space:keyup': '_spaceKeyUpHandler', | 91 'space:keyup': '_spaceKeyUpHandler', |
| 92 }, | 92 }, |
| 93 | 93 |
| 94 _mouseEventRe: /^mouse/, |
| 95 |
| 94 _tapHandler: function() { | 96 _tapHandler: function() { |
| 95 if (this.toggles) { | 97 if (this.toggles) { |
| 96 // a tap is needed to toggle the active state | 98 // a tap is needed to toggle the active state |
| 97 this._userActivate(!this.active); | 99 this._userActivate(!this.active); |
| 98 } else { | 100 } else { |
| 99 this.active = false; | 101 this.active = false; |
| 100 } | 102 } |
| 101 }, | 103 }, |
| 102 | 104 |
| 103 _detectKeyboardFocus: function(focused) { | 105 _detectKeyboardFocus: function(focused) { |
| 104 this._setReceivedFocusFromKeyboard(!this.pointerDown && focused); | 106 this._setReceivedFocusFromKeyboard(!this.pointerDown && focused); |
| 105 }, | 107 }, |
| 106 | 108 |
| 107 // to emulate native checkbox, (de-)activations from a user interaction fire | 109 // to emulate native checkbox, (de-)activations from a user interaction fire |
| 108 // 'change' events | 110 // 'change' events |
| 109 _userActivate: function(active) { | 111 _userActivate: function(active) { |
| 110 this.active = active; | 112 this.active = active; |
| 111 this.fire('change'); | 113 this.fire('change'); |
| 112 }, | 114 }, |
| 113 | 115 |
| 114 _downHandler: function() { | 116 _eventSourceIsPrimaryInput: function(event) { |
| 117 event = event.detail.sourceEvent || event; |
| 118 |
| 119 // Always true for non-mouse events.... |
| 120 if (!this._mouseEventRe.test(event.type)) { |
| 121 return true; |
| 122 } |
| 123 |
| 124 // http://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons |
| 125 if ('buttons' in event) { |
| 126 return event.buttons === 1; |
| 127 } |
| 128 |
| 129 // http://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/which |
| 130 if (typeof event.which === 'number') { |
| 131 return event.which < 2; |
| 132 } |
| 133 |
| 134 // http://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button |
| 135 return event.button < 1; |
| 136 }, |
| 137 |
| 138 _downHandler: function(event) { |
| 139 if (!this._eventSourceIsPrimaryInput(event)) { |
| 140 return; |
| 141 } |
| 142 |
| 115 this._setPointerDown(true); | 143 this._setPointerDown(true); |
| 116 this._setPressed(true); | 144 this._setPressed(true); |
| 117 this._setReceivedFocusFromKeyboard(false); | 145 this._setReceivedFocusFromKeyboard(false); |
| 118 }, | 146 }, |
| 119 | 147 |
| 120 _upHandler: function() { | 148 _upHandler: function() { |
| 121 this._setPointerDown(false); | 149 this._setPointerDown(false); |
| 122 this._setPressed(false); | 150 this._setPressed(false); |
| 123 }, | 151 }, |
| 124 | 152 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 205 |
| 178 }; | 206 }; |
| 179 | 207 |
| 180 /** @polymerBehavior */ | 208 /** @polymerBehavior */ |
| 181 Polymer.IronButtonState = [ | 209 Polymer.IronButtonState = [ |
| 182 Polymer.IronA11yKeysBehavior, | 210 Polymer.IronA11yKeysBehavior, |
| 183 Polymer.IronButtonStateImpl | 211 Polymer.IronButtonStateImpl |
| 184 ]; | 212 ]; |
| 185 | 213 |
| 186 </script> | 214 </script> |
| OLD | NEW |