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

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: Fixed patch set 6 errors. 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 event.preventDefault(); 90 event.preventDefault();
78 return; 91 return;
79 } 92 }
80 93
81 // Enter pressed. 94 // Enter pressed.
82 if (event.keyCode == 13) { 95 if (event.keyCode == 13) {
83 this.firePinSubmitEvent_(); 96 this.firePinSubmitEvent_();
84 event.preventDefault(); 97 event.preventDefault();
85 return; 98 return;
86 } 99 }
100 },
101
102 /**
103 * @private
xiyuan 2016/06/30 22:54:14 nit: move this to the end of jsdoc, here and other
104 * Computes whether the input type for the pin input should be password or
105 * numerical.
106 */
107 computeInputType_: function(enablePassword) {
108 return enablePassword ? 'password' : 'number';
109 },
110
111 /**
112 * @private
113 * Computes the value of the pin input placeholder.
114 */
115 computeInputPlaceholder_: function(enablePassword) {
116 return enablePassword ? this.i18n('pinKeyboardPlaceholderPinPassword') :
117 this.i18n('pinKeyboardPlaceholderPin');
118 },
119
120 /**
121 * @private
122 * Computes the direction of the pin input.
123 */
124 computeInputClass_: function(password) {
125 // +password will convert a string to a number or to NaN if that's not
126 // possible. Number.isInteger will verify the value is not a NaN and that it
127 // does not contain decimals.
128 //
129 // This heuristic will fail for inputs like '1.0'.
130 var enableRtl = (document.dir == 'rtl') && !Number.isInteger(+password);
131 return enableRtl ? 'input-non-pin' : '';
xiyuan 2016/06/30 22:54:14 I am not quite follow. What are we trying to do he
jdufault 2016/06/30 22:58:19 The complication here is that the PIN keyboard acc
xiyuan 2016/06/30 23:09:34 emm, would the default behavior of number input wo
87 } 132 }
88 }); 133 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698