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

Side by Side Diff: lib/src/iron-behaviors/iron-button-state.html

Issue 1418513006: update elements and fix some bugs (Closed) Base URL: git@github.com:dart-lang/polymer_elements.git@master
Patch Set: code review updates Created 5 years, 1 month 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 <!--
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 118
119 // to emulate native checkbox, (de-)activations from a user interaction fire 119 // to emulate native checkbox, (de-)activations from a user interaction fire
120 // 'change' events 120 // 'change' events
121 _userActivate: function(active) { 121 _userActivate: function(active) {
122 if (this.active !== active) { 122 if (this.active !== active) {
123 this.active = active; 123 this.active = active;
124 this.fire('change'); 124 this.fire('change');
125 } 125 }
126 }, 126 },
127 127
128 _eventSourceIsPrimaryInput: function(event) {
129 event = event.detail.sourceEvent || event;
130
131 // Always true for non-mouse events....
132 if (!this._mouseEventRe.test(event.type)) {
133 return true;
134 }
135
136 // http://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
137 if ('buttons' in event) {
138 return event.buttons === 1;
139 }
140
141 // http://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/which
142 if (typeof event.which === 'number') {
143 return event.which < 2;
144 }
145
146 // http://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
147 return event.button < 1;
148 },
149
150 _downHandler: function(event) { 128 _downHandler: function(event) {
151 if (!this._eventSourceIsPrimaryInput(event)) {
152 return;
153 }
154
155 this._setPointerDown(true); 129 this._setPointerDown(true);
156 this._setPressed(true); 130 this._setPressed(true);
157 this._setReceivedFocusFromKeyboard(false); 131 this._setReceivedFocusFromKeyboard(false);
158 }, 132 },
159 133
160 _upHandler: function() { 134 _upHandler: function() {
161 this._setPointerDown(false); 135 this._setPointerDown(false);
162 this._setPressed(false); 136 this._setPressed(false);
163 }, 137 },
164 138
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 198
225 }; 199 };
226 200
227 /** @polymerBehavior */ 201 /** @polymerBehavior */
228 Polymer.IronButtonState = [ 202 Polymer.IronButtonState = [
229 Polymer.IronA11yKeysBehavior, 203 Polymer.IronA11yKeysBehavior,
230 Polymer.IronButtonStateImpl 204 Polymer.IronButtonStateImpl
231 ]; 205 ];
232 206
233 </script> 207 </script>
OLDNEW
« no previous file with comments | « lib/src/iron-autogrow-textarea/test/basic.html ('k') | lib/src/iron-behaviors/test/active-state.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698