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 the box experience flow (OOBE). | |
| 7 * This is the main code for the OOBE WebUI implementation. | |
| 8 */ | |
| 9 | |
| 10 const steps = ["Connect", "Eula", "Update"]; | |
| 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 * Current OOBE step, index in the steps array. | |
|
Evan Stade
2011/06/08 19:56:07
@type {number}
Nikita (slow)
2011/06/08 22:28:27
Done.
| |
| 24 */ | |
| 25 currentStep_: 0, | |
| 26 | |
| 27 /** | |
| 28 * Switches to the next OOBE step. | |
| 29 * @param {number} nextStep Index of the next step. | |
| 30 */ | |
| 31 toggleStep_: function(nextStep) { | |
| 32 var offset = nextStep - this.currentStep_; | |
| 33 var oldstep = $(steps[this.currentStep_]); | |
| 34 var oldheader = $("h" + steps[this.currentStep_]); | |
| 35 var newstep = $(steps[this.currentStep_ + offset]); | |
| 36 var newheader = $("h" + steps[this.currentStep_ + offset]); | |
| 37 | |
| 38 newstep.classList.remove("hidden"); | |
| 39 | |
| 40 if (offset == 1) { | |
| 41 oldheader.classList.add("left"); | |
| 42 oldstep.classList.add("left"); | |
| 43 newheader.classList.remove("right"); | |
| 44 newstep.classList.remove("right"); | |
| 45 } else if (offset == -1) { | |
| 46 oldheader.classList.add("right"); | |
| 47 oldstep.classList.add("right"); | |
| 48 newheader.classList.remove("left"); | |
| 49 newstep.classList.remove("left"); | |
| 50 } | |
|
Evan Stade
2011/06/08 19:56:07
fails silently for |offset| != 1. I would feel bet
Nikita (slow)
2011/06/08 22:28:27
Actually we'll need to make it work with offset li
| |
| 51 | |
| 52 // Adjust inner container height based on new step's height. | |
| 53 $("inner-container").style.height = | |
| 54 $(steps[this.currentStep_ + offset]).offsetHeight; | |
| 55 | |
| 56 setTimeout(function(){oldstep.classList.add('hidden');}, 500); | |
| 57 this.currentStep_ += offset; | |
| 58 $("oobe").className = steps[this.currentStep_]; | |
| 59 }, | |
| 60 }; | |
| 61 | |
| 62 /** | |
| 63 * Initializes the OOBE flow. This will cause all C++ handlers to | |
| 64 * be invoked to do final setup. | |
| 65 */ | |
| 66 Oobe.initialize = function() { | |
| 67 // Adjust inner container height based on first step's height | |
| 68 $("inner-container").style.height = $(steps[0]).offsetHeight; | |
|
Evan Stade
2011/06/08 19:56:07
use single quotes in js
Nikita (slow)
2011/06/08 22:28:27
Done.
| |
| 69 | |
| 70 $('continue-button').addEventListener('click', function(event) { | |
| 71 // TODO(nkostylev): Callback screen handler. | |
| 72 Oobe.toggleStep(1); | |
| 73 }); | |
| 74 $('back-button').addEventListener('click', function(event) { | |
| 75 // TODO(nkostylev): Callback screen handler. | |
| 76 Oobe.toggleStep(0); | |
| 77 }); | |
| 78 $('accept-button').addEventListener('click', function(event) { | |
| 79 // TODO(nkostylev): Callback screen handler. | |
| 80 Oobe.toggleStep(2); | |
| 81 }); | |
| 82 | |
| 83 chrome.send('screenStateInitialize'); | |
| 84 }; | |
| 85 | |
| 86 /** | |
| 87 * Switches to the next OOBE step. | |
| 88 * @param {number} nextStep Index of the next step. | |
| 89 */ | |
| 90 Oobe.toggleStep = function(nextStep) { | |
| 91 Oobe.getInstance().toggleStep_(nextStep); | |
| 92 }; | |
| 93 | |
| 94 // Export | |
| 95 return { | |
| 96 Oobe: Oobe | |
| 97 }; | |
| 98 }); | |
| 99 | |
| 100 var Oobe = cr.ui.Oobe; | |
| 101 | |
| 102 document.addEventListener('DOMContentLoaded', cr.ui.Oobe.initialize); | |
| OLD | NEW |