Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 1.0.8
- Small fix. Closes issue [#88](https://github.com/rstaib/jquery-steps/issues/88)

## 1.0.7
- Small fix. Closes issue [#58](https://github.com/rstaib/jquery-steps/issues/58)
- Set the default value of `enableCancelButton` for backward compatibility reasons to `false`
Expand Down
8 changes: 4 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = function (grunt)
separator: '\r\n\r\n',
banner: '/*! <%= "\\r\\n * " + pkg.title %> v<%= pkg.version %> - <%= grunt.template.today("mm/dd/yyyy") + "\\r\\n" %>' +
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %> <%= (pkg.homepage ? "(" + pkg.homepage + ")" : "") + "\\r\\n" %>' +
' * Licensed under <%= pkg.licenses[0].type + " " + pkg.licenses[0].url + "\\r\\n */\\r\\n" %>' +
' * Licensed under <%= pkg.licenses[0].type + " " + pkg.licenses[0].url + "\\r\\n */\\r\\n" %>' +
';(function ($, undefined)\r\n{\r\n',
footer: '\r\n})(jQuery);'
},
Expand Down Expand Up @@ -150,7 +150,7 @@ module.exports = function (grunt)
grunt.loadNpmTasks('grunt-exec');

grunt.registerTask('default', ['build']);
grunt.registerTask('api', ['clean:api', 'yuidoc']);
grunt.registerTask('api', ['clean:api']);
grunt.registerTask('build', ['clean:build', 'concat', 'jshint', 'qunit']);
grunt.registerTask('release', ['build', 'api', 'uglify', 'compress', 'exec:createPkg']);
};
grunt.registerTask('release', ['build', 'api', 'uglify', 'compress']);
};
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"tabs",
"steps"
],
"version": "1.0.7",
"version": "1.0.8",
"authors": [
{ "name": "Rafael Staib", "email": "me@rafaelstaib.com", "url": "http://www.rafaelstaib.com" }
],
Expand Down Expand Up @@ -44,4 +44,4 @@
"dependencies": {
"jquery": "1.10.2"
}
}
}
Binary file removed build/jQuery.Steps.1.0.7.nupkg
Binary file not shown.
Binary file removed build/jquery.steps-1.0.7.zip
Binary file not shown.
Binary file added build/jquery.steps-1.0.8.zip
Binary file not shown.
86 changes: 55 additions & 31 deletions build/jquery.steps.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* jQuery Steps v1.0.7 - 05/07/2014
* jQuery Steps v1.0.8 - 09/02/2014
* Copyright (c) 2014 Rafael Staib (http://www.jquery-steps.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
Expand Down Expand Up @@ -159,7 +159,7 @@ function analyzeData(wizard, options, state)
{
throwError(_missingCorrespondingElementErrorMessage, "titles");
}

var startIndex = options.startIndex;

state.stepCount = stepTitles.length;
Expand All @@ -168,7 +168,7 @@ function analyzeData(wizard, options, state)
if (options.saveState && $.cookie)
{
var savedState = $.cookie(_cookiePrefix + getUniqueId(wizard));
// Sets the saved position to the start index if not undefined or out of range
// Sets the saved position to the start index if not undefined or out of range
var savedIndex = parseInt(savedState, 0);
if (!isNaN(savedIndex) && savedIndex < state.stepCount)
{
Expand Down Expand Up @@ -400,7 +400,7 @@ function getUniqueId(wizard)

/**
* Gets a valid enum value by checking a specific enum key or value.
*
*
* @static
* @private
* @method getValidEnumValue
Expand Down Expand Up @@ -487,8 +487,12 @@ function goToPreviousStep(wizard, options, state)
* @param index {Integer} The position (zero-based) to route to
* @return {Boolean} Indicates whether the action succeeded or failed
**/
function goToStep(wizard, options, state, index)
function goToStep(wizard, options, state, index, skipEvent)
{
if (typeof skipEvent === 'undefined') {
skipEvent = false;
}

if (index < 0 || index >= state.stepCount)
{
throwError(_indexOutOfRangeErrorMessage);
Expand All @@ -500,7 +504,11 @@ function goToStep(wizard, options, state, index)
}

var oldIndex = state.currentIndex;
if (wizard.triggerHandler("stepChanging", [state.currentIndex, index]))
var eventResult = true;
if (!skipEvent) {
eventResult = wizard.triggerHandler("stepChanging", [state.currentIndex, index]);
}
if (eventResult)
{
// Save new state
state.currentIndex = index;
Expand All @@ -509,10 +517,15 @@ function goToStep(wizard, options, state, index)
// Change visualisation
refreshStepNavigation(wizard, options, state, oldIndex);
refreshPagination(wizard, options, state);
loadAsyncContent(wizard, options, state);
startTransitionEffect(wizard, options, state, index, oldIndex);

wizard.triggerHandler("stepChanged", [index, oldIndex]);
$.when(loadAsyncContent(wizard, options, state)).then(
function() {
startTransitionEffect(wizard, options, state, index, oldIndex);
wizard.triggerHandler("stepChanged", [index, oldIndex]);
},
function() {
// TODO add error handler
}
);
}
else
{
Expand Down Expand Up @@ -714,11 +727,10 @@ function loadAsyncContent(wizard, options, state)
var currentStepContent = getStepPanel(wizard, state.currentIndex)._aria("busy", "true")
.empty().append(renderTemplate(options.loadingTemplate, { text: options.labels.loading }));

$.ajax({ url: currentStep.contentUrl, cache: false }).done(function (data)
return $.ajax({ url: currentStep.contentUrl, cache: false }).done(function (data)
{
currentStepContent.empty().html(data)._aria("busy", "false").data("loaded", "1");
});
break;
}
}
}
Expand Down Expand Up @@ -950,13 +962,13 @@ function removeStep(wizard, options, state, index)
getStepPanel(wizard, index).remove();
getStepAnchor(wizard, index).parent().remove();

// Set the "first" class to the new first step button
// Set the "first" class to the new first step button
if (index === 0)
{
wizard.find(".steps li").first().addClass("first");
}

// Set the "last" class to the new last step button
// Set the "last" class to the new last step button
if (index === state.stepCount)
{
wizard.find(".steps li").eq(index).addClass("last");
Expand Down Expand Up @@ -1092,7 +1104,7 @@ function renderTemplate(template, substitutes)

for (var i = 0; i < matches.length; i++)
{
var match = matches[i],
var match = matches[i],
key = match.substring(1, match.length - 1);

if (substitutes[key] === undefined)
Expand Down Expand Up @@ -1129,12 +1141,12 @@ function renderTitle(wizard, options, state, header, index)
index: index + 1,
title: header.html()
}),
stepItem = $("<li role=\"tab\"><a id=\"" + uniqueStepId + "\" href=\"#" + uniqueHeaderId +
stepItem = $("<li role=\"tab\"><a id=\"" + uniqueStepId + "\" href=\"#" + uniqueHeaderId +
"\" aria-controls=\"" + uniqueBodyId + "\">" + title + "</a></li>");

stepItem._enableAria(options.enableAllSteps || state.currentIndex > index);

if (state.currentIndex > index)
if (state.currentIndex > index || options.enableAllSteps)
{
stepItem.addClass("done");
}
Expand Down Expand Up @@ -1221,7 +1233,7 @@ function startTransitionEffect(wizard, options, state, index, oldIndex)
posFadeOut = (index > oldIndex) ? -(outerWidth) : outerWidth,
posFadeIn = (index > oldIndex) ? outerWidth : -(outerWidth);

currentStep.animate({ left: posFadeOut }, effectSpeed,
currentStep.animate({ left: posFadeOut }, effectSpeed,
function () { $(this)._showAria(false); }).promise();
newStep.css("left", posFadeIn + "px")._showAria()
.animate({ left: 0 }, effectSpeed).promise();
Expand Down Expand Up @@ -1295,6 +1307,7 @@ function validateArgument(argumentName, argumentValue)
}
}


/**
* Represents a jQuery wizard plugin.
*
Expand Down Expand Up @@ -1450,9 +1463,18 @@ $.fn.steps.remove = function (index)
* @param index {Integer} An integer that belongs to the position of a step
* @param step {Object} The step object to change
**/
$.fn.steps.setStep = function (index, step)
$.fn.steps.setStep = function (index, skipEvent)
{
throw new Error("Not yet implemented!");
var state = getState(this);
if ( index < 0 || state && index > state.stepCount) {
return;
}
var range = Array.apply(null, new Array(index)).map(function (_, i) {return i;});
$.each(range, function(stepIndex) {
$('#steps-t-' + stepIndex).parent().removeClass('disabled').addClass('done');
});

return goToStep(this, getOptions(this), state, index, skipEvent);
};

/**
Expand All @@ -1467,6 +1489,7 @@ $.fn.steps.skip = function (count)
throw new Error("Not yet implemented!");
};


/**
* An enum represents the different content types of a step and their loading mechanisms.
*
Expand Down Expand Up @@ -1719,7 +1742,7 @@ var defaults = $.fn.steps.defaults = {
*/

/**
* Sets the focus to the first wizard instance in order to enable the key navigation from the begining if `true`.
* Sets the focus to the first wizard instance in order to enable the key navigation from the begining if `true`.
*
* @property autoFocus
* @type Boolean
Expand Down Expand Up @@ -1810,7 +1833,7 @@ var defaults = $.fn.steps.defaults = {
preloadContent: false,

/**
* Shows the finish button always (on each step; right beside the next button) if `true`.
* Shows the finish button always (on each step; right beside the next button) if `true`.
* Otherwise the next button will be replaced by the finish button if the last step becomes active.
*
* @property showFinishButtonAlways
Expand Down Expand Up @@ -1880,8 +1903,8 @@ var defaults = $.fn.steps.defaults = {
*/

/**
* Fires before the step changes and can be used to prevent step changing by returning `false`.
* Very useful for form validation.
* Fires before the step changes and can be used to prevent step changing by returning `false`.
* Very useful for form validation.
*
* @property onStepChanging
* @type Event
Expand All @@ -1891,7 +1914,7 @@ var defaults = $.fn.steps.defaults = {
onStepChanging: function (event, currentIndex, newIndex) { return true; },

/**
* Fires after the step has change.
* Fires after the step has change.
*
* @property onStepChanged
* @type Event
Expand All @@ -1901,7 +1924,7 @@ var defaults = $.fn.steps.defaults = {
onStepChanged: function (event, currentIndex, priorIndex) { },

/**
* Fires after cancelation.
* Fires after cancelation.
*
* @property onCanceled
* @type Event
Expand All @@ -1911,8 +1934,8 @@ var defaults = $.fn.steps.defaults = {
onCanceled: function (event) { },

/**
* Fires before finishing and can be used to prevent completion by returning `false`.
* Very useful for form validation.
* Fires before finishing and can be used to prevent completion by returning `false`.
* Very useful for form validation.
*
* @property onFinishing
* @type Event
Expand All @@ -1922,7 +1945,7 @@ var defaults = $.fn.steps.defaults = {
onFinishing: function (event, currentIndex) { return true; },

/**
* Fires after completion.
* Fires after completion.
*
* @property onFinished
* @type Event
Expand All @@ -1932,7 +1955,7 @@ var defaults = $.fn.steps.defaults = {
onFinished: function (event, currentIndex) { },

/**
* Contains all labels.
* Contains all labels.
*
* @property labels
* @type Object
Expand Down Expand Up @@ -2012,4 +2035,5 @@ var defaults = $.fn.steps.defaults = {
loading: "Loading ..."
}
};

})(jQuery);
Loading