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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 120 |
121 // Enter pressed. | 121 // Enter pressed. |
122 if (event.keyCode == 13) { | 122 if (event.keyCode == 13) { |
123 this.firePinSubmitEvent_(); | 123 this.firePinSubmitEvent_(); |
124 event.preventDefault(); | 124 event.preventDefault(); |
125 return; | 125 return; |
126 } | 126 } |
127 }, | 127 }, |
128 | 128 |
129 /** | 129 /** |
130 * Changes the color of the submit button if PIN is ready. | 130 * Disables the submit and backspace button if nothing is entered. |
131 * @param {string} value | 131 * @param {string} value |
132 * @private | 132 * @private |
133 */ | 133 */ |
134 getSubmitClass_: function(value) { | 134 hasInput_: function(value) { |
135 return value.length > 0 ? 'ready-background' : ''; | 135 return value.length > 0; |
136 }, | 136 }, |
137 | 137 |
138 /** | 138 /** |
139 * Computes whether the input type for the pin input should be password or | 139 * Computes whether the input type for the pin input should be password or |
140 * numerical. | 140 * numerical. |
141 * @param {boolean} enablePassword | 141 * @param {boolean} enablePassword |
142 * @private | 142 * @private |
143 */ | 143 */ |
144 getInputType_: function(enablePassword) { | 144 getInputType_: function(enablePassword) { |
145 return enablePassword ? 'password' : 'number'; | 145 return enablePassword ? 'password' : 'number'; |
146 }, | 146 }, |
147 | 147 |
148 /** | 148 /** |
149 * Computes the value of the pin input placeholder. | 149 * Computes the value of the pin input placeholder. |
150 * @param {boolean} enablePassword | 150 * @param {boolean} enablePassword |
151 * @private | 151 * @private |
152 */ | 152 */ |
153 getInputPlaceholder_: function(enablePassword) { | 153 getInputPlaceholder_: function(enablePassword) { |
154 return enablePassword ? this.i18n('pinKeyboardPlaceholderPinPassword') : | 154 return enablePassword ? this.i18n('pinKeyboardPlaceholderPinPassword') : |
155 this.i18n('pinKeyboardPlaceholderPin'); | 155 this.i18n('pinKeyboardPlaceholderPin'); |
156 }, | 156 }, |
157 | 157 |
158 /** | 158 /** |
159 * Computes the direction of the pin input. | 159 * Computes the direction of the pin input. |
160 * @param {string} password | 160 * @param {string} password |
161 * @private | 161 * @private |
162 */ | 162 */ |
163 getInputClass_: function(password) { | 163 isInputRtl_: function(password) { |
164 // +password will convert a string to a number or to NaN if that's not | 164 // +password will convert a string to a number or to NaN if that's not |
165 // possible. Number.isInteger will verify the value is not a NaN and that it | 165 // possible. Number.isInteger will verify the value is not a NaN and that it |
166 // does not contain decimals. | 166 // does not contain decimals. |
167 // This heuristic will fail for inputs like '1.0'. | 167 // This heuristic will fail for inputs like '1.0'. |
168 // | 168 // |
169 // Since we still support users entering their passwords through the PIN | 169 // Since we still support users entering their passwords through the PIN |
170 // keyboard, we swap the input box to rtl when we think it is a password | 170 // keyboard, we swap the input box to rtl when we think it is a password |
171 // (just numbers), if the document direction is rtl. | 171 // (just numbers), if the document direction is rtl. |
172 var enableRtl = (document.dir == 'rtl') && !Number.isInteger(+password); | 172 return (document.dir == 'rtl') && !Number.isInteger(+password); |
173 return enableRtl ? 'input-non-pin' : ''; | |
174 }, | 173 }, |
175 | |
176 /** | |
177 * Computes if the submit button is visible. | |
178 * @param {boolean} submitEnabled | |
179 * @private | |
180 */ | |
181 getSubmitHiddenClass_: function(submitEnabled) { | |
182 return submitEnabled ? '' : 'submit-button-hidden'; | |
183 } | |
184 }); | 174 }); |
OLD | NEW |