Index: chrome/browser/resources/md_user_manager/user_manager_tutorial.js |
diff --git a/chrome/browser/resources/md_user_manager/user_manager_tutorial.js b/chrome/browser/resources/md_user_manager/user_manager_tutorial.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e134ed8a34d14ac579a8d0f0b1b3bf8ebed5f475 |
--- /dev/null |
+++ b/chrome/browser/resources/md_user_manager/user_manager_tutorial.js |
@@ -0,0 +1,106 @@ |
+// Copyright 2016 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 |
+ * 'user-manager-tutorial' is the element that controls the tutorial steps for |
+ * the user manager page. |
+ * |
+ * @element user-manager-tutorial |
+ */ |
+Polymer({ |
+ is: 'user-manager-tutorial', |
+ |
+ properties: { |
+ /** |
+ * True if the tutorial is currently showing. |
+ * @type {boolean} |
+ */ |
+ hidden: { |
+ type: Boolean, |
+ value: true |
+ } |
+ }, |
+ |
+ /** @override */ |
+ attached: function() { |
+ this.steps_ = ['yourChrome', |
+ 'friends', |
+ 'guests', |
+ 'complete', |
+ 'notYou']; |
+ }, |
+ |
+ /** |
+ * Determines whether a given step is displaying. |
+ * @param {string} currentStep Index of the current step |
+ * @param {string} step Name of the given step |
+ * @return {boolean} |
+ * @private |
+ */ |
+ isStepHidden_: function(currentStep, step) { |
+ return this.steps_[currentStep] != step; |
+ }, |
+ |
+ /** |
+ * Navigates to the next step. |
+ * @private |
+ */ |
+ next_: function() { |
+ var nextStep = this.currentStep_ + 1; |
+ |
+ // The last tutorial step is an information bubble that ends the tutorial. |
+ if (nextStep >= this.steps_.length) |
+ this.endTutorial_(); |
+ else |
+ this.currentStep_ = nextStep; |
+ }, |
+ |
+ /** |
+ * Handler for the link in the last step. Takes user to the create-profile |
+ * page in order to add a new profile. |
+ * @param {!Event} event |
+ * @private |
+ */ |
+ handleAddUser_: function(event) { |
+ this.endTutorial_(); |
+ // Event is caught by user-manager-pages. |
+ this.fire('change-page', {page: 'create-user-page'}); |
+ }, |
+ |
+ /** |
+ * Starts the tutorial. |
+ */ |
+ startTutorial: function() { |
+ /** |
+ * Current tutorial step, index in the steps array. |
+ * @type {number} |
+ */ |
+ this.currentStep_ = 0; |
+ this.hidden = false; |
+ |
+ // If there's only one pod, show the steps to the side of the pod. |
+ // Otherwise, center the steps and disable interacting with the pods |
+ // while the tutorial is showing. |
+ var podRow = /** @type {{focusPod: !function(), pods: !Array}} */ |
+ ($('pod-row')); |
+ |
+ if (podRow.pods.length == 1) { |
+ this.$.yourChrome.classList.add('single-pod'); |
+ this.$.complete.classList.add('single-pod'); |
+ } |
+ |
+ podRow.focusPod(); // No focused pods. |
+ $('inner-container').classList.add('disabled'); |
+ }, |
+ |
+ /** |
+ * Ends the tutorial. |
+ * @private |
+ */ |
+ endTutorial_: function() { |
+ $('inner-container').classList.remove('disabled'); |
+ this.hidden = true; |
+ } |
+}); |