OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 Out of the box experience flow (OOBE). | 6 * @fileoverview Out of the box experience flow (OOBE). |
7 * This is the main code for the OOBE WebUI implementation. | 7 * This is the main code for the OOBE WebUI implementation. |
8 */ | 8 */ |
9 | 9 |
10 var localStrings = new LocalStrings(); | 10 var localStrings = new LocalStrings(); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 newStep.classList.remove('faded'); | 114 newStep.classList.remove('faded'); |
115 } | 115 } |
116 | 116 |
117 // Adjust inner container height based on new step's height. | 117 // Adjust inner container height based on new step's height. |
118 $('inner-container').style.height = newStep.offsetHeight + 'px'; | 118 $('inner-container').style.height = newStep.offsetHeight + 'px'; |
119 | 119 |
120 if (this.currentStep_ != nextStepIndex) { | 120 if (this.currentStep_ != nextStepIndex) { |
121 oldStep.addEventListener('webkitTransitionEnd', function f(e) { | 121 oldStep.addEventListener('webkitTransitionEnd', function f(e) { |
122 oldStep.removeEventListener('webkitTransitionEnd', f); | 122 oldStep.removeEventListener('webkitTransitionEnd', f); |
123 oldStep.classList.add('hidden'); | 123 oldStep.classList.add('hidden'); |
124 if (nextStepIndex == 0) | |
125 Oobe.refreshNetworkControl(); | |
126 }); | 124 }); |
127 } else { | 125 } else { |
128 // First screen on OOBE launch. | 126 // First screen on OOBE launch. |
129 newHeader.classList.remove('right'); | 127 newHeader.classList.remove('right'); |
130 if (nextStepIndex == 0) { | |
131 Oobe.refreshNetworkControl(); | |
132 } | |
133 } | 128 } |
134 this.currentStep_ = nextStepIndex; | 129 this.currentStep_ = nextStepIndex; |
135 $('oobe').className = nextStepId; | 130 $('oobe').className = nextStepId; |
136 }, | 131 }, |
137 | 132 |
138 /** | 133 /** |
139 * Show screen of given screen id. | 134 * Show screen of given screen id. |
140 * @param {string} screenId Id of the screen to show. | 135 * @param {string} screenId Id of the screen to show. |
141 */ | 136 */ |
142 showScreen: function(screen) { | 137 showScreen: function(screen) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 select.appendChild(option); | 221 select.appendChild(option); |
227 } | 222 } |
228 if (callback) { | 223 if (callback) { |
229 select.addEventListener('change', function(event) { | 224 select.addEventListener('change', function(event) { |
230 chrome.send(callback, [select.options[select.selectedIndex].value]); | 225 chrome.send(callback, [select.options[select.selectedIndex].value]); |
231 }); | 226 }); |
232 } | 227 } |
233 } | 228 } |
234 | 229 |
235 /** | 230 /** |
236 * Returns offset (top, left) of the element. | |
237 * @param {!Element} element HTML element | |
238 * @return {!Object} The offset (top, left). | |
239 */ | |
240 Oobe.getOffset = function(element) { | |
xiyuan
2011/07/29 21:39:33
Don't delete this function yet. I already have cod
Nikita (slow)
2011/08/05 23:40:26
Done.
| |
241 var x = 0; | |
242 var y = 0; | |
243 while(element && !isNaN(element.offsetLeft) && !isNaN(element.offsetTop)) { | |
244 x += element.offsetLeft - element.scrollLeft; | |
245 y += element.offsetTop - element.scrollTop; | |
246 element = element.offsetParent; | |
247 } | |
248 return { top: y, left: x }; | |
249 }; | |
250 | |
251 /** | |
252 * Initializes the OOBE flow. This will cause all C++ handlers to | 231 * Initializes the OOBE flow. This will cause all C++ handlers to |
253 * be invoked to do final setup. | 232 * be invoked to do final setup. |
254 */ | 233 */ |
255 Oobe.initialize = function() { | 234 Oobe.initialize = function() { |
256 oobe.NetworkScreen.register(); | 235 oobe.NetworkScreen.register(); |
257 oobe.EulaScreen.register(); | 236 oobe.EulaScreen.register(); |
258 oobe.UpdateScreen.register(); | 237 oobe.UpdateScreen.register(); |
259 oobe.EnrollmentScreen.register(); | 238 oobe.EnrollmentScreen.register(); |
260 login.AccountPickerScreen.register(); | 239 login.AccountPickerScreen.register(); |
261 if (localStrings.getString('authType') == 'webui') | 240 if (localStrings.getString('authType') == 'webui') |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
311 | 290 |
312 /** | 291 /** |
313 * Enables/disables continue button. | 292 * Enables/disables continue button. |
314 * @param {bool} enable Should the button be enabled? | 293 * @param {bool} enable Should the button be enabled? |
315 */ | 294 */ |
316 Oobe.enableContinueButton = function(enable) { | 295 Oobe.enableContinueButton = function(enable) { |
317 $('continue-button').disabled = !enable; | 296 $('continue-button').disabled = !enable; |
318 }; | 297 }; |
319 | 298 |
320 /** | 299 /** |
321 * Refreshes position of the network control (on connect screen). | |
322 */ | |
323 Oobe.refreshNetworkControl = function() { | |
324 var controlOffset = Oobe.getOffset($('network-control')); | |
325 chrome.send('networkControlPosition', | |
326 [controlOffset.left, controlOffset.top]); | |
327 }; | |
328 | |
329 /** | |
330 * Sets usage statistics checkbox. | 300 * Sets usage statistics checkbox. |
331 * @param {bool} checked Is the checkbox checked? | 301 * @param {bool} checked Is the checkbox checked? |
332 */ | 302 */ |
333 Oobe.setUsageStats = function(checked) { | 303 Oobe.setUsageStats = function(checked) { |
334 $('usage-stats').checked = checked; | 304 $('usage-stats').checked = checked; |
335 }; | 305 }; |
336 | 306 |
337 /** | 307 /** |
338 * Set OEM EULA URL. | 308 * Set OEM EULA URL. |
339 * @param {text} oemEulaUrl OEM EULA URL. | 309 * @param {text} oemEulaUrl OEM EULA URL. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
391 // Reload global local strings, process DOM tree again. | 361 // Reload global local strings, process DOM tree again. |
392 templateData = data; | 362 templateData = data; |
393 i18nTemplate.process(document, data); | 363 i18nTemplate.process(document, data); |
394 | 364 |
395 // Update language and input method menu lists. | 365 // Update language and input method menu lists. |
396 Oobe.setupSelect($('language-select'), data.languageList, ''); | 366 Oobe.setupSelect($('language-select'), data.languageList, ''); |
397 Oobe.setupSelect($('keyboard-select'), data.inputMethodsList, ''); | 367 Oobe.setupSelect($('keyboard-select'), data.inputMethodsList, ''); |
398 | 368 |
399 // Update headers & buttons. | 369 // Update headers & buttons. |
400 Oobe.updateHeadersAndButtons(); | 370 Oobe.updateHeadersAndButtons(); |
401 | |
402 // Update the network control position. | |
403 Oobe.refreshNetworkControl(); | |
404 } | 371 } |
405 | 372 |
406 /** | 373 /** |
407 * Updates headers and buttons of the screens. | 374 * Updates headers and buttons of the screens. |
408 * Should be executed on language change. | 375 * Should be executed on language change. |
409 */ | 376 */ |
410 Oobe.updateHeadersAndButtons = function() { | 377 Oobe.updateHeadersAndButtons = function() { |
411 Oobe.getInstance().updateHeadersAndButtons_(); | 378 Oobe.getInstance().updateHeadersAndButtons_(); |
412 }; | 379 }; |
413 | 380 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
446 document.onselectstart = function(e) { | 413 document.onselectstart = function(e) { |
447 e.preventDefault(); | 414 e.preventDefault(); |
448 } | 415 } |
449 | 416 |
450 // Disable dragging. | 417 // Disable dragging. |
451 document.ondragstart = function(e) { | 418 document.ondragstart = function(e) { |
452 e.preventDefault(); | 419 e.preventDefault(); |
453 } | 420 } |
454 | 421 |
455 document.addEventListener('DOMContentLoaded', cr.ui.Oobe.initialize); | 422 document.addEventListener('DOMContentLoaded', cr.ui.Oobe.initialize); |
OLD | NEW |