| Index: chrome/browser/resources/chromeos/oobe.js
|
| diff --git a/chrome/browser/resources/chromeos/oobe.js b/chrome/browser/resources/chromeos/oobe.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..48d292d54a7bab907c43f76f88197b9349136fe1
|
| --- /dev/null
|
| +++ b/chrome/browser/resources/chromeos/oobe.js
|
| @@ -0,0 +1,104 @@
|
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +/**
|
| + * @fileoverview Out of the box experience flow (OOBE).
|
| + * This is the main code for the OOBE WebUI implementation.
|
| + */
|
| +
|
| +const steps = ["Connect", "Eula", "Update"];
|
| +
|
| +cr.define('cr.ui', function() {
|
| +
|
| + function Oobe() {
|
| + }
|
| +
|
| + cr.addSingletonGetter(Oobe);
|
| +
|
| + Oobe.localStrings_ = new LocalStrings();
|
| +
|
| + Oobe.prototype = {
|
| + /**
|
| + * Current OOBE step, index in the steps array.
|
| + */
|
| + currentStep_: 0,
|
| +
|
| + /**
|
| + * Switches to the next OOBE step.
|
| + * @param {number} nextStep Index of the next step.
|
| + */
|
| + toggleStep_: function(nextStep) {
|
| + if (nextStep >= 0 && nextStep < steps.length) {
|
| + var offset = nextStep - this.currentStep_;
|
| + var oldstep = $(steps[this.currentStep_]);
|
| + var oldheader = $("h" + steps[this.currentStep_]);
|
| + var newstep = $(steps[this.currentStep_ + offset]);
|
| + var newheader = $("h" + steps[this.currentStep_ + offset]);
|
| +
|
| + newstep.classList.remove("hidden");
|
| +
|
| + if (offset == 1) {
|
| + oldheader.classList.add("left");
|
| + oldstep.classList.add("left");
|
| + newheader.classList.remove("right");
|
| + newstep.classList.remove("right");
|
| + } else if (offset == -1) {
|
| + oldheader.classList.add("right");
|
| + oldstep.classList.add("right");
|
| + newheader.classList.remove("left");
|
| + newstep.classList.remove("left");
|
| + }
|
| +
|
| + // Adjust inner container height based on new step's height.
|
| + $("inner-container").style.height =
|
| + $(steps[this.currentStep_ + offset]).offsetHeight;
|
| +
|
| + setTimeout(function(){oldstep.classList.add('hidden');}, 500);
|
| + this.currentStep_ += offset;
|
| + $("oobe").className = steps[this.currentStep_];
|
| + }
|
| + },
|
| + };
|
| +
|
| + /**
|
| + * Initializes the OOBE flow. This will cause all C++ handlers to
|
| + * be invoked to do final setup.
|
| + */
|
| + Oobe.initialize = function() {
|
| + // Adjust inner container height based on first step's height
|
| + $("inner-container").style.height = $(steps[0]).offsetHeight;
|
| +
|
| + $('continue-button').addEventListener('click', function(event) {
|
| + // TODO(nkostylev): Callback screen handler.
|
| + Oobe.toggleStep(1);
|
| + });
|
| + $('back-button').addEventListener('click', function(event) {
|
| + // TODO(nkostylev): Callback screen handler.
|
| + Oobe.toggleStep(0);
|
| + });
|
| + $('accept-button').addEventListener('click', function(event) {
|
| + // TODO(nkostylev): Callback screen handler.
|
| + Oobe.toggleStep(2);
|
| + });
|
| +
|
| + chrome.send('screenStateInitialize');
|
| + };
|
| +
|
| + /**
|
| + * Switches to the next OOBE step.
|
| + * @param {number} nextStep Index of the next step.
|
| + */
|
| + Oobe.toggleStep = function(nextStep) {
|
| + Oobe.getInstance().toggleStep_(nextStep);
|
| + };
|
| +
|
| + // Export
|
| + return {
|
| + Oobe: Oobe
|
| + };
|
| +});
|
| +
|
| +var Oobe = cr.ui.Oobe;
|
| +
|
| +document.addEventListener('DOMContentLoaded', cr.ui.Oobe.initialize);
|
|
|