| 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 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * 'pin-keyboard' is a keyboard that can be used to enter PINs or more generally | 7 * 'pin-keyboard' is a keyboard that can be used to enter PINs or more generally |
| 8 * numeric values. | 8 * numeric values. |
| 9 * | 9 * |
| 10 * Properties: | 10 * Properties: |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 value: '', | 46 value: '', |
| 47 observer: 'onPinValueChange_' | 47 observer: 'onPinValueChange_' |
| 48 } | 48 } |
| 49 }, | 49 }, |
| 50 | 50 |
| 51 /** Transfers focus to the input element. */ | 51 /** Transfers focus to the input element. */ |
| 52 focus: function() { | 52 focus: function() { |
| 53 this.$$('#pin-input').focus(); | 53 this.$$('#pin-input').focus(); |
| 54 }, | 54 }, |
| 55 | 55 |
| 56 /** Called when a keypad number has been tapped. */ | 56 /** |
| 57 * Called when a keypad number has been tapped. |
| 58 * @param {!{target: !PaperButtonElement}} event |
| 59 * @private |
| 60 */ |
| 57 onNumberTap_: function(event, detail) { | 61 onNumberTap_: function(event, detail) { |
| 58 var numberValue = event.target.getAttribute('value'); | 62 var numberValue = event.target.getAttribute('value'); |
| 59 this.value += numberValue; | 63 this.value += numberValue; |
| 64 |
| 65 // If a number button is clicked, we do not want to switch focus to the |
| 66 // button, therefore we transfer focus back to the input, but if a number |
| 67 // button is tabbed into, it should keep focus, so users can use tab and |
| 68 // spacebar/return to enter their PIN. |
| 69 if (!event.target.receivedFocusFromKeyboard) |
| 70 this.focus(); |
| 60 }, | 71 }, |
| 61 | 72 |
| 62 /** Fires a submit event with the current PIN value. */ | 73 /** Fires a submit event with the current PIN value. */ |
| 63 firePinSubmitEvent_: function() { | 74 firePinSubmitEvent_: function() { |
| 64 this.fire('submit', { pin: this.value }); | 75 this.fire('submit', { pin: this.value }); |
| 65 }, | 76 }, |
| 66 | 77 |
| 67 /** | 78 /** |
| 68 * Fires an update event with the current PIN value. The event will only be | 79 * Fires an update event with the current PIN value. The event will only be |
| 69 * fired if the PIN value has actually changed. | 80 * fired if the PIN value has actually changed. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 // does not contain decimals. | 146 // does not contain decimals. |
| 136 // This heuristic will fail for inputs like '1.0'. | 147 // This heuristic will fail for inputs like '1.0'. |
| 137 // | 148 // |
| 138 // Since we still support users entering their passwords through the PIN | 149 // Since we still support users entering their passwords through the PIN |
| 139 // keyboard, we swap the input box to rtl when we think it is a password | 150 // keyboard, we swap the input box to rtl when we think it is a password |
| 140 // (just numbers), if the document direction is rtl. | 151 // (just numbers), if the document direction is rtl. |
| 141 var enableRtl = (document.dir == 'rtl') && !Number.isInteger(+password); | 152 var enableRtl = (document.dir == 'rtl') && !Number.isInteger(+password); |
| 142 return enableRtl ? 'input-non-pin' : ''; | 153 return enableRtl ? 'input-non-pin' : ''; |
| 143 } | 154 } |
| 144 }); | 155 }); |
| OLD | NEW |