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 /** | 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 /** Called when a keypad number has been tapped. */ |
| 57 onNumberTap_: function(event, detail) { | 57 onNumberTap_: function(event, detail) { |
| 58 var numberValue = event.target.getAttribute('value'); | 58 var numberValue = event.target.getAttribute('value'); |
| 59 this.value += numberValue; | 59 this.value += numberValue; |
| 60 | |
| 61 // If a number button is clicked, we do not want to switch focus to the | |
| 62 // button, therefore we transfer focus back to the input, but if a number | |
| 63 // button is tabbed into, it should keep focus, so users can use tab and | |
| 64 // spacebar/return to enter their PIN. | |
| 65 if (!event.target.classList.contains('keyboard-focus')) | |
|
jdufault
2016/07/12 19:59:44
What about just casting event.target to the right
| |
| 66 this.focus(); | |
| 60 }, | 67 }, |
| 61 | 68 |
| 62 /** Fires a submit event with the current PIN value. */ | 69 /** Fires a submit event with the current PIN value. */ |
| 63 firePinSubmitEvent_: function() { | 70 firePinSubmitEvent_: function() { |
| 64 this.fire('submit', { pin: this.value }); | 71 this.fire('submit', { pin: this.value }); |
| 65 }, | 72 }, |
| 66 | 73 |
| 67 /** | 74 /** |
| 68 * Fires an update event with the current PIN value. The event will only be | 75 * Fires an update event with the current PIN value. The event will only be |
| 69 * fired if the PIN value has actually changed. | 76 * 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. | 142 // does not contain decimals. |
| 136 // This heuristic will fail for inputs like '1.0'. | 143 // This heuristic will fail for inputs like '1.0'. |
| 137 // | 144 // |
| 138 // Since we still support users entering their passwords through the PIN | 145 // 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 | 146 // keyboard, we swap the input box to rtl when we think it is a password |
| 140 // (just numbers), if the document direction is rtl. | 147 // (just numbers), if the document direction is rtl. |
| 141 var enableRtl = (document.dir == 'rtl') && !Number.isInteger(+password); | 148 var enableRtl = (document.dir == 'rtl') && !Number.isInteger(+password); |
| 142 return enableRtl ? 'input-non-pin' : ''; | 149 return enableRtl ? 'input-non-pin' : ''; |
| 143 } | 150 } |
| 144 }); | 151 }); |
| OLD | NEW |