OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 |
| 7 * 'user-manager-tutorial' is the element that controls the tutorial steps for |
| 8 * the user manager page. |
| 9 * |
| 10 * @element user-manager-tutorial |
| 11 */ |
| 12 Polymer({ |
| 13 is: 'user-manager-tutorial', |
| 14 |
| 15 properties: { |
| 16 /** |
| 17 * True if the tutorial is currently showing. |
| 18 * @type {boolean} |
| 19 */ |
| 20 hidden: { |
| 21 type: Boolean, |
| 22 value: true |
| 23 } |
| 24 }, |
| 25 |
| 26 /** @override */ |
| 27 attached: function() { |
| 28 this.steps_ = ['yourChrome', |
| 29 'friends', |
| 30 'guests', |
| 31 'complete', |
| 32 'notYou']; |
| 33 }, |
| 34 |
| 35 /** |
| 36 * Determines whether a given step is displaying. |
| 37 * @param {string} currentStep Index of the current step |
| 38 * @param {string} step Name of the given step |
| 39 * @return {boolean} |
| 40 * @private |
| 41 */ |
| 42 isStepHidden_: function(currentStep, step) { |
| 43 return this.steps_[currentStep] != step; |
| 44 }, |
| 45 |
| 46 /** |
| 47 * Navigates to the next step. |
| 48 * @private |
| 49 */ |
| 50 next_: function() { |
| 51 var nextStep = this.currentStep_ + 1; |
| 52 |
| 53 // The last tutorial step is an information bubble that ends the tutorial. |
| 54 if (nextStep >= this.steps_.length) |
| 55 this.endTutorial_(); |
| 56 else |
| 57 this.currentStep_ = nextStep; |
| 58 }, |
| 59 |
| 60 /** |
| 61 * Handler for the link in the last step. Takes user to the create-profile |
| 62 * page in order to add a new profile. |
| 63 * @param {!Event} event |
| 64 * @private |
| 65 */ |
| 66 handleAddUser_: function(event) { |
| 67 this.endTutorial_(); |
| 68 // Event is caught by user-manager-pages. |
| 69 this.fire('change-page', {page: 'create-user-page'}); |
| 70 }, |
| 71 |
| 72 /** |
| 73 * Starts the tutorial. |
| 74 */ |
| 75 startTutorial: function() { |
| 76 /** |
| 77 * Current tutorial step, index in the steps array. |
| 78 * @type {number} |
| 79 */ |
| 80 this.currentStep_ = 0; |
| 81 this.hidden = false; |
| 82 |
| 83 // If there's only one pod, show the steps to the side of the pod. |
| 84 // Otherwise, center the steps and disable interacting with the pods |
| 85 // while the tutorial is showing. |
| 86 var podRow = /** @type {{focusPod: !function(), pods: !Array}} */ |
| 87 ($('pod-row')); |
| 88 |
| 89 if (podRow.pods.length == 1) { |
| 90 this.$.yourChrome.classList.add('single-pod'); |
| 91 this.$.complete.classList.add('single-pod'); |
| 92 } |
| 93 |
| 94 podRow.focusPod(); // No focused pods. |
| 95 $('inner-container').classList.add('disabled'); |
| 96 }, |
| 97 |
| 98 /** |
| 99 * Ends the tutorial. |
| 100 * @private |
| 101 */ |
| 102 endTutorial_: function() { |
| 103 $('inner-container').classList.remove('disabled'); |
| 104 this.hidden = true; |
| 105 } |
| 106 }); |
OLD | NEW |