@@ -52,8 +52,8 @@ angular.module('patternfly.wizard').component('pfWizardStep', {
52
52
controller : function ( $timeout ) {
53
53
'use strict' ;
54
54
55
- var firstRun = true ,
56
- ctrl = this ;
55
+ var ctrl = this ,
56
+ firstRun ;
57
57
58
58
var stepIdx = function ( step ) {
59
59
var idx = 0 ;
@@ -86,32 +86,59 @@ angular.module('patternfly.wizard').component('pfWizardStep', {
86
86
return foundStep ;
87
87
} ;
88
88
89
- ctrl . steps = [ ] ;
90
- ctrl . context = { } ;
91
-
92
- if ( angular . isUndefined ( ctrl . nextEnabled ) ) {
93
- ctrl . nextEnabled = true ;
94
- }
95
- if ( angular . isUndefined ( ctrl . prevEnabled ) ) {
96
- ctrl . prevEnabled = true ;
97
- }
98
- if ( angular . isUndefined ( ctrl . showReview ) ) {
99
- ctrl . showReview = false ;
100
- }
101
- if ( angular . isUndefined ( ctrl . showReviewDetails ) ) {
102
- ctrl . showReviewDetails = false ;
103
- }
104
- if ( angular . isUndefined ( ctrl . stepPriority ) ) {
105
- ctrl . stepPriority = 999 ;
106
- } else {
107
- ctrl . stepPriority = parseInt ( ctrl . stepPriority ) ;
108
- }
109
- if ( angular . isUndefined ( ctrl . okToNavAway ) ) {
110
- ctrl . okToNavAway = true ;
111
- }
112
- if ( angular . isUndefined ( ctrl . allowClickNav ) ) {
113
- ctrl . allowClickNav = true ;
114
- }
89
+ ctrl . $onInit = function ( ) {
90
+ firstRun = true ;
91
+ ctrl . steps = [ ] ;
92
+ ctrl . context = { } ;
93
+ ctrl . title = ctrl . stepTitle ;
94
+ ctrl . contentStyle = ctrl . wizard . contentStyle ;
95
+ ctrl . wizard . addStep ( ctrl ) ;
96
+ ctrl . pageNumber = ctrl . wizard . getStepNumber ( ctrl ) ;
97
+
98
+ if ( angular . isUndefined ( ctrl . nextEnabled ) ) {
99
+ ctrl . nextEnabled = true ;
100
+ }
101
+ if ( angular . isUndefined ( ctrl . prevEnabled ) ) {
102
+ ctrl . prevEnabled = true ;
103
+ }
104
+ if ( angular . isUndefined ( ctrl . showReview ) ) {
105
+ ctrl . showReview = false ;
106
+ }
107
+ if ( angular . isUndefined ( ctrl . showReviewDetails ) ) {
108
+ ctrl . showReviewDetails = false ;
109
+ }
110
+ if ( angular . isUndefined ( ctrl . stepPriority ) ) {
111
+ ctrl . stepPriority = 999 ;
112
+ } else {
113
+ ctrl . stepPriority = parseInt ( ctrl . stepPriority ) ;
114
+ }
115
+ if ( angular . isUndefined ( ctrl . okToNavAway ) ) {
116
+ ctrl . okToNavAway = true ;
117
+ }
118
+ if ( angular . isUndefined ( ctrl . allowClickNav ) ) {
119
+ ctrl . allowClickNav = true ;
120
+ }
121
+
122
+ if ( ctrl . substeps && ! ctrl . onShow ) {
123
+ ctrl . onShow = function ( ) {
124
+ $timeout ( function ( ) {
125
+ if ( ! ctrl . selectedStep ) {
126
+ ctrl . goTo ( ctrl . getEnabledSteps ( ) [ 0 ] ) ;
127
+ }
128
+ } , 10 ) ;
129
+ } ;
130
+ }
131
+ } ;
132
+
133
+ ctrl . $onChanges = function ( changesObj ) {
134
+ if ( changesObj . nextTooltip ) {
135
+ ctrl . wizard . nextTooltip = changesObj . nextTooltip . currentValue ;
136
+ }
137
+
138
+ if ( changesObj . prevTooltip ) {
139
+ ctrl . wizard . prevTooltip = changesObj . prevTooltip . currentValue ;
140
+ }
141
+ } ;
115
142
116
143
ctrl . getEnabledSteps = function ( ) {
117
144
return ctrl . steps . filter ( function ( step ) {
@@ -204,7 +231,7 @@ angular.module('patternfly.wizard').component('pfWizardStep', {
204
231
}
205
232
} ;
206
233
207
- this . addStep = function ( step ) {
234
+ ctrl . addStep = function ( step ) {
208
235
// Insert the step into step array
209
236
var insertBefore = _ . find ( ctrl . steps , function ( nextStep ) {
210
237
return nextStep . stepPriority > step . stepPriority ;
@@ -216,36 +243,22 @@ angular.module('patternfly.wizard').component('pfWizardStep', {
216
243
}
217
244
} ;
218
245
219
- this . currentStepTitle = function ( ) {
246
+ ctrl . currentStepTitle = function ( ) {
220
247
return ctrl . selectedStep . stepTitle ;
221
248
} ;
222
249
223
- this . currentStepDescription = function ( ) {
250
+ ctrl . currentStepDescription = function ( ) {
224
251
return ctrl . selectedStep . description ;
225
252
} ;
226
253
227
- this . currentStep = function ( ) {
254
+ ctrl . currentStep = function ( ) {
228
255
return ctrl . selectedStep ;
229
256
} ;
230
257
231
- this . totalStepCount = function ( ) {
258
+ ctrl . totalStepCount = function ( ) {
232
259
return ctrl . getEnabledSteps ( ) . length ;
233
260
} ;
234
261
235
- // Allow access to any step
236
- this . _goTo = function ( step ) {
237
- var enabledSteps = ctrl . getEnabledSteps ( ) ;
238
- var stepTo ;
239
-
240
- if ( angular . isNumber ( step ) ) {
241
- stepTo = enabledSteps [ step ] ;
242
- } else {
243
- stepTo = stepByTitle ( step ) ;
244
- }
245
-
246
- ctrl . goTo ( stepTo ) ;
247
- } ;
248
-
249
262
// Method used for next button within step
250
263
ctrl . next = function ( callback ) {
251
264
var enabledSteps = ctrl . getEnabledSteps ( ) ;
@@ -291,35 +304,7 @@ angular.module('patternfly.wizard').component('pfWizardStep', {
291
304
}
292
305
}
293
306
}
294
-
295
307
return goPrev ;
296
308
} ;
297
-
298
- if ( ctrl . substeps && ! ctrl . onShow ) {
299
- ctrl . onShow = function ( ) {
300
- $timeout ( function ( ) {
301
- if ( ! ctrl . selectedStep ) {
302
- ctrl . goTo ( ctrl . getEnabledSteps ( ) [ 0 ] ) ;
303
- }
304
- } , 10 ) ;
305
- } ;
306
- }
307
-
308
- ctrl . $onInit = function ( ) {
309
- ctrl . title = ctrl . stepTitle ;
310
- ctrl . contentStyle = ctrl . wizard . contentStyle ;
311
- ctrl . wizard . addStep ( ctrl ) ;
312
- ctrl . pageNumber = ctrl . wizard . getStepNumber ( ctrl ) ;
313
- } ;
314
-
315
- ctrl . $onChanges = function ( changesObj ) {
316
- if ( changesObj . nextTooltip ) {
317
- ctrl . wizard . nextTooltip = changesObj . nextTooltip . currentValue ;
318
- }
319
-
320
- if ( changesObj . prevTooltip ) {
321
- ctrl . wizard . prevTooltip = changesObj . prevTooltip . currentValue ;
322
- }
323
- } ;
324
309
}
325
310
} ) ;
0 commit comments