Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js

Issue 2222583002: Lock screen pin keyboard ui upgrades. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Pin warnings moved inside pin keyboard. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 29 matching lines...) Expand all
40 }, 40 },
41 41
42 /** 42 /**
43 * Whether or not the keyboard's submit button should be shown. 43 * Whether or not the keyboard's submit button should be shown.
44 */ 44 */
45 enableSubmitButton: { 45 enableSubmitButton: {
46 type: Boolean, 46 type: Boolean,
47 value: false 47 value: false
48 }, 48 },
49 49
50 /**
51 * Whether or not to show an error.
52 */
53 errorMessage: {
54 type: String,
55 value: ''
56 },
57
50 /** The value stored in the keyboard's input element. */ 58 /** The value stored in the keyboard's input element. */
51 value: { 59 value: {
52 type: String, 60 type: String,
53 notify: true, 61 notify: true,
54 value: '', 62 value: '',
55 observer: 'onPinValueChange_' 63 observer: 'onPinValueChange_'
56 } 64 }
57 }, 65 },
58 66
59 /** 67 /**
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 128
121 // Enter pressed. 129 // Enter pressed.
122 if (event.keyCode == 13) { 130 if (event.keyCode == 13) {
123 this.firePinSubmitEvent_(); 131 this.firePinSubmitEvent_();
124 event.preventDefault(); 132 event.preventDefault();
125 return; 133 return;
126 } 134 }
127 }, 135 },
128 136
129 /** 137 /**
130 * Changes the color of the submit button if PIN is ready. 138 * Changes the color of the input text if it is not empty.
131 * @param {string} value 139 * @param {string} value
132 * @private 140 * @private
133 */ 141 */
134 getSubmitClass_: function(value) { 142 getContentClass_: function(value) {
135 return value.length > 0 ? 'ready-background' : ''; 143 return value.length > 0 ? 'has-content' : '';
136 }, 144 },
137 145
138 /** 146 /**
147 * Disables the submit and backspace button if nothing is entered.
148 * @param {string} value
149 * @private
150 */
151 hasInput_: function(value) {
152 return value.length > 0;
153 },
154
155 /**
139 * Computes whether the input type for the pin input should be password or 156 * Computes whether the input type for the pin input should be password or
140 * numerical. 157 * numerical.
141 * @param {boolean} enablePassword 158 * @param {boolean} enablePassword
142 * @private 159 * @private
143 */ 160 */
144 getInputType_: function(enablePassword) { 161 getInputType_: function(enablePassword) {
145 return enablePassword ? 'password' : 'number'; 162 return enablePassword ? 'password' : 'number';
146 }, 163 },
147 164
148 /** 165 /**
149 * Computes the value of the pin input placeholder. 166 * Computes the value of the pin input placeholder.
150 * @param {boolean} enablePassword 167 * @param {boolean} enablePassword
151 * @private 168 * @private
152 */ 169 */
153 getInputPlaceholder_: function(enablePassword) { 170 getInputPlaceholder_: function(enablePassword) {
154 return enablePassword ? this.i18n('pinKeyboardPlaceholderPinPassword') : 171 return enablePassword ? this.i18n('pinKeyboardPlaceholderPinPassword') :
155 this.i18n('pinKeyboardPlaceholderPin'); 172 this.i18n('pinKeyboardPlaceholderPin');
156 }, 173 },
157 174
158 /** 175 /**
176 * Hides the error message div if no error is to be shown.
177 * @param {string} errorMessage
178 * @private
179 */
180 hasErrorMessage_: function(errorMessage) {
181 return errorMessage.length > 0;
182 },
183
184 /**
185 * Computes the whether the error message should be shown.
186 * @param {boolean} errorMessage
187 * @private
188 */
189 getErrorClass_: function(errorMessage) {
190 return errorMessage.length > 0 ? 'error-show' : '';
191 },
192
193 /**
194 * Computes the direction of the errorMessage.
jdufault 2016/08/22 20:56:40 nit: error message
sammiequon 2016/08/23 17:30:18 Done.
195 * @private
196 */
197 getErrorDirection_: function() {
198 return document.dir == 'rtl' ? 'error-rtl' : '';
199 },
200
201 /**
159 * Computes the direction of the pin input. 202 * Computes the direction of the pin input.
160 * @param {string} password 203 * @param {string} password
161 * @private 204 * @private
162 */ 205 */
163 getInputClass_: function(password) { 206 getInputClass_: function(password) {
164 // +password will convert a string to a number or to NaN if that's not 207 // +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 208 // possible. Number.isInteger will verify the value is not a NaN and that it
166 // does not contain decimals. 209 // does not contain decimals.
167 // This heuristic will fail for inputs like '1.0'. 210 // This heuristic will fail for inputs like '1.0'.
168 // 211 //
169 // Since we still support users entering their passwords through the PIN 212 // 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 213 // keyboard, we swap the input box to rtl when we think it is a password
171 // (just numbers), if the document direction is rtl. 214 // (just numbers), if the document direction is rtl.
172 var enableRtl = (document.dir == 'rtl') && !Number.isInteger(+password); 215 var enableRtl = (document.dir == 'rtl') && !Number.isInteger(+password);
173 return enableRtl ? 'input-non-pin' : ''; 216 return enableRtl ? 'input-non-pin' : '';
174 }, 217 },
175 218
176 /** 219 /**
177 * Computes if the submit button is visible. 220 * Computes if the submit button is visible.
178 * @param {boolean} submitEnabled 221 * @param {boolean} submitEnabled
179 * @private 222 * @private
180 */ 223 */
181 getSubmitHiddenClass_: function(submitEnabled) { 224 getSubmitClass_: function(submitEnabled) {
182 return submitEnabled ? '' : 'submit-button-hidden'; 225 return submitEnabled ? '' : 'submit-button-hidden';
183 } 226 }
184 }); 227 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698