Skip to content

Commit ddc1696

Browse files
committed
Update and rename jquery.steps-0.8.0.js to jquery.steps.js
Transition bug removed
1 parent fc3294e commit ddc1696

File tree

1 file changed

+35
-26
lines changed

1 file changed

+35
-26
lines changed

jquery.steps-0.8.0.js renamed to jquery.steps.js

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* jQuery Steps Plugin v0.8.0 - A powerful jQuery wizard plugin that supports accessibility and HTML5
2+
* jQuery Steps Plugin v0.8.1 - A powerful jQuery wizard plugin that supports accessibility and HTML5
33
* https://github.com/rstaib/jquery-steps
44
*
55
* Copyright (c) 2013 Rafael J. Staib
@@ -17,12 +17,13 @@
1717
* - Implement preloadContent for async and iframe content types.
1818
* - Implement slideLeft animation
1919
* - Implement functionality to skip a certain amount of steps
20+
* - Add insert and remove step method
2021
*/
2122

2223

2324
(function ($)
2425
{
25-
var uid = 0;
26+
var uniqueId = 0;
2627

2728
/// <summary>
2829
///
@@ -130,7 +131,7 @@
130131
currentIndex: opts.startIndex,
131132
currentStep: null,
132133
stepCount: 0,
133-
transitionLock: false
134+
transitionShowElement: null
134135
});
135136
createUniqueId($this);
136137

@@ -339,15 +340,9 @@
339340
var options = wizard.data("options");
340341
var state = wizard.data("state");
341342

342-
if (state.transitionLock)
343-
{
344-
return;
345-
}
346-
347343
if (index < 0 || index >= state.stepCount || state.stepCount == 0)
348344
{
349-
//TODO: Change to a better error message
350-
throw new "Index out of range exception!";
345+
throw new "Index out of range.";
351346
}
352347

353348
if (options.forceMoveForward && index < state.currentIndex)
@@ -374,21 +369,33 @@
374369
switch (options.transitionEffect)
375370
{
376371
case $.fn.steps.transitionEffect.fade:
377-
state.transitionLock = true;
372+
state.transitionShowElement = stepContents.eq(index);
378373
stepContents.eq(oldIndex).fadeOut(options.transitionEffectSpeed, function ()
379374
{
380-
stepContents.eq(index).fadeIn(options.transitionEffectSpeed,
381-
function () { state.transitionLock = false; });
382-
});
375+
var wizard = $(this).parents(".wizard");
376+
var state = wizard.data("state");
377+
378+
if (state.transitionShowElement)
379+
{
380+
state.transitionShowElement.fadeIn(options.transitionEffectSpeed);
381+
state.transitionShowElement = null;
382+
}
383+
}).promise();
383384
break;
384385

385386
case $.fn.steps.transitionEffect.slide:
386-
state.transitionLock = true;
387+
state.transitionShowElement = stepContents.eq(index);
387388
stepContents.eq(oldIndex).slideUp(options.transitionEffectSpeed, function ()
388389
{
389-
stepContents.eq(index).slideDown(options.transitionEffectSpeed,
390-
function () { state.transitionLock = false; });
391-
});
390+
var wizard = $(this).parents(".wizard");
391+
var state = wizard.data("state");
392+
393+
if (state.transitionShowElement)
394+
{
395+
state.transitionShowElement.slideDown(options.transitionEffectSpeed);
396+
state.transitionShowElement = null;
397+
}
398+
}).promise();
392399
break;
393400

394401
//case $.fn.steps.transitionEffect.slideLeft:
@@ -435,10 +442,13 @@
435442
stepContents.not(":eq(" + options.startIndex + ")").hide();
436443
stepContents.eq(options.startIndex).show();
437444

438-
if (stepTitles.length !== stepContents.length)
445+
if (stepTitles.length > stepContents.length)
446+
{
447+
throw new "One or more corresponding step contents are missing.";
448+
}
449+
else if (stepTitles.length < stepContents.length)
439450
{
440-
//TODO: Change to a better error message
441-
throw new "Each title has to have a relating content part and vise versa!";
451+
throw new "One or more corresponding step titles are missing.";
442452
}
443453

444454
var stepsWrapper = $(document.createElement(options.stepsContainerTag)).addClass("steps");
@@ -641,8 +651,7 @@
641651
{
642652
if (substitutes[key] === undefined)
643653
{
644-
//TODO: Change to a better error message
645-
throw new "Substitute key \"" + key + "\" does not exist!";
654+
throw new "The key \"" + key + "\" does not exist in the substitute collection!";
646655
}
647656

648657
return substitutes[key];
@@ -673,18 +682,18 @@
673682
}
674683

675684
/// <summary>
676-
///
685+
/// Creates an unique id and adds this to the corresponding wizard instance.
677686
/// </summary>
678687
function createUniqueId(wizard)
679688
{
680689
if (wizard.attr("data-uid") === undefined)
681690
{
682-
wizard.attr("data-uid", "steps-uid-" + ++uid);
691+
wizard.attr("data-uid", "steps-uid-" + ++uniqueId);
683692
}
684693
}
685694

686695
/// <summary>
687-
///
696+
/// Retrieves the unique id from the given wizard instance.
688697
/// </summary>
689698
/// <returns></returns>
690699
function getUniqueId(wizard)

0 commit comments

Comments
 (0)