@@ -68,43 +68,48 @@ cwc.ui.Tutorial.prototype.setTour = function(tourData) {
68
68
'showCancelLink' : true ,
69
69
} ,
70
70
} ) ;
71
+ this . tour_ . once ( 'cancel' , ( ) => {
72
+ let sidebarInstance = this . helper . getInstance ( 'sidebar' ) ;
73
+ if ( sidebarInstance ) {
74
+ sidebarInstance . setActive ( 'tutorial' , false ) ;
75
+ }
76
+ } ) ;
71
77
this . tourLength_ = tourData . length ;
72
78
for ( let i in tourData ) {
73
79
if ( ! Object . prototype . hasOwnProperty . call ( tourData , i ) ) continue ;
74
80
let data = tourData [ i ] ;
75
81
let step = { } ;
76
82
77
83
// Step id
78
- step . id = data . id || 'step' + i ;
84
+ step [ 'id' ] = data [ 'id' ] || 'step' + i ;
79
85
80
86
// Title
81
- if ( data . title ) {
82
- step . title = i18t ( data . title ) ;
87
+ if ( data [ ' title' ] ) {
88
+ step [ ' title' ] = i18t ( data [ ' title' ] ) ;
83
89
} else {
84
90
this . log_ . error ( 'Step' , i , 'missing title!' ) ;
85
91
}
86
92
87
93
// Text
88
- if ( data . text ) {
89
- step . text = i18t ( data . text ) ;
94
+ if ( data [ ' text' ] ) {
95
+ step [ ' text' ] = i18t ( data [ ' text' ] ) ;
90
96
} else {
91
97
this . log_ . error ( 'Step' , i , 'missing text!' ) ;
92
98
}
93
99
94
100
// Attached to element
95
- if ( data . attachTo ) {
96
- step . attachTo = data . attachTo ;
101
+ if ( typeof data [ ' attachTo' ] !== 'undefined' ) {
102
+ step [ ' attachTo' ] = data [ ' attachTo' ] ;
97
103
}
98
104
99
105
// Handle buttons
100
- if ( data . buttons ) {
101
- step . buttons = data . buttons ;
106
+ if ( data [ ' buttons' ] ) {
107
+ step [ ' buttons' ] = data [ ' buttons' ] ;
102
108
} else {
103
- step . buttons = [ ] ;
104
- console . log ( i , this . tourLength_ ) ;
109
+ step [ 'buttons' ] = [ ] ;
105
110
// Back button
106
111
if ( i > 0 ) {
107
- step . buttons . push ( {
112
+ step [ ' buttons' ] . push ( {
108
113
'text' : i18t ( 'Back' ) ,
109
114
'action' : this . tour_ . back ,
110
115
'classes' : 'shepherd-button-secondary' ,
@@ -113,7 +118,7 @@ cwc.ui.Tutorial.prototype.setTour = function(tourData) {
113
118
114
119
// Exit
115
120
if ( i == 0 ) {
116
- step . buttons . push ( {
121
+ step [ ' buttons' ] . push ( {
117
122
'text' : i18t ( 'Exit' ) ,
118
123
'action' : this . cancel . bind ( this ) ,
119
124
'classes' : 'shepherd-button-secondary' ,
@@ -122,15 +127,15 @@ cwc.ui.Tutorial.prototype.setTour = function(tourData) {
122
127
123
128
// Done
124
129
if ( i == this . tourLength_ - 1 ) {
125
- step . buttons . push ( {
130
+ step [ ' buttons' ] . push ( {
126
131
'text' : i18t ( 'Done' ) ,
127
132
'action' : this . cancel . bind ( this ) ,
128
133
'classes' : 'shepherd-button-example-primary' ,
129
134
} ) ;
130
135
}
131
136
// Next button
132
137
if ( i < this . tourLength_ - 1 ) {
133
- step . buttons . push ( {
138
+ step [ ' buttons' ] . push ( {
134
139
'text' : i18t ( 'Next' ) ,
135
140
'action' : this . tour_ . next ,
136
141
'classes' : 'shepherd-button-example-primary' ,
0 commit comments