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