Chromium Code Reviews| Index: chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js |
| diff --git a/chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js b/chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js |
| index d6c28711b4d28f8981da2fa4aa487e02dafc6e40..e301a175a11b176a9dfee927de67dba8d754cbe9 100644 |
| --- a/chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js |
| +++ b/chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js |
| @@ -53,6 +53,23 @@ Polymer({ |
| notify: true, |
| value: '', |
| observer: 'onPinValueChange_' |
| + }, |
| + |
| + /** |
| + * The intervalID used for the backspace button set/clear interval. |
| + */ |
| + intervalId_: { |
|
jdufault
2016/09/01 16:40:11
repeatClearIntervalId_?
sammiequon
2016/09/02 17:24:55
Done.
|
| + type: Number, |
| + value: 0 |
| + }, |
| + |
| + /** |
| + * When the backspace button is held down, it repeatly clears the last |
| + * character of the input value every intervalMs. |
| + */ |
| + intervalMs_: { |
|
jdufault
2016/09/01 16:40:11
Make this a constant value defined at the top of t
sammiequon
2016/09/02 17:24:55
Done.
|
| + type: Number, |
| + value: 250 |
| } |
| }, |
| @@ -97,12 +114,34 @@ Polymer({ |
| /** |
| * Called when the user wants to erase the last character of the entered |
| - * PIN value. |
| + * PIN value. |
| */ |
| onPinClear_: function() { |
| this.value = this.value.substring(0, this.value.length - 1); |
| }, |
| + /** |
| + * Called when the user presses the backspace button. Starts a interval |
| + * callback to repeatedly clear the last pin value until the interval is |
| + * cleared. |
| + * @private |
| + */ |
| + onBackspaceMouseDown_: function() { |
| + this.onPinClear_(); |
| + this.intervalId_ = setInterval(function() { |
| + this.async(function() { this.onPinClear_(); }, 1); |
|
jdufault
2016/09/01 16:40:11
Remove the this.async call if you're still using s
sammiequon
2016/09/02 17:24:55
Done.
|
| + }.bind(this), this.intervalMs_); |
| + }, |
| + |
| + /** |
| + * Called when the user unpresses the backspace button. Stops the interval |
| + * callback. |
| + * @private |
| + */ |
| + onBackspaceMouseUpLeave_: function() { |
| + clearInterval(this.intervalId_); |
| + }, |
| + |
| /** Called when a key event is pressed while the input element has focus. */ |
| onInputKeyDown_: function(event) { |
| // Up/down pressed, swallow the event to prevent the input value from |
| @@ -143,6 +182,11 @@ Polymer({ |
| * @private |
| */ |
| onKeyPress_: function(event) { |
| + // If the active element is the input element, the input element itself will |
| + // handle the keypresses, so we do not handle them here. |
| + if (this.shadowRoot.activeElement == this.inputElement) |
| + return; |
| + |
| var code = event.keyCode; |
| // Enter pressed. |