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