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'; |
11 /** @const */ var SCREEN_OOBE_EULA = 'eula'; | 11 /** @const */ var SCREEN_OOBE_EULA = 'eula'; |
12 /** @const */ var SCREEN_OOBE_UPDATE = 'update'; | |
12 /** @const */ var SCREEN_OOBE_ENROLLMENT = 'oauth-enrollment'; | 13 /** @const */ var SCREEN_OOBE_ENROLLMENT = 'oauth-enrollment'; |
13 /** @const */ var SCREEN_GAIA_SIGNIN = 'gaia-signin'; | 14 /** @const */ var SCREEN_GAIA_SIGNIN = 'gaia-signin'; |
14 /** @const */ var SCREEN_ACCOUNT_PICKER = 'account-picker'; | 15 /** @const */ var SCREEN_ACCOUNT_PICKER = 'account-picker'; |
15 | 16 |
16 /* Accelerator identifiers. Must be kept in sync with webui_login_view.cc. */ | 17 /* Accelerator identifiers. Must be kept in sync with webui_login_view.cc. */ |
17 /** @const */ var ACCELERATOR_CANCEL = 'cancel'; | 18 /** @const */ var ACCELERATOR_CANCEL = 'cancel'; |
18 /** @const */ var ACCELERATOR_ENROLLMENT = 'enrollment'; | 19 /** @const */ var ACCELERATOR_ENROLLMENT = 'enrollment'; |
19 /** @const */ var ACCELERATOR_VERSION = 'version'; | 20 /** @const */ var ACCELERATOR_VERSION = 'version'; |
20 | 21 |
21 /* Help topic identifiers. */ | 22 /* Help topic identifiers. */ |
22 /** @const */ var HELP_TOPIC_ENTERPRISE_REPORTING = 2535613; | 23 /** @const */ var HELP_TOPIC_ENTERPRISE_REPORTING = 2535613; |
23 | 24 |
24 cr.define('cr.ui.login', function() { | 25 cr.define('cr.ui.login', function() { |
25 var Bubble = cr.ui.Bubble; | 26 var Bubble = cr.ui.Bubble; |
26 | 27 |
27 /** | 28 /** |
29 * Groups of screens (screen IDs) that should have the same dimensions. | |
30 * @type Array.<Array.<string>> | |
31 * @const | |
32 */ | |
33 var SCREEN_GROUPS = [[SCREEN_OOBE_NETWORK, | |
34 SCREEN_OOBE_EULA, | |
35 SCREEN_OOBE_UPDATE] | |
36 ]; | |
37 | |
38 /** | |
28 * Constructor a display manager that manages initialization of screens, | 39 * Constructor a display manager that manages initialization of screens, |
29 * transitions, error messages display. | 40 * transitions, error messages display. |
30 * | 41 * |
31 * @constructor | 42 * @constructor |
32 */ | 43 */ |
33 function DisplayManager() { | 44 function DisplayManager() { |
34 } | 45 } |
35 | 46 |
36 DisplayManager.prototype = { | 47 DisplayManager.prototype = { |
37 /** | 48 /** |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 this.currentScreen.cancelAutoEnrollment(); | 113 this.currentScreen.cancelAutoEnrollment(); |
103 } | 114 } |
104 } else if (name == ACCELERATOR_VERSION) { | 115 } else if (name == ACCELERATOR_VERSION) { |
105 if (this.allowToggleVersion_) | 116 if (this.allowToggleVersion_) |
106 $('version-labels').hidden = !$('version-labels').hidden; | 117 $('version-labels').hidden = !$('version-labels').hidden; |
107 } | 118 } |
108 }, | 119 }, |
109 | 120 |
110 /** | 121 /** |
111 * Appends buttons to the button strip. | 122 * Appends buttons to the button strip. |
112 * @param {Array} buttons Array with the buttons to append. | 123 * @param {Array.<HTMLElement>} buttons Array with the buttons to append. |
113 * @param {string} screenId Id of the screen that buttons belong to. | 124 * @param {string} screenId Id of the screen that buttons belong to. |
114 */ | 125 */ |
115 appendButtons_: function(buttons, screenId) { | 126 appendButtons_: function(buttons, screenId) { |
116 if (buttons) { | 127 if (buttons) { |
117 var buttonStrip = null; | 128 var buttonStrip = null; |
118 if (this.isNewOobe()) | 129 if (this.isNewOobe()) |
119 buttonStrip = $(screenId + '-controls'); | 130 buttonStrip = $(screenId + '-controls'); |
120 else | 131 else |
121 buttonStrip = $('button-strip'); | 132 buttonStrip = $('button-strip'); |
122 if (buttonStrip) { | 133 if (buttonStrip) { |
123 for (var i = 0; i < buttons.length; ++i) | 134 for (var i = 0; i < buttons.length; ++i) |
124 buttonStrip.appendChild(buttons[i]); | 135 buttonStrip.appendChild(buttons[i]); |
125 } | 136 } |
126 } | 137 } |
127 }, | 138 }, |
128 | 139 |
129 /** | 140 /** |
141 * Disables or enables control buttons on the specified screen. | |
142 * @param {HTMLElement} screen Screen which controls should be affected. | |
143 * @param {boolean} disabled Whether to disable controls. | |
144 */ | |
145 disableButtons_: function(screen, disabled) { | |
146 var buttons = document.querySelectorAll( | |
147 '#' + screen.id + '-controls button'); | |
148 for (var i = 0; i < buttons.length; ++i) { | |
149 buttons[i].disabled = disabled; | |
150 } | |
151 }, | |
152 | |
153 /** | |
130 * Updates a step's css classes to reflect left, current, or right position. | 154 * Updates a step's css classes to reflect left, current, or right position. |
131 * @param {number} stepIndex step index. | 155 * @param {number} stepIndex step index. |
132 * @param {string} state one of 'left', 'current', 'right'. | 156 * @param {string} state one of 'left', 'current', 'right'. |
133 */ | 157 */ |
134 updateStep_: function(stepIndex, state) { | 158 updateStep_: function(stepIndex, state) { |
135 var stepId = this.screens_[stepIndex]; | 159 var stepId = this.screens_[stepIndex]; |
136 var step = $(stepId); | 160 var step = $(stepId); |
137 var header = $('header-' + stepId); | 161 var header = $('header-' + stepId); |
138 var states = ['left', 'right', 'current']; | 162 var states = ['left', 'right', 'current']; |
139 for (var i = 0; i < states.length; ++i) { | 163 for (var i = 0; i < states.length; ++i) { |
(...skipping 10 matching lines...) Expand all Loading... | |
150 * Switches to the next OOBE step. | 174 * Switches to the next OOBE step. |
151 * @param {number} nextStepIndex Index of the next step. | 175 * @param {number} nextStepIndex Index of the next step. |
152 */ | 176 */ |
153 toggleStep_: function(nextStepIndex, screenData) { | 177 toggleStep_: function(nextStepIndex, screenData) { |
154 var currentStepId = this.screens_[this.currentStep_]; | 178 var currentStepId = this.screens_[this.currentStep_]; |
155 var nextStepId = this.screens_[nextStepIndex]; | 179 var nextStepId = this.screens_[nextStepIndex]; |
156 var oldStep = $(currentStepId); | 180 var oldStep = $(currentStepId); |
157 var newStep = $(nextStepId); | 181 var newStep = $(nextStepId); |
158 var newHeader = $('header-' + nextStepId); | 182 var newHeader = $('header-' + nextStepId); |
159 | 183 |
184 // Disable controls before starting animation. | |
185 this.disableButtons_(oldStep, true); | |
186 | |
160 if (oldStep.onBeforeHide) | 187 if (oldStep.onBeforeHide) |
161 oldStep.onBeforeHide(); | 188 oldStep.onBeforeHide(); |
162 | 189 |
163 if (newStep.onBeforeShow) | 190 if (newStep.onBeforeShow) |
164 newStep.onBeforeShow(screenData); | 191 newStep.onBeforeShow(screenData); |
165 | 192 |
166 newStep.classList.remove('hidden'); | 193 newStep.classList.remove('hidden'); |
167 | 194 |
168 if (newStep.onAfterShow) | 195 if (newStep.onAfterShow) |
169 newStep.onAfterShow(screenData); | 196 newStep.onAfterShow(screenData); |
170 | 197 |
198 this.disableButtons_(newStep, false); | |
199 | |
171 if (this.isOobeUI()) { | 200 if (this.isOobeUI()) { |
172 // Start gliding animation for OOBE steps. | 201 // Start gliding animation for OOBE steps. |
173 if (nextStepIndex > this.currentStep_) { | 202 if (nextStepIndex > this.currentStep_) { |
174 for (var i = this.currentStep_; i < nextStepIndex; ++i) | 203 for (var i = this.currentStep_; i < nextStepIndex; ++i) |
175 this.updateStep_(i, 'left'); | 204 this.updateStep_(i, 'left'); |
176 this.updateStep_(nextStepIndex, 'current'); | 205 this.updateStep_(nextStepIndex, 'current'); |
177 } else if (nextStepIndex < this.currentStep_) { | 206 } else if (nextStepIndex < this.currentStep_) { |
178 for (var i = this.currentStep_; i > nextStepIndex; --i) | 207 for (var i = this.currentStep_; i > nextStepIndex; --i) |
179 this.updateStep_(i, 'right'); | 208 this.updateStep_(i, 'right'); |
180 this.updateStep_(nextStepIndex, 'current'); | 209 this.updateStep_(nextStepIndex, 'current'); |
181 } | 210 } |
182 } else { | 211 } else { |
183 // Start fading animation for login display. | 212 // Start fading animation for login display. |
184 oldStep.classList.add('faded'); | 213 oldStep.classList.add('faded'); |
185 newStep.classList.remove('faded'); | 214 newStep.classList.remove('faded'); |
186 } | 215 } |
187 | 216 |
188 // Adjust inner container height based on new step's height. | 217 // Adjust inner container height based on new step's height. |
189 this.updateInnerContainerSize_(newStep); | 218 this.updateInnerContainerSize_(newStep); |
190 | 219 |
191 if (this.currentStep_ != nextStepIndex && | 220 if (this.currentStep_ != nextStepIndex && |
192 !oldStep.classList.contains('hidden')) { | 221 !oldStep.classList.contains('hidden')) { |
193 // TODO(nkostylev): Remove when new transitions are added back. | 222 if (oldStep.classList.contains('animated') || !this.isNewOobe()) { |
194 if (this.isNewOobe()) { | 223 oldStep.classList.add('animation'); |
195 if (oldStep.classList.contains('faded') || | |
196 oldStep.classList.contains('left') || | |
197 oldStep.classList.contains('right')) { | |
198 oldStep.classList.add('hidden'); | |
199 } | |
200 } else { | |
201 oldStep.addEventListener('webkitTransitionEnd', function f(e) { | 224 oldStep.addEventListener('webkitTransitionEnd', function f(e) { |
202 oldStep.removeEventListener('webkitTransitionEnd', f); | 225 oldStep.removeEventListener('webkitTransitionEnd', f); |
203 if (oldStep.classList.contains('faded') || | 226 if (oldStep.classList.contains('faded') || |
204 oldStep.classList.contains('left') || | 227 oldStep.classList.contains('left') || |
205 oldStep.classList.contains('right')) { | 228 oldStep.classList.contains('right')) { |
229 oldStep.classList.remove('animation'); | |
206 oldStep.classList.add('hidden'); | 230 oldStep.classList.add('hidden'); |
207 } | 231 } |
208 }); | 232 }); |
233 } else { | |
234 oldStep.classList.add('hidden'); | |
209 } | 235 } |
210 } else { | 236 } else { |
211 // First screen on OOBE launch. | 237 // First screen on OOBE launch. |
238 // $('outer-container').hidden = false; | |
Nikita (slow)
2012/08/10 10:21:35
Is this commented code needed?
Ivan Korotkov
2012/08/10 13:25:16
Removed.
| |
239 $('inner-container').classList.remove('down'); | |
Nikita (slow)
2012/08/10 10:21:35
This won't affect boot into user pods or boot into
Ivan Korotkov
2012/08/10 13:25:16
Right, because login.html doesn't have 'down' alre
| |
240 console.error('Down'); | |
Nikita (slow)
2012/08/10 10:21:35
Cleanup.
Ivan Korotkov
2012/08/10 13:25:16
Done.
| |
212 newHeader.classList.remove('right'); | 241 newHeader.classList.remove('right'); |
213 // Report back first OOBE screen being painted. | 242 // Report back first OOBE screen being painted. |
214 window.webkitRequestAnimationFrame(function() { | 243 window.webkitRequestAnimationFrame(function() { |
215 chrome.send('loginVisible'); | 244 chrome.send('loginVisible'); |
216 }); | 245 }); |
217 } | 246 } |
218 this.currentStep_ = nextStepIndex; | 247 this.currentStep_ = nextStepIndex; |
219 $('oobe').className = nextStepId; | 248 $('oobe').className = nextStepId; |
249 | |
250 $('step-logo').hidden = newStep.classList.contains('no-logo'); | |
220 }, | 251 }, |
221 | 252 |
222 /** | 253 /** |
223 * Show screen of given screen id. | 254 * Show screen of given screen id. |
224 * @param {Object} screen Screen params dict, | 255 * @param {Object} screen Screen params dict, |
225 * e.g. {id: screenId, data: data}. | 256 * e.g. {id: screenId, data: data}. |
226 */ | 257 */ |
227 showScreen: function(screen) { | 258 showScreen: function(screen) { |
228 var screenId = screen.id; | 259 var screenId = screen.id; |
229 | 260 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 | 307 |
277 if (this.isNewOobe()) | 308 if (this.isNewOobe()) |
278 $('progress-dots').appendChild(dot); | 309 $('progress-dots').appendChild(dot); |
279 else | 310 else |
280 $('progress').appendChild(dot); | 311 $('progress').appendChild(dot); |
281 | 312 |
282 this.appendButtons_(el.buttons, screenId); | 313 this.appendButtons_(el.buttons, screenId); |
283 }, | 314 }, |
284 | 315 |
285 /** | 316 /** |
286 * Updates inner container size based on the size of the current screen. | 317 * Updates inner container size based on the size of the current screen and |
318 * other screens in the same group. | |
287 * Should be executed on screen change / screen size change. | 319 * Should be executed on screen change / screen size change. |
288 * @param {!HTMLElement} screen Screen that is being shown. | 320 * @param {!HTMLElement} screen Screen that is being shown. |
289 */ | 321 */ |
290 updateInnerContainerSize_: function(screen) { | 322 updateInnerContainerSize_: function(screen) { |
291 $('inner-container').style.height = screen.offsetHeight + 'px'; | 323 var height = screen.offsetHeight; |
292 if (this.isNewOobe()) | 324 var width = screen.offsetWidth; |
293 $('inner-container').style.width = screen.offsetWidth + 'px'; | 325 for (var i = 0, screenGroup; screenGroup = SCREEN_GROUPS[i]; i++) { |
326 if (screenGroup.indexOf(screen.id) != -1) { | |
327 // Set screen dimensions to maximum dimensions within this group. | |
328 for (var j = 0, screen2; screen2 = $(screenGroup[j]); j++) { | |
329 height = Math.max(height, screen2.offsetHeight); | |
330 width = Math.max(width, screen2.offsetWidth); | |
331 } | |
332 break; | |
333 } | |
334 } | |
335 $('inner-container').style.height = height + 'px'; | |
336 if (this.isNewOobe()) { | |
337 $('inner-container').style.width = width + 'px'; | |
338 // This requires |screen| to have |box-sizing: border-box|. | |
339 screen.style.width = width + 'px'; | |
340 screen.style.height = height + 'px'; | |
341 } | |
294 }, | 342 }, |
295 | 343 |
296 /** | 344 /** |
297 * Updates localized content of the screens like headers, buttons and links. | 345 * Updates localized content of the screens like headers, buttons and links. |
298 * Should be executed on language change. | 346 * Should be executed on language change. |
299 */ | 347 */ |
300 updateLocalizedContent_: function() { | 348 updateLocalizedContent_: function() { |
301 if (!this.isNewOobe()) | 349 if (!this.isNewOobe()) |
302 $('button-strip').innerHTML = ''; | 350 $('button-strip').innerHTML = ''; |
303 for (var i = 0, screenId; screenId = this.screens_[i]; ++i) { | 351 for (var i = 0, screenId; screenId = this.screens_[i]; ++i) { |
304 var screen = $(screenId); | 352 var screen = $(screenId); |
305 if (this.isNewOobe()) { | 353 if (this.isNewOobe()) { |
306 buttonStrip = $(screenId + '-controls'); | 354 var buttonStrip = $(screenId + '-controls'); |
307 if (buttonStrip) | 355 if (buttonStrip) |
308 buttonStrip.innerHTML = ''; | 356 buttonStrip.innerHTML = ''; |
309 // TODO(nkostylev): Update screen headers for new OOBE design. | 357 // TODO(nkostylev): Update screen headers for new OOBE design. |
310 } else { | 358 } else { |
311 $('header-' + screenId).textContent = screen.header; | 359 $('header-' + screenId).textContent = screen.header; |
312 } | 360 } |
313 this.appendButtons_(screen.buttons, screenId); | 361 this.appendButtons_(screen.buttons, screenId); |
314 if (screen.updateLocalizedContent) | 362 if (screen.updateLocalizedContent) |
315 screen.updateLocalizedContent(); | 363 screen.updateLocalizedContent(); |
316 } | 364 } |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
498 }); | 546 }); |
499 } | 547 } |
500 } | 548 } |
501 }; | 549 }; |
502 | 550 |
503 // Export | 551 // Export |
504 return { | 552 return { |
505 DisplayManager: DisplayManager | 553 DisplayManager: DisplayManager |
506 }; | 554 }; |
507 }); | 555 }); |
OLD | NEW |