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