| 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 erase the last character of the entered |
| 18 // PIN value. |
| 19 onPinClear_: function() { |
| 20 var pin = this.$$('#pin-input'); |
| 21 pin.value = pin.value.substring(0, pin.value.length - 1); |
| 22 }, |
| 23 |
| 17 // Called when the user wants to submit the PIN. | 24 // Called when the user wants to submit the PIN. |
| 18 onPinSubmit_: function() { | 25 onPinSubmit_: function() { |
| 19 var pin = this.$$('#pin-input').value; | 26 var pin = this.$$('#pin-input').value; |
| 20 this.fire('submit', { pin: pin }); | 27 this.fire('submit', { pin: pin }); |
| 21 }, | 28 }, |
| 22 | 29 |
| 23 // Called when a key event is pressed while the input element has focus. | 30 // Called when a key event is pressed while the input element has focus. |
| 24 onInputKeyDown_: function(event) { | 31 onInputKeyDown_: function(event) { |
| 25 // Up/down pressed, swallow the event to prevent the input value from | 32 // Up/down pressed, swallow the event to prevent the input value from |
| 26 // being incremented or decremented. | 33 // being incremented or decremented. |
| 27 if (event.keyCode == 38 || event.keyCode == 40) | 34 if (event.keyCode == 38 || event.keyCode == 40) |
| 28 event.preventDefault(); | 35 event.preventDefault(); |
| 29 | 36 |
| 30 // Enter pressed. | 37 // Enter pressed. |
| 31 if (event.keyCode == 13) { | 38 if (event.keyCode == 13) { |
| 32 this.onPinSubmit_(); | 39 this.onPinSubmit_(); |
| 33 event.preventDefault(); | 40 event.preventDefault(); |
| 34 } | 41 } |
| 35 } | 42 } |
| 36 }); | 43 }); |
| OLD | NEW |