@@ -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
/**
@@ -1474,6 +1492,63 @@ $.fn.steps.skip = function (count)
1474
1492
throw new Error ( "Not yet implemented!" ) ;
1475
1493
} ;
1476
1494
1495
+ /**
1496
+ * Sets the current step index.
1497
+ *
1498
+ * @method setCurrentIndex
1499
+ * @param index {Integer} The new step index (zero-based)
1500
+ * @return {Boolean } Indicates whether the action executed
1501
+ **/
1502
+ $ . fn . steps . setCurrentIndex = function ( index )
1503
+ {
1504
+ var options = getOptions ( this ) ,
1505
+ state = getState ( this ) ;
1506
+
1507
+ return goToStep ( this , options , state , index ) ;
1508
+ } ;
1509
+
1510
+ /**
1511
+ * Disable a step so that it will be skipped on going to Next and Previous
1512
+ *
1513
+ * @method disableStep
1514
+ * @param index {Integer} Index number of the step to disable
1515
+ * @return {Boolean } Indicates whether the action executed
1516
+ **/
1517
+ $ . fn . steps . disableStep = function ( index )
1518
+ {
1519
+ var state = getState ( this ) ;
1520
+
1521
+ if ( typeof state . disabledSteps == 'undefined' ) {
1522
+ state . disabledSteps = [ ] ;
1523
+ }
1524
+ if ( $ . inArray ( index , state . disabledSteps ) == - 1 ) {
1525
+ state . disabledSteps . push ( index ) ;
1526
+ return true ;
1527
+ }
1528
+ return false ;
1529
+ } ;
1530
+
1531
+ /**
1532
+ * Enable a step that was previously disabled
1533
+ *
1534
+ * @method enableStep
1535
+ * @param index {Integer} Index number of the step to re-enable
1536
+ * @return {Boolean } Indicates whether the action executed
1537
+ **/
1538
+ $ . fn . steps . enableStep = function ( index )
1539
+ {
1540
+ var state = getState ( this ) ;
1541
+
1542
+ if ( typeof state . disabledSteps != 'undefined' ) {
1543
+ var arrayIndex = $ . inArray ( index , state . disabledSteps ) ;
1544
+ if ( arrayIndex > - 1 ) {
1545
+ state . disabledSteps . splice ( arrayIndex , 1 ) ;
1546
+ return true ;
1547
+ }
1548
+ }
1549
+ return false ;
1550
+ } ;
1551
+
1477
1552
/**
1478
1553
* An enum represents the different content types of a step and their loading mechanisms.
1479
1554
*
0 commit comments