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

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

Issue 2108813002: Added strings of i18n and made the pin-keyboard work for rtl lang. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Rebased. Created 4 years, 5 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:
11 * value: The value of the PIN keyboard. Writing to this property will adjust 11 * value: The value of the PIN keyboard. Writing to this property will adjust
12 * the PIN keyboard's value. 12 * the PIN keyboard's value.
13 * 13 *
14 * Events: 14 * Events:
15 * pin-change: Fired when the PIN value has changed. The pin is available at 15 * pin-change: Fired when the PIN value has changed. The pin is available at
16 * event.detail.pin. 16 * event.detail.pin.
17 * submit: Fired when the PIN is submitted. The pin is available at 17 * submit: Fired when the PIN is submitted. The pin is available at
18 * event.detail.pin. 18 * event.detail.pin.
19 * 19 *
20 * Example: 20 * Example:
21 * <pin-keyboard on-pin-change="onPinChange" on-submit="onPinSubmit" 21 * <pin-keyboard on-pin-change="onPinChange" on-submit="onPinSubmit"
22 * value="{{pinValue}}"> 22 * value="{{pinValue}}">
23 * </pin-keyboard> 23 * </pin-keyboard>
24 */ 24 */
25 Polymer({ 25 Polymer({
26 is: 'pin-keyboard', 26 is: 'pin-keyboard',
27 27
28 behaviors: [
29 I18nBehavior,
30 ],
31
28 properties: { 32 properties: {
33 /**
34 * Whether or not the keyboard's input element should be numerical
35 * or password.
36 */
37 enablePassword: {
38 type: Boolean,
39 value: false
40 },
41
29 /** The value stored in the keyboard's input element. */ 42 /** The value stored in the keyboard's input element. */
30 value: { 43 value: {
31 type: String, 44 type: String,
32 notify: true, 45 notify: true,
33 value: '', 46 value: '',
34 observer: 'onPinValueChange_' 47 observer: 'onPinValueChange_'
35 } 48 }
36 }, 49 },
37 50
38 /** Transfers focus to the input element. */ 51 /** Transfers focus to the input element. */
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 return; 98 return;
86 } 99 }
87 }, 100 },
88 101
89 /** 102 /**
90 * Changes the color of the submit button if PIN is ready. 103 * Changes the color of the submit button if PIN is ready.
91 * @param {string} value 104 * @param {string} value
92 */ 105 */
93 computeSubmitClass_: function(value) { 106 computeSubmitClass_: function(value) {
94 return value.length > 0 ? 'ready-background' : ''; 107 return value.length > 0 ? 'ready-background' : '';
108 },
109
110 /**
111 * Computes whether the input type for the pin input should be password or
112 * numerical.
113 * @private
114 */
115 computeInputType_: function(enablePassword) {
116 return enablePassword ? 'password' : 'number';
117 },
118
119 /**
120 * Computes the value of the pin input placeholder.
121 * @private
122 */
123 computeInputPlaceholder_: function(enablePassword) {
124 return enablePassword ? this.i18n('pinKeyboardPlaceholderPinPassword') :
125 this.i18n('pinKeyboardPlaceholderPin');
126 },
127
128 /**
129 * Computes the direction of the pin input.
130 * @private
131 */
132 computeInputClass_: function(password) {
133 // +password will convert a string to a number or to NaN if that's not
134 // possible. Number.isInteger will verify the value is not a NaN and that it
135 // does not contain decimals.
136 // This heuristic will fail for inputs like '1.0'.
137 //
138 // 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
140 // (just numbers), if the document direction is rtl.
141 var enableRtl = (document.dir == 'rtl') && !Number.isInteger(+password);
142 return enableRtl ? 'input-non-pin' : '';
95 } 143 }
96 }); 144 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698