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 dfc111d4c5fcd7c32df8aa1e7a95762d0894bfbb..ef64fefc0c580321d88d3bf72bce8cb60e7879f1 100644 |
| --- a/chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js |
| +++ b/chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js |
| @@ -26,6 +26,13 @@ Polymer({ |
| is: 'pin-keyboard', |
| properties: { |
| + type: { |
| + type: String, |
| + notify: true, |
| + value: 'number', |
| + observer: 'onInputTypeChange_' |
| + }, |
| + |
| /** The value stored in the keyboard's input element. */ |
| value: { |
| type: String, |
| @@ -51,6 +58,13 @@ Polymer({ |
| this.fire('submit', { pin: this.value }); |
| }, |
| + changeRTLIfNeeded_: function(password) { |
|
jdufault
2016/06/28 18:38:47
What about updateRtlState? changeRTL implies a one
sammiequon
2016/06/28 20:59:31
Done.
|
| + var regex = /^([0-9]*)$/; |
| + var shouldRtl = !regex.test(password); |
|
jdufault
2016/06/28 18:38:47
What about Number.isInteger(+password)?
+password
sammiequon
2016/06/28 20:59:31
Done.
|
| + this.$$('#pin-input').classList.toggle( |
| + 'pin-keyboard-input-non-pin', shouldRtl); |
| + }, |
| + |
| /** |
| * Fires an update event with the current PIN value. The event will only be |
| * fired if the PIN value has actually changed. |
| @@ -58,8 +72,10 @@ Polymer({ |
| * @param {string} previous |
| */ |
| onPinValueChange_: function(value, previous) { |
| - if (value != previous) |
| + if (value != previous) { |
| this.fire('pin-change', { pin: value }); |
| + this.changeRTLIfNeeded_(value); |
| + } |
| }, |
| /** Called when the user wants to erase the last character of the entered |
| @@ -84,5 +100,20 @@ Polymer({ |
| event.preventDefault(); |
| return; |
| } |
| + }, |
| + |
| + /** |
| + * Changes the input type for the pin-keyboard input element, based on the |
| + * input specified for the pin-keyboard. |
| + * @param {string} value |
| + * @param {string} previous |
| + */ |
| + onInputTypeChange_: function(value, previous) { |
| + if (value != previous) { |
| + if (value == 'password' || value == 'number' || |
| + value == 'text') { |
| + this.$$('#pin-input').type = value; |
| + } |
| + } |
| } |
| }); |