Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 Display manager for WebUI OOBE and login. | 6 * @fileoverview Display manager for WebUI OOBE and login. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 // TODO(xiyuan): Find a better to share those constants. | 9 // TODO(xiyuan): Find a better to share those constants. |
| 10 /** @const */ var SCREEN_OOBE_NETWORK = 'connect'; | 10 /** @const */ var SCREEN_OOBE_NETWORK = 'connect'; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 } else if (name == ACCELERATOR_RESET) { | 121 } else if (name == ACCELERATOR_RESET) { |
| 122 var currentStepId = this.screens_[this.currentStep_]; | 122 var currentStepId = this.screens_[this.currentStep_]; |
| 123 if (currentStepId == SCREEN_GAIA_SIGNIN || | 123 if (currentStepId == SCREEN_GAIA_SIGNIN || |
| 124 currentStepId == SCREEN_ACCOUNT_PICKER) { | 124 currentStepId == SCREEN_ACCOUNT_PICKER) { |
| 125 chrome.send('toggleResetScreen'); | 125 chrome.send('toggleResetScreen'); |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 }, | 128 }, |
| 129 | 129 |
| 130 /** | 130 /** |
| 131 * Sets focus on a button with the autofocus attribute in the current | |
| 132 * screen. | |
| 133 */ | |
| 134 restoreFocus: function() { | |
| 135 this.updateFocus_($(this.screens_[this.currentStep_])); | |
| 136 }, | |
| 137 | |
| 138 /** | |
| 131 * Appends buttons to the button strip. | 139 * Appends buttons to the button strip. |
| 132 * @param {Array.<HTMLElement>} buttons Array with the buttons to append. | 140 * @param {Array.<HTMLElement>} buttons Array with the buttons to append. |
| 133 * @param {string} screenId Id of the screen that buttons belong to. | 141 * @param {string} screenId Id of the screen that buttons belong to. |
| 134 */ | 142 */ |
| 135 appendButtons_: function(buttons, screenId) { | 143 appendButtons_: function(buttons, screenId) { |
| 136 if (buttons) { | 144 if (buttons) { |
| 137 var buttonStrip = null; | 145 var buttonStrip = null; |
| 138 if (this.isNewOobe()) | 146 if (this.isNewOobe()) |
| 139 buttonStrip = $(screenId + '-controls'); | 147 buttonStrip = $(screenId + '-controls'); |
| 140 else | 148 else |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 153 */ | 161 */ |
| 154 disableButtons_: function(screen, disabled) { | 162 disableButtons_: function(screen, disabled) { |
| 155 var buttons = document.querySelectorAll( | 163 var buttons = document.querySelectorAll( |
| 156 '#' + screen.id + '-controls button'); | 164 '#' + screen.id + '-controls button'); |
| 157 for (var i = 0; i < buttons.length; ++i) { | 165 for (var i = 0; i < buttons.length; ++i) { |
| 158 buttons[i].disabled = disabled; | 166 buttons[i].disabled = disabled; |
| 159 } | 167 } |
| 160 }, | 168 }, |
| 161 | 169 |
| 162 /** | 170 /** |
| 171 * Sets focus on a button with the autofocus attribute. | |
| 172 * @param {HTMLElement} screen Screen which controls should be affected. | |
| 173 */ | |
| 174 updateFocus_: function(screen) { | |
| 175 var buttons = document.querySelectorAll( | |
|
Nikita (slow)
2012/11/28 18:26:26
I think this should be implemented differently.
Y
mtomasz
2012/11/28 21:57:42
Isn't screen.buttons getter producing new buttons
Nikita (slow)
2012/11/29 16:08:11
You're right, screen.buttons always creates new el
| |
| 176 '#' + screen.id + '-controls button'); | |
| 177 for (var i = 0; i < buttons.length; ++i) { | |
| 178 if (buttons[i].autofocus) | |
| 179 buttons[i].focus(); | |
|
Nikita (slow)
2012/11/28 18:26:26
break;
mtomasz
2012/11/28 21:57:42
Done.
| |
| 180 } | |
| 181 }, | |
| 182 | |
| 183 /** | |
| 163 * Updates a step's css classes to reflect left, current, or right position. | 184 * Updates a step's css classes to reflect left, current, or right position. |
| 164 * @param {number} stepIndex step index. | 185 * @param {number} stepIndex step index. |
| 165 * @param {string} state one of 'left', 'current', 'right'. | 186 * @param {string} state one of 'left', 'current', 'right'. |
| 166 */ | 187 */ |
| 167 updateStep_: function(stepIndex, state) { | 188 updateStep_: function(stepIndex, state) { |
| 168 var stepId = this.screens_[stepIndex]; | 189 var stepId = this.screens_[stepIndex]; |
| 169 var step = $(stepId); | 190 var step = $(stepId); |
| 170 var header = $('header-' + stepId); | 191 var header = $('header-' + stepId); |
| 171 var states = ['left', 'right', 'current']; | 192 var states = ['left', 'right', 'current']; |
| 172 for (var i = 0; i < states.length; ++i) { | 193 for (var i = 0; i < states.length; ++i) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 !oldStep.classList.contains('hidden')) { | 252 !oldStep.classList.contains('hidden')) { |
| 232 if (oldStep.classList.contains('animated') || !this.isNewOobe()) { | 253 if (oldStep.classList.contains('animated') || !this.isNewOobe()) { |
| 233 innerContainer.classList.add('animation'); | 254 innerContainer.classList.add('animation'); |
| 234 oldStep.addEventListener('webkitTransitionEnd', function f(e) { | 255 oldStep.addEventListener('webkitTransitionEnd', function f(e) { |
| 235 oldStep.removeEventListener('webkitTransitionEnd', f); | 256 oldStep.removeEventListener('webkitTransitionEnd', f); |
| 236 if (oldStep.classList.contains('faded') || | 257 if (oldStep.classList.contains('faded') || |
| 237 oldStep.classList.contains('left') || | 258 oldStep.classList.contains('left') || |
| 238 oldStep.classList.contains('right')) { | 259 oldStep.classList.contains('right')) { |
| 239 innerContainer.classList.remove('animation'); | 260 innerContainer.classList.remove('animation'); |
| 240 oldStep.classList.add('hidden'); | 261 oldStep.classList.add('hidden'); |
| 262 this.updateFocus_(newStep); | |
| 241 } | 263 } |
| 242 }); | 264 }.bind(this)); |
|
Nikita (slow)
2012/11/28 18:26:26
Have you tested how OOBE works with this change?
mtomasz
2012/11/28 21:57:42
Yes, tested locally.
| |
| 243 } else { | 265 } else { |
| 244 oldStep.classList.add('hidden'); | 266 oldStep.classList.add('hidden'); |
| 267 this.updateFocus_(newStep); | |
| 245 } | 268 } |
| 246 } else { | 269 } else { |
| 247 // First screen on OOBE launch. | 270 // First screen on OOBE launch. |
| 248 if (innerContainer.classList.contains('down')) { | 271 if (innerContainer.classList.contains('down')) { |
| 249 innerContainer.classList.remove('down'); | 272 innerContainer.classList.remove('down'); |
| 250 innerContainer.addEventListener( | 273 innerContainer.addEventListener( |
| 251 'webkitTransitionEnd', function f(e) { | 274 'webkitTransitionEnd', function f(e) { |
| 252 innerContainer.removeEventListener('webkitTransitionEnd', f); | 275 innerContainer.removeEventListener('webkitTransitionEnd', f); |
| 253 $('progress-dots').classList.remove('down'); | 276 $('progress-dots').classList.remove('down'); |
| 254 chrome.send('loginVisible', ['oobe']); | 277 chrome.send('loginVisible', ['oobe']); |
| 255 }); | 278 this.updateFocus_(newStep); |
| 279 }.bind(this)); | |
| 280 } else { | |
| 281 this.updateFocus_(newStep); | |
| 256 } | 282 } |
| 257 newHeader.classList.remove('right'); // Old OOBE. | 283 newHeader.classList.remove('right'); // Old OOBE. |
| 258 } | 284 } |
| 259 this.currentStep_ = nextStepIndex; | 285 this.currentStep_ = nextStepIndex; |
| 260 $('oobe').className = nextStepId; | 286 $('oobe').className = nextStepId; |
| 261 | 287 |
| 262 $('step-logo').hidden = newStep.classList.contains('no-logo'); | 288 $('step-logo').hidden = newStep.classList.contains('no-logo'); |
| 263 | 289 |
| 264 chrome.send('updateCurrentScreen', [this.currentScreen.id]); | 290 chrome.send('updateCurrentScreen', [this.currentScreen.id]); |
| 265 }, | 291 }, |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 602 $('add-user-button').classList.add('button-restricted'); | 628 $('add-user-button').classList.add('button-restricted'); |
| 603 $('add-user-button').title = disable ? | 629 $('add-user-button').title = disable ? |
| 604 localStrings.getString('disabledAddUserTooltip') : ''; | 630 localStrings.getString('disabledAddUserTooltip') : ''; |
| 605 } | 631 } |
| 606 | 632 |
| 607 // Export | 633 // Export |
| 608 return { | 634 return { |
| 609 DisplayManager: DisplayManager | 635 DisplayManager: DisplayManager |
| 610 }; | 636 }; |
| 611 }); | 637 }); |
| OLD | NEW |