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

Unified 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 side-by-side diff with in-line comments
Download patch
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..3ad19e4e7de29d926887f567f1c8ea8332f81ceb
--- /dev/null
+++ b/chrome/browser/resources/chromeos/oobe.js
@@ -0,0 +1,100 @@
+// 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() {
+ cr.addSingletonGetter(Oobe);
+
+ Oobe.localStrings_ = new LocalStrings();
+
+ Oobe.prototype = {
+ /**
+ * Current OOBE step, index in the steps array.
+ * @type {number}
+ */
+ currentStep_: 0,
+
+ /**
+ * Switches to the next OOBE step.
+ * @param {number} nextStep Index of the next step.
+ */
+ toggleStep_: function(nextStep) {
+ 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');
+
+ // TODO(nkostylev): Support offset other than -1/1.
+ 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);
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.
+ 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
+ $('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);

Powered by Google App Engine
This is Rietveld 408576698