Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * @fileoverview Out of box experience flow (OOBE). | |
| 7 * This is the main code for the OOBE WebUI implementation. | |
| 8 */ | |
| 9 | |
| 10 var steps = ["Connect", "Eula", "Update"]; | |
|
James Hawkins
2011/06/07 17:17:54
const?
Nikita (slow)
2011/06/07 18:02:04
Done.
| |
| 11 | |
| 12 cr.define('cr.ui', function() { | |
| 13 | |
| 14 function Oobe() { | |
| 15 } | |
| 16 | |
| 17 cr.addSingletonGetter(Oobe); | |
| 18 | |
| 19 Oobe.localStrings_ = new LocalStrings(); | |
| 20 | |
| 21 Oobe.prototype = { | |
| 22 /** | |
| 23 * Whether or not |initialize| has been called. | |
| 24 */ | |
| 25 initialized_: false, | |
|
James Hawkins
2011/06/07 17:17:54
You (seemingly) don't ever use this variable excep
Nikita (slow)
2011/06/07 18:02:04
Done.
| |
| 26 | |
| 27 /** | |
| 28 * Current OOBE step, index in the steps array. | |
| 29 */ | |
| 30 currentStep_: 0, | |
| 31 | |
| 32 /** | |
| 33 * Switches to the next OOBE step. | |
| 34 * @param {number} nextStep Index of the next step. | |
| 35 */ | |
| 36 toggleStep_: function(nextStep) { | |
| 37 if (nextStep >= 0 && nextStep < steps.length) { | |
|
James Hawkins
2011/06/07 17:17:54
In what situations would |nextStep| be < 0 or >= s
Nikita (slow)
2011/06/07 18:02:04
It shouldn't be, just a sanity check.
James Hawkins
2011/06/07 18:13:06
If the backend ever gets into a buggy state where
Nikita (slow)
2011/06/08 14:30:54
Done.
| |
| 38 var offset = nextStep - this.currentStep_; | |
| 39 var oldstep = $(steps[this.currentStep_]); | |
| 40 var oldheader = $("h" + steps[this.currentStep_]); | |
| 41 var newstep = $(steps[this.currentStep_ + offset]); | |
| 42 var newheader = $("h" + steps[this.currentStep_ + offset]); | |
| 43 | |
| 44 newstep.classList.remove("hidden"); | |
| 45 | |
| 46 if (offset == 1) { | |
| 47 oldheader.classList.add("left"); | |
| 48 oldstep.classList.add("left"); | |
| 49 newheader.classList.remove("right"); | |
| 50 newstep.classList.remove("right"); | |
| 51 } else if (offset == -1) { | |
| 52 oldheader.classList.add("right"); | |
| 53 oldstep.classList.add("right"); | |
| 54 newheader.classList.remove("left"); | |
| 55 newstep.classList.remove("left"); | |
| 56 } | |
| 57 | |
| 58 // Adjust inner container height based on new step's height. | |
| 59 $("inner-container").style.height = | |
| 60 $(steps[this.currentStep_ + offset]).offsetHeight; | |
| 61 | |
| 62 setTimeout(function(){oldstep.classList.add('hidden');}, 500); | |
|
James Hawkins
2011/06/07 17:17:54
Is this animated via CSS?
Nikita (slow)
2011/06/07 18:02:04
Yes:
.header-section {
-webkit-transition: all .
| |
| 63 this.currentStep_ += offset; | |
| 64 $("oobe").className = steps[this.currentStep_]; | |
| 65 } | |
| 66 }, | |
| 67 }; | |
| 68 | |
| 69 /** | |
| 70 * Initializes the OOBE flow. This will cause all C++ handlers to | |
| 71 * be invoked to do final setup. | |
| 72 */ | |
| 73 Oobe.initialize = function() { | |
| 74 this.initialized_ = true; | |
| 75 | |
| 76 // Adjust inner container height based on first step's height | |
| 77 $("inner-container").style.height = $(steps[0]).offsetHeight; | |
| 78 | |
| 79 $('continue-button').addEventListener('click', function(event) { | |
| 80 // TODO(nkostylev): Callback screen handler. | |
| 81 Oobe.toggleStep(1); | |
| 82 }); | |
| 83 $('back-button').addEventListener('click', function(event) { | |
| 84 // TODO(nkostylev): Callback screen handler. | |
| 85 Oobe.toggleStep(0); | |
| 86 }); | |
| 87 $('accept-button').addEventListener('click', function(event) { | |
| 88 // TODO(nkostylev): Callback screen handler. | |
| 89 Oobe.toggleStep(2); | |
| 90 }); | |
| 91 | |
| 92 chrome.send('screenStateInitialize'); | |
| 93 }; | |
| 94 | |
| 95 /** | |
| 96 * Switches to the next OOBE step. | |
| 97 * @param {number} nextStep Index of the next step. | |
| 98 */ | |
| 99 Oobe.toggleStep = function(nextStep) { | |
| 100 Oobe.getInstance().toggleStep_(nextStep); | |
| 101 }; | |
| 102 | |
| 103 // Export | |
| 104 return { | |
| 105 Oobe: Oobe | |
| 106 }; | |
| 107 }); | |
| 108 | |
| 109 var Oobe = cr.ui.Oobe; | |
| 110 | |
| 111 document.addEventListener('DOMContentLoaded', cr.ui.Oobe.initialize); | |
| OLD | NEW |