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 'user-manager-tutorial' is the element that controls the |
| 7 * tutorial steps for the user manager page. |
| 8 * |
| 9 * @element user-manager-tutorial |
| 10 */ |
| 11 Polymer({ |
| 12 is: 'user-manager-tutorial', |
| 13 |
| 14 properties: { |
| 15 /** |
| 16 * True if the tutorial is currently hidden. |
| 17 * @private {boolean} |
| 18 */ |
| 19 hidden_: { |
| 20 type: Boolean, |
| 21 value: true |
| 22 }, |
| 23 |
| 24 /** |
| 25 * Current tutorial step, index in the steps array. |
| 26 * @type {number} |
| 27 */ |
| 28 currentStep_: { |
| 29 type: Number, |
| 30 value: 0 |
| 31 } |
| 32 }, |
| 33 |
| 34 /** @override */ |
| 35 created: function() { |
| 36 this.steps_ = ['yourChrome', 'friends', 'guests', 'complete', 'notYou']; |
| 37 }, |
| 38 |
| 39 /** |
| 40 * Determines whether a given step is displaying. |
| 41 * @param {string} currentStep Index of the current step |
| 42 * @param {string} step Name of the given step |
| 43 * @return {boolean} |
| 44 * @private |
| 45 */ |
| 46 isStepHidden_: function(currentStep, step) { |
| 47 return this.steps_[currentStep] != step; |
| 48 }, |
| 49 |
| 50 /** |
| 51 * Navigates to the next step. |
| 52 * @private |
| 53 */ |
| 54 onNextTap_: function() { |
| 55 var nextStep = this.currentStep_ + 1; |
| 56 |
| 57 // The last tutorial step is an information bubble that ends the tutorial. |
| 58 if (nextStep >= this.steps_.length) |
| 59 this.onDissmissTap_(); |
| 60 else |
| 61 this.currentStep_ = nextStep; |
| 62 }, |
| 63 |
| 64 /** |
| 65 * Handler for the link in the last step. Takes user to the create-profile |
| 66 * page in order to add a new profile. |
| 67 * @param {!Event} event |
| 68 * @private |
| 69 */ |
| 70 onAddUserTap_: function(event) { |
| 71 this.onDissmissTap_(); |
| 72 // Event is caught by user-manager-pages. |
| 73 this.fire('change-page', {page: 'create-user-page'}); |
| 74 }, |
| 75 |
| 76 /** |
| 77 * Starts the tutorial. |
| 78 */ |
| 79 startTutorial: function() { |
| 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 onDissmissTap_: function() { |
| 103 $('inner-container').classList.remove('disabled'); |
| 104 this.hidden_ = true; |
| 105 } |
| 106 }); |
OLD | NEW |