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 * 'settings-setup-pin-dialog' is the settings page for choosing a PIN. | 7 * 'settings-setup-pin-dialog' is the settings page for choosing a PIN. |
| 8 * | 8 * |
| 9 * Example: | 9 * Example: |
| 10 * | 10 * |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 */ | 37 */ |
| 38 pinKeyboardValue_: String, | 38 pinKeyboardValue_: String, |
| 39 | 39 |
| 40 /** | 40 /** |
| 41 * Stores the initial PIN value so it can be confirmed. | 41 * Stores the initial PIN value so it can be confirmed. |
| 42 * @private | 42 * @private |
| 43 */ | 43 */ |
| 44 initialPin_: String, | 44 initialPin_: String, |
| 45 | 45 |
| 46 /** | 46 /** |
| 47 * The actual problem message to display. | |
| 48 * @private | |
| 49 */ | |
| 50 problemMessage_: String, | |
| 51 | |
| 52 /** | |
| 53 * The type of problem class to show (warning or error). | |
| 54 */ | |
| 55 problemClass_: String, | |
| 56 | |
| 57 /** | |
| 58 * Should the step-specific submit button be displayed? | 47 * Should the step-specific submit button be displayed? |
| 59 * @private | 48 * @private |
| 60 */ | 49 */ |
| 61 enableSubmit_: Boolean, | 50 enableSubmit_: Boolean, |
| 62 | 51 |
| 63 /** | 52 /** |
| 64 * The current step/subpage we are on. | 53 * The current step/subpage we are on. |
| 65 * @private | 54 * @private |
| 66 */ | 55 */ |
| 67 isConfirmStep_: { | 56 isConfirmStep_: { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 81 }, | 70 }, |
| 82 | 71 |
| 83 close: function() { | 72 close: function() { |
| 84 if (this.$.dialog.open) | 73 if (this.$.dialog.open) |
| 85 this.$.dialog.close(); | 74 this.$.dialog.close(); |
| 86 | 75 |
| 87 this.resetState_(); | 76 this.resetState_(); |
| 88 }, | 77 }, |
| 89 | 78 |
| 90 /** | 79 /** |
| 80 * Gets the pin keyboard element. | |
| 81 * @type {!HTMLDivElement} | |
| 82 */ | |
| 83 get pinKeyboard() { | |
| 84 return this.$$('#pinKeyboard'); | |
| 85 }, | |
| 86 | |
| 87 /** | |
| 91 * Resets the element to the initial state. | 88 * Resets the element to the initial state. |
| 92 * @private | 89 * @private |
| 93 */ | 90 */ |
| 94 resetState_: function() { | 91 resetState_: function() { |
| 95 this.initialPin_ = ''; | 92 this.initialPin_ = ''; |
| 96 this.pinKeyboardValue_ = ''; | 93 this.pinKeyboardValue_ = ''; |
| 97 this.enableSubmit_ = false; | 94 this.enableSubmit_ = false; |
| 98 this.isConfirmStep_ = false; | 95 this.isConfirmStep_ = false; |
| 99 this.onPinChange_(); | 96 this.onPinChange_(); |
| 100 }, | 97 }, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 this.initialPin_ == this.pinKeyboardValue_; | 147 this.initialPin_ == this.pinKeyboardValue_; |
| 151 }, | 148 }, |
| 152 | 149 |
| 153 /** | 150 /** |
| 154 * Notify the user about a problem. | 151 * Notify the user about a problem. |
| 155 * @private | 152 * @private |
| 156 * @param {string} messageId | 153 * @param {string} messageId |
| 157 * @param {string} problemClass | 154 * @param {string} problemClass |
| 158 */ | 155 */ |
| 159 showProblem_: function(messageId, problemClass) { | 156 showProblem_: function(messageId, problemClass) { |
| 160 this.problemMessage_ = this.i18n(messageId); | 157 this.pinKeyboard.setProblem(this.i18n(messageId), true /*isError*/); |
|
jdufault
2016/08/24 01:20:18
Refactor the callers of showProblem_ to also use t
sammiequon
2016/08/25 23:50:02
No more problem message.
| |
| 161 this.problemClass_ = problemClass; | |
| 162 this.updateStyles(); | 158 this.updateStyles(); |
| 163 }, | 159 }, |
| 164 | 160 |
| 165 /** @private */ | 161 /** @private */ |
| 166 hideProblem_: function() { | 162 hideProblem_: function() { |
| 167 this.problemMessage_ = ''; | 163 this.pinKeyboard.setProblem('', true /*isError*/); |
|
jdufault
2016/08/24 01:20:18
Add a clearProblem method?
sammiequon
2016/08/25 23:50:02
No more problem message.
| |
| 168 this.problemClass_ = ''; | |
| 169 }, | 164 }, |
| 170 | 165 |
| 171 /** @private */ | 166 /** @private */ |
| 172 onPinChange_: function() { | 167 onPinChange_: function() { |
| 173 if (!this.isConfirmStep_) { | 168 if (!this.isConfirmStep_) { |
| 174 var isPinLongEnough = this.isPinLongEnough_(this.pinKeyboardValue_); | 169 var isPinLongEnough = this.isPinLongEnough_(this.pinKeyboardValue_); |
| 175 var isWeak = isPinLongEnough && this.isPinWeak_(this.pinKeyboardValue_); | 170 var isWeak = isPinLongEnough && this.isPinWeak_(this.pinKeyboardValue_); |
| 176 | 171 |
| 177 if (!isPinLongEnough && this.pinKeyboardValue_) | 172 if (!isPinLongEnough && this.pinKeyboardValue_) |
| 178 this.showProblem_('configurePinTooShort', 'error'); | 173 this.showProblem_('configurePinTooShort', 'error'); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 * @private | 246 * @private |
| 252 * @param {boolean} isConfirmStep | 247 * @param {boolean} isConfirmStep |
| 253 * @return {string} | 248 * @return {string} |
| 254 */ | 249 */ |
| 255 getContinueMessage_: function(isConfirmStep) { | 250 getContinueMessage_: function(isConfirmStep) { |
| 256 return this.i18n(isConfirmStep ? 'confirm' : 'configurePinContinueButton'); | 251 return this.i18n(isConfirmStep ? 'confirm' : 'configurePinContinueButton'); |
| 257 }, | 252 }, |
| 258 }); | 253 }); |
| 259 | 254 |
| 260 })(); | 255 })(); |
| OLD | NEW |