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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 ], | 55 ], |
56 | 56 |
57 properties: { | 57 properties: { |
58 /** | 58 /** |
59 * Whether or not the keyboard's input element should be numerical | 59 * Whether or not the keyboard's input element should be numerical |
60 * or password. | 60 * or password. |
61 * @private | 61 * @private |
62 */ | 62 */ |
63 enablePassword: { | 63 enablePassword: { |
64 type: Boolean, | 64 type: Boolean, |
65 value: false | 65 value: false, |
66 }, | 66 }, |
67 | 67 |
68 /** | 68 /** |
69 * The password element the pin keyboard is associated with. If this is not | 69 * The password element the pin keyboard is associated with. If this is not |
70 * set, then a default input element is shown and used. | 70 * set, then a default input element is shown and used. |
71 * @type {?Element} | 71 * @type {?Element} |
72 * @private | 72 * @private |
73 */ | 73 */ |
74 passwordElement: { | 74 passwordElement: { |
75 type: Object, | 75 type: Object, |
76 value: function() { return this.$$('#pin-input'); }, | 76 value: function() { |
77 observer: 'onPasswordElementAttached_' | 77 return this.$.pinInput.inputElement; |
| 78 }, |
| 79 observer: 'onPasswordElementAttached_', |
78 }, | 80 }, |
79 | 81 |
80 /** | 82 /** |
81 * The value stored in the keyboard's input element. | |
82 * @private | |
83 */ | |
84 value: { | |
85 type: String, | |
86 notify: true, | |
87 value: '', | |
88 observer: 'onPinValueChange_' | |
89 }, | |
90 | |
91 /** | |
92 * The intervalID used for the backspace button set/clear interval. | 83 * The intervalID used for the backspace button set/clear interval. |
93 * @private | 84 * @private |
94 */ | 85 */ |
95 repeatBackspaceIntervalId_: { | 86 repeatBackspaceIntervalId_: { |
96 type: Number, | 87 type: Number, |
97 value: 0 | 88 value: 0, |
98 }, | 89 }, |
99 | 90 |
100 /** | 91 /** |
101 * The timeoutID used for the auto backspace. | 92 * The timeoutID used for the auto backspace. |
102 * @private | 93 * @private |
103 */ | 94 */ |
104 startAutoBackspaceId_: { | 95 startAutoBackspaceId_: { |
105 type: Number, | 96 type: Number, |
106 value: 0 | 97 value: 0, |
107 } | 98 }, |
| 99 |
| 100 /** |
| 101 * Whether or not to show the default pin input. |
| 102 * @private |
| 103 */ |
| 104 showPinInput_: { |
| 105 type: Boolean, |
| 106 value: false, |
| 107 }, |
| 108 |
| 109 /** |
| 110 * The value stored in the keyboard's input element. |
| 111 * @private |
| 112 */ |
| 113 value: { |
| 114 type: String, |
| 115 notify: true, |
| 116 value: '', |
| 117 observer: 'onPinValueChange_', |
| 118 }, |
108 }, | 119 }, |
109 | 120 |
110 /** | 121 /** |
111 * Called when a password element is attached to the pin keyboard. | 122 * Called when a password element is attached to the pin keyboard. |
112 * @param {HTMLInputElement} inputElement The PIN keyboard's input element. | 123 * @param {HTMLInputElement} inputElement The PIN keyboard's input element. |
113 * @private | 124 * @private |
114 */ | 125 */ |
115 onPasswordElementAttached_: function(inputElement) { | 126 onPasswordElementAttached_: function(inputElement) { |
116 if (inputElement != this.$$('#pin-input')) | 127 this.showPinInput_ = inputElement == this.$.pinInput.inputElement; |
117 this.$$('#pin-input').hidden = true; | |
118 inputElement.addEventListener('input', | 128 inputElement.addEventListener('input', |
119 this.handleInputChanged_.bind(this)); | 129 this.handleInputChanged_.bind(this)); |
120 }, | 130 }, |
121 | 131 |
122 /** | 132 /** |
123 * Called when the user uses the keyboard to enter a value into the input | 133 * Called when the user uses the keyboard to enter a value into the input |
124 * element. | 134 * element. |
125 * @param {Event} event The event object. | 135 * @param {Event} event The event object. |
126 * @private | 136 * @private |
127 */ | 137 */ |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 // does not contain decimals. | 391 // does not contain decimals. |
382 // This heuristic will fail for inputs like '1.0'. | 392 // This heuristic will fail for inputs like '1.0'. |
383 // | 393 // |
384 // Since we still support users entering their passwords through the PIN | 394 // Since we still support users entering their passwords through the PIN |
385 // keyboard, we swap the input box to rtl when we think it is a password | 395 // keyboard, we swap the input box to rtl when we think it is a password |
386 // (just numbers), if the document direction is rtl. | 396 // (just numbers), if the document direction is rtl. |
387 return (document.dir == 'rtl') && !Number.isInteger(+password); | 397 return (document.dir == 'rtl') && !Number.isInteger(+password); |
388 }, | 398 }, |
389 }); | 399 }); |
390 })(); | 400 })(); |
OLD | NEW |