Skip to content

Commit 03fa90a

Browse files
committed
Added event for the close button.
1 parent 33dbff1 commit 03fa90a

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

src/ui/tutorial/tutorial.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,43 +68,48 @@ cwc.ui.Tutorial.prototype.setTour = function(tourData) {
6868
'showCancelLink': true,
6969
},
7070
});
71+
this.tour_.once('cancel', () => {
72+
let sidebarInstance = this.helper.getInstance('sidebar');
73+
if (sidebarInstance) {
74+
sidebarInstance.setActive('tutorial', false);
75+
}
76+
});
7177
this.tourLength_ = tourData.length;
7278
for (let i in tourData) {
7379
if (!Object.prototype.hasOwnProperty.call(tourData, i)) continue;
7480
let data = tourData[i];
7581
let step = {};
7682

7783
// Step id
78-
step.id = data.id || 'step' + i;
84+
step['id'] = data['id'] || 'step' + i;
7985

8086
// Title
81-
if (data.title) {
82-
step.title = i18t(data.title);
87+
if (data['title']) {
88+
step['title'] = i18t(data['title']);
8389
} else {
8490
this.log_.error('Step', i, 'missing title!');
8591
}
8692

8793
// Text
88-
if (data.text) {
89-
step.text = i18t(data.text);
94+
if (data['text']) {
95+
step['text'] = i18t(data['text']);
9096
} else {
9197
this.log_.error('Step', i, 'missing text!');
9298
}
9399

94100
// Attached to element
95-
if (data.attachTo) {
96-
step.attachTo = data.attachTo;
101+
if (typeof data['attachTo'] !== 'undefined') {
102+
step['attachTo'] = data['attachTo'];
97103
}
98104

99105
// Handle buttons
100-
if (data.buttons) {
101-
step.buttons = data.buttons;
106+
if (data['buttons']) {
107+
step['buttons'] = data['buttons'];
102108
} else {
103-
step.buttons = [];
104-
console.log(i, this.tourLength_);
109+
step['buttons'] = [];
105110
// Back button
106111
if (i > 0) {
107-
step.buttons.push({
112+
step['buttons'].push({
108113
'text': i18t('Back'),
109114
'action': this.tour_.back,
110115
'classes': 'shepherd-button-secondary',
@@ -113,7 +118,7 @@ cwc.ui.Tutorial.prototype.setTour = function(tourData) {
113118

114119
// Exit
115120
if (i == 0) {
116-
step.buttons.push({
121+
step['buttons'].push({
117122
'text': i18t('Exit'),
118123
'action': this.cancel.bind(this),
119124
'classes': 'shepherd-button-secondary',
@@ -122,15 +127,15 @@ cwc.ui.Tutorial.prototype.setTour = function(tourData) {
122127

123128
// Done
124129
if (i == this.tourLength_ - 1) {
125-
step.buttons.push({
130+
step['buttons'].push({
126131
'text': i18t('Done'),
127132
'action': this.cancel.bind(this),
128133
'classes': 'shepherd-button-example-primary',
129134
});
130135
}
131136
// Next button
132137
if (i < this.tourLength_ - 1) {
133-
step.buttons.push({
138+
step['buttons'].push({
134139
'text': i18t('Next'),
135140
'action': this.tour_.next,
136141
'classes': 'shepherd-button-example-primary',

0 commit comments

Comments
 (0)