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

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 cr.addSingletonGetter(Oobe);
14
15 Oobe.localStrings_ = new LocalStrings();
16
17 Oobe.prototype = {
18 /**
19 * Current OOBE step, index in the steps array.
20 * @type {number}
21 */
22 currentStep_: 0,
23
24 /**
25 * Switches to the next OOBE step.
26 * @param {number} nextStep Index of the next step.
27 */
28 toggleStep_: function(nextStep) {
29 var offset = nextStep - this.currentStep_;
30 var oldstep = $(steps[this.currentStep_]);
31 var oldheader = $('h' + steps[this.currentStep_]);
32 var newstep = $(steps[this.currentStep_ + offset]);
33 var newheader = $('h' + steps[this.currentStep_ + offset]);
34
35 newstep.classList.remove('hidden');
36
37 // TODO(nkostylev): Support offset other than -1/1.
38 if (offset == 1) {
39 oldheader.classList.add('left');
40 oldstep.classList.add('left');
41 newheader.classList.remove('right');
42 newstep.classList.remove('right');
43 } else if (offset == -1) {
44 oldheader.classList.add('right');
45 oldstep.classList.add('right');
46 newheader.classList.remove('left');
47 newstep.classList.remove('left');
48 }
49
50 // Adjust inner container height based on new step's height.
51 $('inner-container').style.height =
52 $(steps[this.currentStep_ + offset]).offsetHeight;
53
54 setTimeout(function(){oldstep.classList.add('hidden');}, 500);
Evan Stade 2011/06/08 22:46:56 this is not correct. I don't even think it's neces
Nikita (slow) 2011/06/09 15:52:14 Done.
55 this.currentStep_ += offset;
Evan Stade 2011/06/08 22:46:56 I guess this is a pretty insignificant nit, but it
Nikita (slow) 2011/06/09 15:52:14 You're right, I'll change this. Initially offset w
56 $('oobe').className = steps[this.currentStep_];
57 },
58 };
59
60 /**
61 * Initializes the OOBE flow. This will cause all C++ handlers to
62 * be invoked to do final setup.
63 */
64 Oobe.initialize = function() {
65 // Adjust inner container height based on first step's height
66 $('inner-container').style.height = $(steps[0]).offsetHeight;
67
68 $('continue-button').addEventListener('click', function(event) {
69 // TODO(nkostylev): Callback screen handler.
70 Oobe.toggleStep(1);
71 });
72 $('back-button').addEventListener('click', function(event) {
73 // TODO(nkostylev): Callback screen handler.
74 Oobe.toggleStep(0);
75 });
76 $('accept-button').addEventListener('click', function(event) {
77 // TODO(nkostylev): Callback screen handler.
78 Oobe.toggleStep(2);
79 });
80
81 chrome.send('screenStateInitialize');
82 };
83
84 /**
85 * Switches to the next OOBE step.
86 * @param {number} nextStep Index of the next step.
87 */
88 Oobe.toggleStep = function(nextStep) {
89 Oobe.getInstance().toggleStep_(nextStep);
90 };
91
92 // Export
93 return {
94 Oobe: Oobe
95 };
96 });
97
98 var Oobe = cr.ui.Oobe;
99
100 document.addEventListener('DOMContentLoaded', cr.ui.Oobe.initialize);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698