@@ -52,8 +52,8 @@ angular.module('patternfly.wizard').component('pfWizardStep', {
5252 controller : function ( $timeout ) {
5353 'use strict' ;
5454
55- var firstRun = true ,
56- ctrl = this ;
55+ var ctrl = this ,
56+ firstRun ;
5757
5858 var stepIdx = function ( step ) {
5959 var idx = 0 ;
@@ -86,32 +86,59 @@ angular.module('patternfly.wizard').component('pfWizardStep', {
8686 return foundStep ;
8787 } ;
8888
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+ } ;
115142
116143 ctrl . getEnabledSteps = function ( ) {
117144 return ctrl . steps . filter ( function ( step ) {
@@ -204,7 +231,7 @@ angular.module('patternfly.wizard').component('pfWizardStep', {
204231 }
205232 } ;
206233
207- this . addStep = function ( step ) {
234+ ctrl . addStep = function ( step ) {
208235 // Insert the step into step array
209236 var insertBefore = _ . find ( ctrl . steps , function ( nextStep ) {
210237 return nextStep . stepPriority > step . stepPriority ;
@@ -216,36 +243,22 @@ angular.module('patternfly.wizard').component('pfWizardStep', {
216243 }
217244 } ;
218245
219- this . currentStepTitle = function ( ) {
246+ ctrl . currentStepTitle = function ( ) {
220247 return ctrl . selectedStep . stepTitle ;
221248 } ;
222249
223- this . currentStepDescription = function ( ) {
250+ ctrl . currentStepDescription = function ( ) {
224251 return ctrl . selectedStep . description ;
225252 } ;
226253
227- this . currentStep = function ( ) {
254+ ctrl . currentStep = function ( ) {
228255 return ctrl . selectedStep ;
229256 } ;
230257
231- this . totalStepCount = function ( ) {
258+ ctrl . totalStepCount = function ( ) {
232259 return ctrl . getEnabledSteps ( ) . length ;
233260 } ;
234261
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-
249262 // Method used for next button within step
250263 ctrl . next = function ( callback ) {
251264 var enabledSteps = ctrl . getEnabledSteps ( ) ;
@@ -291,35 +304,7 @@ angular.module('patternfly.wizard').component('pfWizardStep', {
291304 }
292305 }
293306 }
294-
295307 return goPrev ;
296308 } ;
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- } ;
324309 }
325310} ) ;
0 commit comments