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..8948d1d76efe66d5cbcacbd3aced8affa688a551 |
--- /dev/null |
+++ b/chrome/browser/resources/chromeos/oobe.js |
@@ -0,0 +1,102 @@ |
+// 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. |
Evan Stade
2011/06/08 19:56:07
@type {number}
Nikita (slow)
2011/06/08 22:28:27
Done.
|
+ */ |
+ 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"); |
+ |
+ 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"); |
+ } |
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
|
+ |
+ // 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; |
Evan Stade
2011/06/08 19:56:07
use single quotes in js
Nikita (slow)
2011/06/08 22:28:27
Done.
|
+ |
+ $('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); |