Chromium Code Reviews| 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..25fa9fbeb9e091799601307f39a6412f6f1f02ed |
| --- /dev/null |
| +++ b/chrome/browser/resources/md_user_manager/user_manager_tutorial.js |
| @@ -0,0 +1,108 @@ |
| +/* 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; |
| + } |
| + |
|
Dan Beam
2016/02/12 23:42:24
nit: remove \n
Moe
2016/02/20 00:21:00
Done.
|
| +}); |