@@ -123,14 +123,14 @@ function analyzeData(wizard, options, state)
123
123
var item = $ ( this ) , // item == header
124
124
content = stepContents . eq ( index ) ,
125
125
modeData = content . data ( "mode" ) ,
126
- mode = ( modeData == null ) ? $ . fn . steps . contentMode . html : getValidEnumValue ( $ . fn . steps . contentMode ,
126
+ mode = ( modeData == null ) ? contentMode . html : getValidEnumValue ( contentMode ,
127
127
( / ^ \s * $ / . test ( modeData ) || isNaN ( modeData ) ) ? modeData : parseInt ( modeData , 0 ) ) ,
128
- contentUrl = ( mode === $ . fn . steps . contentMode . html || content . data ( "url" ) === undefined ) ?
128
+ contentUrl = ( mode === contentMode . html || content . data ( "url" ) === undefined ) ?
129
129
"" : content . data ( "url" ) ,
130
- contentLoaded = ( mode !== $ . fn . steps . contentMode . html && content . data ( "loaded" ) === "1" ) ,
131
- step = $ . extend ( { } , $ . fn . steps . stepModel , {
130
+ contentLoaded = ( mode !== contentMode . html && content . data ( "loaded" ) === "1" ) ,
131
+ step = $ . extend ( { } , stepModel , {
132
132
title : item . html ( ) ,
133
- content : ( mode === $ . fn . steps . contentMode . html ) ? content . html ( ) : "" ,
133
+ content : ( mode === contentMode . html ) ? content . html ( ) : "" ,
134
134
contentUrl : contentUrl ,
135
135
contentMode : mode ,
136
136
contentLoaded : contentLoaded
@@ -181,11 +181,6 @@ function format(format)
181
181
return format ;
182
182
}
183
183
184
- function generateMenuItem ( tag , label )
185
- {
186
- return "<li><a href=\"#" + tag + "\" role=\"menuitem\">" + label + "</a></li>" ;
187
- }
188
-
189
184
function getOptions ( wizard )
190
185
{
191
186
return wizard . data ( "options" ) ;
@@ -358,9 +353,9 @@ function goToStep(wizard, options, state, index)
358
353
loadAsyncContent ( wizard , options , state ) ;
359
354
360
355
var stepContents = wizard . find ( ".content > .body" ) ;
361
- switch ( getValidEnumValue ( $ . fn . steps . transitionEffect , options . transitionEffect ) )
356
+ switch ( getValidEnumValue ( transitionEffect , options . transitionEffect ) )
362
357
{
363
- case $ . fn . steps . transitionEffect . fade :
358
+ case transitionEffect . fade :
364
359
state . transitionShowElement = stepContents . eq ( index ) ;
365
360
stepContents . eq ( oldIndex ) . fadeOut ( options . transitionEffectSpeed , function ( )
366
361
{
@@ -376,7 +371,7 @@ function goToStep(wizard, options, state, index)
376
371
} ) . promise ( ) ;
377
372
break ;
378
373
379
- case $ . fn . steps . transitionEffect . slide :
374
+ case transitionEffect . slide :
380
375
state . transitionShowElement = stepContents . eq ( index ) ;
381
376
stepContents . eq ( oldIndex ) . slideUp ( options . transitionEffectSpeed , function ( )
382
377
{
@@ -392,7 +387,7 @@ function goToStep(wizard, options, state, index)
392
387
} ) . promise ( ) ;
393
388
break ;
394
389
395
- case $ . fn . steps . transitionEffect . slideLeft :
390
+ case transitionEffect . slideLeft :
396
391
var newStep = stepContents . eq ( index ) ,
397
392
currentStep = stepContents . eq ( oldIndex ) ,
398
393
outerWidth = currentStep . outerWidth ( true ) ,
@@ -437,7 +432,7 @@ function increaseCurrentIndexBy(state, increaseBy)
437
432
function initialize ( options )
438
433
{
439
434
/*jshint -W040 */
440
- var opts = $ . extend ( true , { } , $ . fn . steps . defaults , options ) ;
435
+ var opts = $ . extend ( true , { } , defaults , options ) ;
441
436
442
437
return this . each ( function ( i )
443
438
{
@@ -498,7 +493,7 @@ function insertStep(wizard, options, state, index, step)
498
493
// TODO: Validate step object
499
494
500
495
// Change data
501
- step = $ . extend ( { } , $ . fn . steps . stepModel , step ) ;
496
+ step = $ . extend ( { } , stepModel , step ) ;
502
497
insertStepToCache ( wizard , index , step ) ;
503
498
if ( state . currentIndex >= index )
504
499
{
@@ -508,10 +503,10 @@ function insertStep(wizard, options, state, index, step)
508
503
state . stepCount ++ ;
509
504
510
505
var contentContainer = wizard . find ( ".content" ) ,
511
- header = $ ( document . createElement ( options . headerTag ) ) . html ( step . title ) ,
512
- body = $ ( document . createElement ( options . bodyTag ) ) ;
506
+ header = $ ( format ( "<{0}>{1}</{0}>" , options . headerTag , step . title ) ) ,
507
+ body = $ ( format ( "<{0}></{0}>" , options . bodyTag ) ) ;
513
508
514
- if ( step . contentMode == null || step . contentMode === $ . fn . steps . contentMode . html )
509
+ if ( step . contentMode == null || step . contentMode === contentMode . html )
515
510
{
516
511
body . html ( step . content ) ;
517
512
}
@@ -597,15 +592,15 @@ function loadAsyncContent(wizard, options, state)
597
592
598
593
if ( ! options . enableContentCache || ! currentStep . contentLoaded )
599
594
{
600
- switch ( getValidEnumValue ( $ . fn . steps . contentMode , currentStep . contentMode ) )
595
+ switch ( getValidEnumValue ( contentMode , currentStep . contentMode ) )
601
596
{
602
- case $ . fn . steps . contentMode . iframe :
597
+ case contentMode . iframe :
603
598
wizard . find ( ".content > .body" ) . eq ( state . currentIndex ) . empty ( )
604
- . html ( $ ( "<iframe src=\"" + currentStep . contentUrl + "\" />" ) )
599
+ . html ( "<iframe src=\"" + currentStep . contentUrl + "\" />" )
605
600
. data ( "loaded" , "1" ) ;
606
601
break ;
607
602
608
- case $ . fn . steps . contentMode . async :
603
+ case contentMode . async :
609
604
var currentStepContent = wizard . find ( "#" + getUniqueId ( wizard ) + _tabpanelSuffix + state . currentIndex ) . aria ( "busy" , "true" )
610
605
. empty ( ) . append ( renderTemplate ( options . loadingTemplate , { text : options . labels . loading } ) ) ;
611
606
$ . ajax ( { url : currentStep . contentUrl , cache : false } )
@@ -863,7 +858,7 @@ function removeStep(wizard, options, state, index)
863
858
}
864
859
865
860
// Change data
866
- removeStepToCache ( wizard , index ) ;
861
+ removeStepFromCache ( wizard , index ) ;
867
862
if ( state . currentIndex > index )
868
863
{
869
864
state . currentIndex -- ;
@@ -893,7 +888,7 @@ function removeStep(wizard, options, state, index)
893
888
return true ;
894
889
}
895
890
896
- function removeStepToCache ( wizard , index )
891
+ function removeStepFromCache ( wizard , index )
897
892
{
898
893
getSteps ( wizard ) . splice ( index , 1 ) ;
899
894
}
@@ -911,10 +906,9 @@ function removeStepToCache(wizard, index)
911
906
function render ( wizard , options , state )
912
907
{
913
908
// Create a content wrapper and copy HTML from the intial wizard structure
914
- var contentWrapper = $ ( document . createElement ( options . contentContainerTag ) )
915
- . addClass ( "content" ) . html ( wizard . html ( ) ) ,
916
- stepsWrapper = $ ( document . createElement ( options . stepsContainerTag ) )
917
- . addClass ( "steps" ) . append ( $ ( "<ul role=\"tablist\"></ul>" ) ) ,
909
+ var wrapperTemplate = "<{0} class=\"{1}\">{2}</{0}>" ,
910
+ contentWrapper = $ ( format ( wrapperTemplate , options . contentContainerTag , "content" , wizard . html ( ) ) ) ,
911
+ stepsWrapper = $ ( format ( wrapperTemplate , options . stepsContainerTag , "steps" , "<ul role=\"tablist\"></ul>" ) ) ,
918
912
stepTitles = contentWrapper . children ( options . headerTag ) ,
919
913
stepContents = contentWrapper . children ( options . bodyTag ) ;
920
914
@@ -974,23 +968,24 @@ function renderPagination(wizard, options, state)
974
968
{
975
969
if ( options . enablePagination )
976
970
{
977
- var actionCollection = $ ( "<ul role=\"menu\" aria-label=\"" + options . labels . pagination + "\"></ul>" ) ,
978
- actionWrapper = $ ( document . createElement ( options . actionContainerTag ) )
979
- . addClass ( "actions" ) . append ( actionCollection ) ;
980
- wizard . append ( actionWrapper ) ;
971
+ var pagination = "<{0} class=\"actions\"><ul role=\"menu\" aria-label=\"{1}\">{2}</ul></{0}>" ,
972
+ buttonTemplate = "<li><a href=\"#{0}\" role=\"menuitem\">{1}</a></li>" ,
973
+ buttons = "" ;
981
974
982
975
if ( ! options . forceMoveForward )
983
976
{
984
- actionCollection . append ( generateMenuItem ( "previous" , options . labels . previous ) ) ;
977
+ buttons += format ( buttonTemplate , "previous" , options . labels . previous ) ;
985
978
}
986
979
987
- actionCollection . append ( generateMenuItem ( "next" , options . labels . next ) ) ;
980
+ buttons += format ( buttonTemplate , "next" , options . labels . next ) ;
988
981
989
982
if ( options . enableFinishButton )
990
983
{
991
- actionCollection . append ( generateMenuItem ( "finish" , options . labels . finish ) ) ;
984
+ buttons += format ( buttonTemplate , "finish" , options . labels . finish ) ;
992
985
}
993
986
987
+ wizard . append ( format ( pagination , options . actionContainerTag , options . labels . pagination , buttons ) ) ;
988
+
994
989
refreshPagination ( wizard , options , state ) ;
995
990
loadAsyncContent ( wizard , options , state ) ;
996
991
}
0 commit comments