@@ -456,7 +456,16 @@ function getValidEnumValue(enumType, keyOrValue)
456
456
**/
457
457
function goToNextStep ( wizard , options , state )
458
458
{
459
- return paginationClick ( wizard , options , state , increaseCurrentIndexBy ( state , 1 ) ) ;
459
+ // Determine next active step
460
+ var newIndex = increaseCurrentIndexBy ( state , 1 ) ;
461
+ do {
462
+ if ( typeof state . disabledSteps == 'undefined' || $ . inArray ( newIndex , state . disabledSteps ) == - 1 ) {
463
+ break ; //found an index that is not disabled => stop the loop
464
+ }
465
+ newIndex ++ ;
466
+ } while ( true ) ;
467
+
468
+ return paginationClick ( wizard , options , state , newIndex ) ;
460
469
}
461
470
462
471
/**
@@ -472,7 +481,16 @@ function goToNextStep(wizard, options, state)
472
481
**/
473
482
function goToPreviousStep ( wizard , options , state )
474
483
{
475
- return paginationClick ( wizard , options , state , decreaseCurrentIndexBy ( state , 1 ) ) ;
484
+ // Determine previous active step
485
+ var newIndex = decreaseCurrentIndexBy ( state , 1 ) ;
486
+ do {
487
+ if ( typeof state . disabledSteps == 'undefined' || $ . inArray ( newIndex , state . disabledSteps ) == - 1 ) {
488
+ break ; //found an index that is not disabled => stop the loop
489
+ }
490
+ newIndex -- ;
491
+ } while ( true ) ;
492
+
493
+ return paginationClick ( wizard , options , state , newIndex ) ;
476
494
}
477
495
478
496
/**
@@ -1482,6 +1500,48 @@ $.fn.steps.setCurrentIndex = function (index)
1482
1500
return goToStep ( this , options , state , index ) ;
1483
1501
} ;
1484
1502
1503
+ /**
1504
+ * Disable a step so that it will be skipped on going to Next and Previous
1505
+ *
1506
+ * @method disableStep
1507
+ * @param index {Integer} Index number of the step to disable
1508
+ * @return {Boolean } Indicates whether the action executed
1509
+ **/
1510
+ $ . fn . steps . disableStep = function ( index )
1511
+ {
1512
+ var state = getState ( this ) ;
1513
+
1514
+ if ( typeof state . disabledSteps == 'undefined' ) {
1515
+ state . disabledSteps = [ ] ;
1516
+ }
1517
+ if ( $ . inArray ( index , state . disabledSteps ) == - 1 ) {
1518
+ state . disabledSteps . push ( index ) ;
1519
+ return true ;
1520
+ }
1521
+ return false ;
1522
+ } ;
1523
+
1524
+ /**
1525
+ * Enable a step that was previously disabled
1526
+ *
1527
+ * @method enableStep
1528
+ * @param index {Integer} Index number of the step to re-enable
1529
+ * @return {Boolean } Indicates whether the action executed
1530
+ **/
1531
+ $ . fn . steps . enableStep = function ( index )
1532
+ {
1533
+ var state = getState ( this ) ;
1534
+
1535
+ if ( typeof state . disabledSteps != 'undefined' ) {
1536
+ var arrayIndex = $ . inArray ( index , state . disabledSteps ) ;
1537
+ if ( arrayIndex > - 1 ) {
1538
+ state . disabledSteps . splice ( arrayIndex , 1 ) ;
1539
+ return true ;
1540
+ }
1541
+ }
1542
+ return false ;
1543
+ } ;
1544
+
1485
1545
/**
1486
1546
* An enum represents the different content types of a step and their loading mechanisms.
1487
1547
*
0 commit comments