OLD | NEW |
1 <!-- | 1 <!-- |
2 -- Copyright 2013 The Chromium Authors. All rights reserved. | 2 -- Copyright 2013 The Chromium Authors. All rights reserved. |
3 -- Use of this source code is governed by a BSD-style license that can be | 3 -- Use of this source code is governed by a BSD-style license that can be |
4 -- found in the LICENSE file. | 4 -- found in the LICENSE file. |
5 --> | 5 --> |
6 | 6 |
7 <polymer-element name="kb-key" extends="kb-key-base" | 7 <polymer-element name="kb-key" extends="kb-key-base" |
8 attributes="image imageSize keyCode keyName shiftModifier weight"> | 8 attributes="image imageSize keyCode keyName shiftModifier weight"> |
9 <template> | 9 <template> |
10 <style> | 10 <style> |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 <script> | 183 <script> |
184 Polymer('kb-hide-keyboard-key', { | 184 Polymer('kb-hide-keyboard-key', { |
185 /** | 185 /** |
186 * Timer for a long press event which triggers the display of a keyboard | 186 * Timer for a long press event which triggers the display of a keyboard |
187 * options menu. | 187 * options menu. |
188 * @type {?Function} | 188 * @type {?Function} |
189 */ | 189 */ |
190 longPressTimer: undefined, | 190 longPressTimer: undefined, |
191 | 191 |
192 down: function(event) { | 192 down: function(event) { |
193 var self = this; | 193 this.longPressTimer = this.async(function() { |
194 this.longPressTimer = this.asyncMethod(function() { | 194 if (this.longPressTimer) { |
195 if (self.longPressTimer) { | 195 clearTimeout(this.longPressTimer); |
196 clearTimeout(self.longPressTimer); | 196 this.longPressTimer = undefined; |
197 self.longPressTimer = undefined; | |
198 var details = { | 197 var details = { |
199 left: this.offsetLeft, | 198 left: this.offsetLeft, |
200 top: this.offsetTop, | 199 top: this.offsetTop, |
201 width: this.clientWidth, | 200 width: this.clientWidth, |
202 }; | 201 }; |
203 this.fire('show-options', details); | 202 this.fire('show-options', details); |
204 } | 203 } |
205 }, null, LONGPRESS_DELAY_MSEC); | 204 }, null, LONGPRESS_DELAY_MSEC); |
206 }, | 205 }, |
207 | 206 |
208 /** @override */ | 207 /** @override */ |
209 ready: function() { | 208 ready: function() { |
210 this.super(); | 209 this.super(); |
211 this.image = "keyboard"; | 210 this.image = "keyboard"; |
212 }, | 211 }, |
213 | 212 |
214 up: function(event) { | 213 up: function(event) { |
215 if (this.longPressTimer) { | 214 if (this.longPressTimer) { |
216 clearTimeout(this.longPressTimer); | 215 clearTimeout(this.longPressTimer); |
217 hideKeyboard(); | 216 hideKeyboard(); |
218 this.longPressTimer = undefined; | 217 this.longPressTimer = undefined; |
219 } | 218 } |
220 } | 219 } |
221 }); | 220 }); |
222 </script> | 221 </script> |
223 </polymer-element> | 222 </polymer-element> |
OLD | NEW |