@@ -181,6 +181,27 @@ function format(format)
181181 return format ;
182182}
183183
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+
184205function getOptions ( wizard )
185206{
186207 return wizard . data ( "options" ) ;
@@ -403,7 +424,7 @@ function initialize(options)
403424 // Trigger focus
404425 if ( opts . autoFocus && _uniqueId === 0 )
405426 {
406- wizard . find ( "#" + getUniqueId ( wizard ) + _tabSuffix + opts . startIndex ) . focus ( ) ;
427+ getStepAnchor ( wizard , opts . startIndex ) . focus ( ) ;
407428 }
408429 } ) ;
409430}
@@ -430,8 +451,6 @@ function initialize(options)
430451 **/
431452function insertStep ( wizard , options , state , index , step )
432453{
433- var uniqueId = getUniqueId ( wizard ) ;
434-
435454 if ( index < 0 || index > state . stepCount )
436455 {
437456 throwError ( _indexOutOfRangeErrorMessage ) ;
@@ -464,7 +483,7 @@ function insertStep(wizard, options, state, index, step)
464483 }
465484 else
466485 {
467- contentContainer . find ( "#" + uniqueId + _tabpanelSuffix + ( index - 1 ) ) . after ( body ) . after ( header ) ;
486+ getStepPanel ( wizard , ( index - 1 ) ) . after ( body ) . after ( header ) ;
468487 }
469488
470489 renderBody ( wizard , body , index ) ;
@@ -550,13 +569,13 @@ function loadAsyncContent(wizard, options, state)
550569 break ;
551570
552571 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" )
554573 . 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+ } ) ;
560579 break ;
561580 }
562581 }
@@ -581,17 +600,18 @@ function paginationClick(wizard, options, state, index)
581600
582601 if ( index >= 0 && index < state . stepCount && ! ( options . forceMoveForward && index < state . currentIndex ) )
583602 {
584- var anchor = wizard . find ( "#" + getUniqueId ( wizard ) + _tabSuffix + index ) ,
603+ var anchor = getStepAnchor ( wizard , index ) ,
585604 parent = anchor . parent ( ) ,
586605 isDisabled = parent . hasClass ( "disabled" ) ;
587- // Remove the class to make the anchor clickable!
606+
607+ // Enable the step to make the anchor clickable!
588608 parent . enableAria ( ) ;
589609 anchor . click ( ) ;
590610
591611 // An error occured
592612 if ( oldIndex === state . currentIndex && isDisabled )
593613 {
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.
595615 parent . disableAria ( ) ;
596616 return false ;
597617 }
@@ -722,14 +742,13 @@ function refreshPagination(wizard, options, state)
722742 */
723743function refreshStepNavigation ( wizard , options , state , oldIndex )
724744{
725- var uniqueId = getUniqueId ( wizard ) ,
726- currentOrNewStepAnchor = wizard . find ( "#" + uniqueId + _tabSuffix + state . currentIndex ) ,
745+ var currentOrNewStepAnchor = getStepAnchor ( wizard , state . currentIndex ) ,
727746 currentInfo = $ ( "<span class=\"current-info audible\">" + options . labels . current + " </span>" ) ,
728747 stepTitles = wizard . find ( ".content > .title" ) ;
729748
730749 if ( oldIndex != null )
731750 {
732- var oldStepAnchor = wizard . find ( "#" + uniqueId + _tabSuffix + oldIndex ) ;
751+ var oldStepAnchor = getStepAnchor ( wizard , oldIndex ) ;
733752 oldStepAnchor . parent ( ) . addClass ( "done" ) . removeClass ( "error" ) . deselectAria ( ) ;
734753 stepTitles . eq ( oldIndex ) . removeClass ( "current" ) . next ( ".body" ) . removeClass ( "current" ) ;
735754 currentInfo = oldStepAnchor . find ( ".current-info" ) ;
@@ -799,8 +818,6 @@ function registerEvents(wizard, options)
799818 **/
800819function removeStep ( wizard , options , state , index )
801820{
802- var uniqueId = getUniqueId ( wizard ) ;
803-
804821 // Index out of range and try deleting current item will return false.
805822 if ( index < 0 || index >= state . stepCount || state . currentIndex === index )
806823 {
@@ -816,9 +833,9 @@ function removeStep(wizard, options, state, index)
816833 }
817834 state . stepCount -- ;
818835
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 ( ) ;
822839
823840 // Set the "first" class to the new first step button
824841 if ( index === 0 )
@@ -1089,14 +1106,13 @@ function startTransitionEffect(wizard, options, state, index, oldIndex)
10891106 case transitionEffect . slideLeft :
10901107 var outerWidth = currentStep . outerWidth ( true ) ,
10911108 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 ;
10951111
10961112 currentStep . animate ( { left : posFadeOut } , effectSpeed ,
10971113 function ( ) { $ ( this ) . hideAria ( ) ; } ) . promise ( ) ;
10981114 newStep . css ( "left" , posFadeIn + "px" ) . showAria ( )
1099- . animate ( { left : currentPos } , effectSpeed ) . promise ( ) ;
1115+ . animate ( { left : posLeft } , effectSpeed ) . promise ( ) ;
11001116 break ;
11011117
11021118 default :
@@ -1135,7 +1151,7 @@ function stepClickHandler(event)
11351151 // If nothing has changed
11361152 if ( oldIndex === state . currentIndex )
11371153 {
1138- wizard . find ( "#" + getUniqueId ( wizard ) + _tabSuffix + oldIndex ) . focus ( ) ;
1154+ getStepAnchor ( wizard , oldIndex ) . focus ( ) ;
11391155 return false ;
11401156 }
11411157}
0 commit comments