8000 Merge pull request #1 from winternet-studio/master · MichiPueh/jquery-steps@cc603e3 · GitHub
Skip to content

Commit cc603e3

Browse files
committed
Merge pull request #1 from winternet-studio/master
Pulling from forked repo in own forked repo.
2 parents 4e1078b + 8df104f commit cc603e3

File tree

1 file changed

+77
-2
lines changed

1 file changed

+77
-2
lines changed

build/jquery.steps.js

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,16 @@ function getValidEnumValue(enumType, keyOrValue)
456456
**/
457457
function goToNextStep(wizard, options, state)
458458
{
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);
460469
}
461470

462471
/**
@@ -472,7 +481,16 @@ function goToNextStep(wizard, options, state)
472481
**/
473482
function goToPreviousStep(wizard, options, state)
474483
{
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);
476494
}
477495

478496
/**
@@ -1474,6 +1492,63 @@ $.fn.steps.skip = function (count)
14741492
throw new Error("Not yet implemented!");
14751493
};
14761494

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+
14771552
/**
14781553
* An enum represents the different content types of a step and their loading mechanisms.
14791554
*

0 commit comments

Comments
 (0)