Chromium Code Reviews| 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 21 matching lines...) Expand all Loading... | |
| 32 properties: { | 32 properties: { |
| 33 /** | 33 /** |
| 34 * Whether or not the keyboard's input element should be numerical | 34 * Whether or not the keyboard's input element should be numerical |
| 35 * or password. | 35 * or password. |
| 36 */ | 36 */ |
| 37 enablePassword: { | 37 enablePassword: { |
| 38 type: Boolean, | 38 type: Boolean, |
| 39 value: false | 39 value: false |
| 40 }, | 40 }, |
| 41 | 41 |
| 42 /** | |
| 43 * Whether or not the keyboard's submit button should be shown. | |
| 44 */ | |
| 45 enableSubmitButton: { | |
| 46 type: Boolean, | |
| 47 value: false | |
| 48 }, | |
| 49 | |
| 42 /** The value stored in the keyboard's input element. */ | 50 /** The value stored in the keyboard's input element. */ |
| 43 value: { | 51 value: { |
| 44 type: String, | 52 type: String, |
| 45 notify: true, | 53 notify: true, |
| 46 value: '', | 54 value: '', |
| 47 observer: 'onPinValueChange_' | 55 observer: 'onPinValueChange_' |
| 48 } | 56 } |
| 49 }, | 57 }, |
| 50 | 58 |
| 51 /** | 59 /** |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 if (event.keyCode == 13) { | 122 if (event.keyCode == 13) { |
| 115 this.firePinSubmitEvent_(); | 123 this.firePinSubmitEvent_(); |
| 116 event.preventDefault(); | 124 event.preventDefault(); |
| 117 return; | 125 return; |
| 118 } | 126 } |
| 119 }, | 127 }, |
| 120 | 128 |
| 121 /** | 129 /** |
| 122 * Changes the color of the submit button if PIN is ready. | 130 * Changes the color of the submit button if PIN is ready. |
| 123 * @param {string} value | 131 * @param {string} value |
| 132 * @private | |
| 124 */ | 133 */ |
| 125 computeSubmitClass_: function(value) { | 134 computeSubmitClass_: function(value) { |
| 126 return value.length > 0 ? 'ready-background' : ''; | 135 return value.length > 0 ? 'ready-background' : ''; |
| 127 }, | 136 }, |
| 128 | 137 |
| 129 /** | 138 /** |
| 130 * 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 |
| 131 * numerical. | 140 * numerical. |
| 141 * @param {bool} enablePassword | |
|
jdufault
2016/07/29 19:12:13
boolean for all of these
sammiequon
2016/07/29 19:44:49
Done.
| |
| 132 * @private | 142 * @private |
| 133 */ | 143 */ |
| 134 computeInputType_: function(enablePassword) { | 144 computeInputType_: function(enablePassword) { |
| 135 return enablePassword ? 'password' : 'number'; | 145 return enablePassword ? 'password' : 'number'; |
| 136 }, | 146 }, |
| 137 | 147 |
| 138 /** | 148 /** |
| 139 * Computes the value of the pin input placeholder. | 149 * Computes the value of the pin input placeholder. |
| 150 * @param {bool} enablePassword | |
| 140 * @private | 151 * @private |
| 141 */ | 152 */ |
| 142 computeInputPlaceholder_: function(enablePassword) { | 153 computeInputPlaceholder_: function(enablePassword) { |
| 143 return enablePassword ? this.i18n('pinKeyboardPlaceholderPinPassword') : | 154 return enablePassword ? this.i18n('pinKeyboardPlaceholderPinPassword') : |
| 144 this.i18n('pinKeyboardPlaceholderPin'); | 155 this.i18n('pinKeyboardPlaceholderPin'); |
| 145 }, | 156 }, |
| 146 | 157 |
| 147 /** | 158 /** |
| 148 * Computes the direction of the pin input. | 159 * Computes the direction of the pin input. |
| 160 * @param {string} password | |
| 149 * @private | 161 * @private |
| 150 */ | 162 */ |
| 151 computeInputClass_: function(password) { | 163 computeInputClass_: function(password) { |
| 152 // +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 |
| 153 // 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 |
| 154 // does not contain decimals. | 166 // does not contain decimals. |
| 155 // This heuristic will fail for inputs like '1.0'. | 167 // This heuristic will fail for inputs like '1.0'. |
| 156 // | 168 // |
| 157 // Since we still support users entering their passwords through the PIN | 169 // Since we still support users entering their passwords through the PIN |
| 158 // 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 |
| 159 // (just numbers), if the document direction is rtl. | 171 // (just numbers), if the document direction is rtl. |
| 160 var enableRtl = (document.dir == 'rtl') && !Number.isInteger(+password); | 172 var enableRtl = (document.dir == 'rtl') && !Number.isInteger(+password); |
| 161 return enableRtl ? 'input-non-pin' : ''; | 173 return enableRtl ? 'input-non-pin' : ''; |
| 174 }, | |
| 175 | |
| 176 /** | |
| 177 * Computes if the submit button is visible. | |
| 178 * @param {bool} submitEnabled | |
| 179 * @private | |
| 180 */ | |
| 181 computeSubmitHiddenClass_: function(submitEnabled) { | |
| 182 return submitEnabled ? '' : 'submit-button-hidden'; | |
| 162 } | 183 } |
| 163 }); | 184 }); |
| OLD | NEW |