@@ -181,6 +181,27 @@ function format(format)
181
181
return format ;
182
182
}
183
183
184
+ function getStepAnchor ( wizard , index )
185
+ {
186
+ var uniqueId = getUniqueId ( wizard ) ;
187
+
188
+ return wizard . find ( "#" + uniqueId + _tabSuffix + index ) ;
189
+ }
190
+
191
+ function getStepPanel ( wizard , index )
192
+ {
193
+ var uniqueId = getUniqueId ( wizard ) ;
194
+
195
+ return wizard . find ( "#" + uniqueId + _tabpanelSuffix + index ) ;
196
+ }
197
+
198
+ function getStepTitle ( wizard , index )
199
+ {
200
+ var uniqueId = getUniqueId ( wizard ) ;
201
+
202
+ return wizard . find ( "#" + uniqueId + _titleSuffix + index ) ;
203
+ }
204
+
184
205
function getOptions ( wizard )
185
206
{
186
207
return wizard . data ( "options" ) ;
@@ -403,7 +424,7 @@ function initialize(options)
403
424
// Trigger focus
404
425
if ( opts . autoFocus && _uniqueId === 0 )
405
426
{
406
- wizard . find ( "#" + getUniqueId ( wizard ) + _tabSuffix + opts . startIndex ) . focus ( ) ;
427
+ getStepAnchor ( wizard , opts . startIndex ) . focus ( ) ;
407
428
}
408
429
} ) ;
409
430
}
@@ -430,8 +451,6 @@ function initialize(options)
430
451
**/
431
452
function insertStep ( wizard , options , state , index , step )
432
453
{
433
- var uniqueId = getUniqueId ( wizard ) ;
434
-
435
454
if ( index < 0 || index > state . stepCount )
436
455
{
437
456
throwError ( _indexOutOfRangeErrorMessage ) ;
@@ -464,7 +483,7 @@ function insertStep(wizard, options, state, index, step)
464
483
}
465
484
else
466
485
{
467
- contentContainer . find ( "#" + uniqueId + _tabpanelSuffix + ( index - 1 ) ) . after ( body ) . after ( header ) ;
486
+ getStepPanel ( wizard , ( index - 1 ) ) . after ( body ) . after ( header ) ;
468
487
}
469
488
470
489
renderBody ( wizard , body , index ) ;
@@ -550,13 +569,13 @@ function loadAsyncContent(wizard, options, state)
550
569
break ;
551
570
552
571
case contentMode . async :
553
- var currentStepContent = wizard . find ( "#" + getUniqueId ( wizard ) + _tabpanelSuffix + state . currentIndex ) . aria ( "busy" , "true" )
572
+ var currentStepContent = getStepPanel ( wizard , state . currentIndex ) . aria ( "busy" , "true" )
554
573
. empty ( ) . append ( renderTemplate ( options . loadingTemplate , { text : options . labels . loading } ) ) ;
555
- $ . ajax ( { url : currentStep . contentUrl , cache : false } )
556
- . done ( function ( data )
557
- {
558
- currentStepContent . empty ( ) . html ( data ) . aria ( "busy" , "false" ) . data ( "loaded" , "1" ) ;
559
- } ) ;
574
+
575
+ $ . ajax ( { url : currentStep . contentUrl , cache : false } ) . done ( function ( data )
576
+ {
577
+ currentStepContent . empty ( ) . html ( data ) . aria ( "busy" , "false" ) . data ( "loaded" , "1" ) ;
578
+ } ) ;
560
579
break ;
561
580
}
562
581
}
@@ -581,17 +600,18 @@ function paginationClick(wizard, options, state, index)
581
600
582
601
if ( index >= 0 && index < state . stepCount && ! ( options . forceMoveForward && index < state . currentIndex ) )
583
602
{
584
- var anchor = wizard . find ( "#" + getUniqueId ( wizard ) + _tabSuffix + index ) ,
603
+ var anchor = getStepAnchor ( wizard , index ) ,
585
604
parent = anchor . parent ( ) ,
586
605
isDisabled = parent . hasClass ( "disabled" ) ;
587
- // Remove the class to make the anchor clickable!
606
+
607
+ // Enable the step to make the anchor clickable!
588
608
parent . enableAria ( ) ;
589
609
anchor . click ( ) ;
590
610
591
611
// An error occured
592
612
if ( oldIndex === state . currentIndex && isDisabled )
593
613
{
594
- // Add the class again to disable the anchor; avoid click action.
614
+ // Disable the step again if current index has not changed; prevents click action.
595
615
parent . disableAria ( ) ;
596
616
return false ;
597
617
}
@@ -722,14 +742,13 @@ function refreshPagination(wizard, options, state)
722
742
*/
723
743
function refreshStepNavigation ( wizard , options , state , oldIndex )
724
744
{
725
- var uniqueId = getUniqueId ( wizard ) ,
726
- currentOrNewStepAnchor = wizard . find ( "#" + uniqueId + _tabSuffix + state . currentIndex ) ,
745
+ var currentOrNewStepAnchor = getStepAnchor ( wizard , state . currentIndex ) ,
727
746
currentInfo = $ ( "<span class=\"current-info audible\">" + options . labels . current + " </span>" ) ,
728
747
stepTitles = wizard . find ( ".content > .title" ) ;
729
748
730
749
if ( oldIndex != null )
731
750
{
732
- var oldStepAnchor = wizard . find ( "#" + uniqueId + _tabSuffix + oldIndex ) ;
751
+ var oldStepAnchor = getStepAnchor ( wizard , oldIndex ) ;
733
752
oldStepAnchor . parent ( ) . addClass ( "done" ) . removeClass ( "error" ) . deselectAria ( ) ;
734
753
stepTitles . eq ( oldIndex ) . removeClass ( "current" ) . next ( ".body" ) . removeClass ( "current" ) ;
735
754
currentInfo = oldStepAnchor . find ( ".current-info" ) ;
@@ -799,8 +818,6 @@ function registerEvents(wizard, options)
799
818
**/
800
819
function removeStep ( wizard , options , state , index )
801
820
{
802
- var uniqueId = getUniqueId ( wizard ) ;
803
-
804
821
// Index out of range and try deleting current item will return false.
805
822
if ( index < 0 || index >= state . stepCount || state . currentIndex === index )
806
823
{
@@ -816,9 +833,9 @@ function removeStep(wizard, options, state, index)
816
833
}
817
834
state . stepCount -- ;
818
835
819
- wizard . find ( "#" + uniqueId + _titleSuffix + index ) . remove ( ) ;
820
- wizard . find ( "#" + uniqueId + _tabpanelSuffix + index ) . remove ( ) ;
821
- wizard . find ( "#" + uniqueId + _tabSuffix + index ) . parent ( ) . remove ( ) ;
836
+ getStepTitle ( wizard , index ) . remove ( ) ;
837
+ getStepPanel ( wizard , index ) . remove ( ) ;
838
+ getStepAnchor ( wizard , index ) . parent ( ) . remove ( ) ;
822
839
823
840
// Set the "first" class to the new first step button
824
841
if ( index === 0 )
@@ -1089,14 +1106,13 @@ function startTransitionEffect(wizard, options, state, index, oldIndex)
1089
1106
case transitionEffect . slideLeft :
1090
1107
var outerWidth = currentStep . outerWidth ( true ) ,
1091
1108
posFadeOut = ( index > oldIndex ) ? - ( outerWidth ) : outerWidth ,
1092
- posFadeIn = ( index > oldIndex ) ? outerWidth : - ( outerWidth ) ;
1093
-
1094
- var currentPos = currentStep . position ( ) . left ;
1109
+ posFadeIn = ( index > oldIndex ) ? outerWidth : - ( outerWidth ) ,
1110
+ posLeft = currentStep . parent ( ) . position ( ) . left ;
1095
1111
1096
1112
currentStep . animate ( { left : posFadeOut } , effectSpeed ,
1097
1113
function ( ) { $ ( this ) . hideAria ( ) ; } ) . promise ( ) ;
1098
1114
newStep . css ( "left" , posFadeIn + "px" ) . showAria ( )
1099
- . animate ( { left : currentPos } , effectSpeed ) . promise ( ) ;
1115
+ . animate ( { left : posLeft } , effectSpeed ) . promise ( ) ;
1100
1116
break ;
1101
1117
1102
1118
default :
@@ -1135,7 +1151,7 @@ function stepClickHandler(event)
1135
1151
// If nothing has changed
1136
1152
if ( oldIndex === state . currentIndex )
1137
1153
{
1138
- wizard . find ( "#" + getUniqueId ( wizard ) + _tabSuffix + oldIndex ) . focus ( ) ;
1154
+ getStepAnchor ( wizard , oldIndex ) . focus ( ) ;
1139
1155
return false ;
1140
1156
}
1141
1157
}
0 commit comments