Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 Polymer({ | 5 Polymer({ |
| 6 is: 'pin-keyboard', | 6 is: 'pin-keyboard', |
| 7 | 7 |
| 8 // Called when a keypad number has been tapped. | 8 // Called when a keypad number has been tapped. |
| 9 onNumberTap_: function(event, detail) { | 9 onNumberTap_: function(event, detail) { |
| 10 var target = event.target; | 10 var target = event.target; |
| 11 var value = target.getAttribute('value'); | 11 var value = target.getAttribute('value'); |
| 12 | 12 |
| 13 var input = this.$$('#pin-input'); | 13 var input = this.$$('#pin-input'); |
| 14 input.value += value; | 14 input.value += value; |
| 15 }, | 15 }, |
| 16 | 16 |
| 17 // Called when the user wants to clear the current entered PIN value. | |
| 18 onPinClear_: function() { | |
|
jdufault
2016/06/22 23:18:01
onPinBackspace_? Though that doesn't sound much be
sammiequon
2016/06/22 23:43:28
Done.
| |
| 19 var pin = this.$$('#pin-input'); | |
| 20 pin.value = pin.value.substring(0, pin.value.length - 1); | |
| 21 }, | |
| 22 | |
| 17 // Called when the user wants to submit the PIN. | 23 // Called when the user wants to submit the PIN. |
| 18 onPinSubmit_: function() { | 24 onPinSubmit_: function() { |
| 19 var pin = this.$$('#pin-input').value; | 25 var pin = this.$$('#pin-input').value; |
| 20 this.fire('submit', { pin: pin }); | 26 this.fire('submit', { pin: pin }); |
| 21 }, | 27 }, |
| 22 | 28 |
| 23 // Called when a key event is pressed while the input element has focus. | 29 // Called when a key event is pressed while the input element has focus. |
| 24 onInputKeyDown_: function(event) { | 30 onInputKeyDown_: function(event) { |
| 25 // Up/down pressed, swallow the event to prevent the input value from | 31 // Up/down pressed, swallow the event to prevent the input value from |
| 26 // being incremented or decremented. | 32 // being incremented or decremented. |
| 27 if (event.keyCode == 38 || event.keyCode == 40) | 33 if (event.keyCode == 38 || event.keyCode == 40) |
| 28 event.preventDefault(); | 34 event.preventDefault(); |
| 29 | 35 |
| 30 // Enter pressed. | 36 // Enter pressed. |
| 31 if (event.keyCode == 13) { | 37 if (event.keyCode == 13) { |
| 32 this.onPinSubmit_(); | 38 this.onPinSubmit_(); |
| 33 event.preventDefault(); | 39 event.preventDefault(); |
| 34 } | 40 } |
| 35 } | 41 } |
| 36 }); | 42 }); |
| OLD | NEW |