Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Side by Side Diff: chrome/browser/resources/chromeos/oobe.js

Issue 7058048: [cros] Layout for OOBE WebUI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: iterate Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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.
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 if (nextStep >= 0 && nextStep < steps.length) {
33 var offset = nextStep - this.currentStep_;
34 var oldstep = $(steps[this.currentStep_]);
35 var oldheader = $("h" + steps[this.currentStep_]);
36 var newstep = $(steps[this.currentStep_ + offset]);
37 var newheader = $("h" + steps[this.currentStep_ + offset]);
38
39 newstep.classList.remove("hidden");
40
41 if (offset == 1) {
42 oldheader.classList.add("left");
43 oldstep.classList.add("left");
44 newheader.classList.remove("right");
45 newstep.classList.remove("right");
46 } else if (offset == -1) {
47 oldheader.classList.add("right");
48 oldstep.classList.add("right");
49 newheader.classList.remove("left");
50 newstep.classList.remove("left");
51 }
52
53 // Adjust inner container height based on new step's height.
54 $("inner-container").style.height =
55 $(steps[this.currentStep_ + offset]).offsetHeight;
56
57 setTimeout(function(){oldstep.classList.add('hidden');}, 500);
58 this.currentStep_ += offset;
59 $("oobe").className = steps[this.currentStep_];
60 }
61 },
62 };
63
64 /**
65 * Initializes the OOBE flow. This will cause all C++ handlers to
66 * be invoked to do final setup.
67 */
68 Oobe.initialize = function() {
69 // Adjust inner container height based on first step's height
70 $("inner-container").style.height = $(steps[0]).offsetHeight;
71
72 $('continue-button').addEventListener('click', function(event) {
73 // TODO(nkostylev): Callback screen handler.
74 Oobe.toggleStep(1);
75 });
76 $('back-button').addEventListener('click', function(event) {
77 // TODO(nkostylev): Callback screen handler.
78 Oobe.toggleStep(0);
79 });
80 $('accept-button').addEventListener('click', function(event) {
81 // TODO(nkostylev): Callback screen handler.
82 Oobe.toggleStep(2);
83 });
84
85 chrome.send('screenStateInitialize');
86 };
87
88 /**
89 * Switches to the next OOBE step.
90 * @param {number} nextStep Index of the next step.
91 */
92 Oobe.toggleStep = function(nextStep) {
93 Oobe.getInstance().toggleStep_(nextStep);
94 };
95
96 // Export
97 return {
98 Oobe: Oobe
99 };
100 });
101
102 var Oobe = cr.ui.Oobe;
103
104 document.addEventListener('DOMContentLoaded', cr.ui.Oobe.initialize);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698