diff --git a/CHANGELOG.md b/CHANGELOG.md index e1d6fb8..0fc2821 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Changelog +## 1.1.0 +- Added event `onInit` which is fired when the component is completely initialized. Closes issue [#80](https://github.com/rstaib/jquery-steps/issues/80) +- Added event `onContentLoaded` which is fired when the step content is loaded (only in async cases relevant) Closes issue [#88](https://github.com/rstaib/jquery-steps/issues/88) and [#97](https://github.com/rstaib/jquery-steps/issues/97) + +## 1.0.8 +- Fixed issue [#91](https://github.com/rstaib/jquery-steps/issues/91) (`stepChanged` event is fired before transitions are done) + +## 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` + +## 1.0.6 +- Small fix. Closes issue [#56](https://github.com/rstaib/jquery-steps/issues/56) + +## 1.0.5 + +- Added a cancel button +- Fixed a bug regarding adding steps dynamically. Closes issue [#56](https://github.com/rstaib/jquery-steps/issues/56) + ## 1.0.4 - Fixed an issue regarding currentIndex on finish and finished event. Closes issue [#24](https://github.com/rstaib/jquery-steps/issues/24) and [#33](https://github.com/rstaib/jquery-steps/issues/33) diff --git a/Gruntfile.js b/Gruntfile.js index 4bd4db2..4e6b3f5 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -19,12 +19,12 @@ module.exports = function (grunt) dist: { files: { '<%= pkg.folders.dist %>/jquery.steps.js': [ + '<%= pkg.folders.src %>/helper.js', '<%= pkg.folders.src %>/privates.js', '<%= pkg.folders.src %>/publics.js', '<%= pkg.folders.src %>/enums.js', '<%= pkg.folders.src %>/model.js', - '<%= pkg.folders.src %>/defaults.js', - '<%= pkg.folders.src %>/helper.js' + '<%= pkg.folders.src %>/defaults.js' ] } } diff --git a/README.md b/README.md index a4c49e1..e7273bd 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -jQuery Steps Plugin [![Build Status](https://www.travis-ci.org/rstaib/jquery-steps.png?branch=master)](https://www.travis-ci.org/rstaib/jquery-steps) +jQuery Steps Plugin [![Build Status](https://travis-ci.org/rstaib/jquery-steps.svg?branch=master)](https://travis-ci.org/rstaib/jquery-steps) [![Bower version](https://badge.fury.io/bo/jquery.steps.svg)](http://badge.fury.io/bo/jquery.steps) [![NuGet version](https://badge.fury.io/nu/jquery.steps.svg)](http://badge.fury.io/nu/jquery.steps) ============ A powerful jQuery wizard plugin that supports accessibility and HTML5. diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..7b63e2b --- /dev/null +++ b/bower.json @@ -0,0 +1,47 @@ +{ + "name": "jquery.steps", + "description": "A powerful jQuery wizard plugin that supports accessibility and HTML5.", + "keywords": [ + "wizard", + "navigation", + "forms", + "UI", + "component", + "HTML5", + "accessibility", + "validation", + "tabs", + "steps" + ], + "version": "1.1.0", + "authors": [ + { "name": "Rafael Staib", "email": "me@rafaelstaib.com", "url": "http://www.rafaelstaib.com" } + ], + "homepage": "http://www.jquery-steps.com", + "repository": { + "type": "git", + "url": "git://github.com/rstaib/jquery-steps.git" + }, + "license": "MIT", + "main": [ + "build/jquery.steps.js", + "demo/css/jquery.steps.css" + ], + "ignore": [ + "**/.*", + "build/*.nupkg", + "build/*.zip", + "lib", + "nuget", + "src", + "test", + "*.md", + "*.txt", + "Gruntfile.js", + "package.json", + "steps.jquery.json" + ], + "dependencies": { + "jquery": ">=1.9.0" + } +} diff --git a/build/jQuery.Steps.1.0.4.nupkg b/build/jQuery.Steps.1.0.4.nupkg deleted file mode 100644 index b716084..0000000 Binary files a/build/jQuery.Steps.1.0.4.nupkg and /dev/null differ diff --git a/build/jQuery.Steps.1.1.0.nupkg b/build/jQuery.Steps.1.1.0.nupkg new file mode 100644 index 0000000..4f52e85 Binary files /dev/null and b/build/jQuery.Steps.1.1.0.nupkg differ diff --git a/build/jquery.steps-1.0.4.zip b/build/jquery.steps-1.0.4.zip deleted file mode 100644 index 781e94f..0000000 Binary files a/build/jquery.steps-1.0.4.zip and /dev/null differ diff --git a/build/jquery.steps-1.1.0.zip b/build/jquery.steps-1.1.0.zip new file mode 100644 index 0000000..b762d08 Binary files /dev/null and b/build/jquery.steps-1.1.0.zip differ diff --git a/build/jquery.steps.js b/build/jquery.steps.js index 9929e76..956b05a 100644 --- a/build/jquery.steps.js +++ b/build/jquery.steps.js @@ -1,10 +1,63 @@ /*! - * jQuery Steps v1.0.4 - 12/17/2013 - * Copyright (c) 2013 Rafael Staib (http://www.jquery-steps.com) + * jQuery Steps v1.1.0 - 09/04/2014 + * Copyright (c) 2014 Rafael Staib (http://www.jquery-steps.com) * Licensed under MIT http://www.opensource.org/licenses/MIT */ ;(function ($, undefined) { +$.fn.extend({ + _aria: function (name, value) + { + return this.attr("aria-" + name, value); + }, + + _removeAria: function (name) + { + return this.removeAttr("aria-" + name); + }, + + _enableAria: function (enable) + { + return (enable == null || enable) ? + this.removeClass("disabled")._aria("disabled", "false") : + this.addClass("disabled")._aria("disabled", "true"); + }, + + _showAria: function (show) + { + return (show == null || show) ? + this.show()._aria("hidden", "false") : + this.hide()._aria("hidden", "true"); + }, + + _selectAria: function (select) + { + return (select == null || select) ? + this.addClass("current")._aria("selected", "true") : + this.removeClass("current")._aria("selected", "false"); + }, + + _id: function (id) + { + return (id) ? this.attr("id", id) : this.attr("id"); + } +}); + +if (!String.prototype.format) +{ + String.prototype.format = function() + { + var args = (arguments.length === 1 && $.isArray(arguments[0])) ? arguments[0] : arguments; + var formattedString = this; + for (var i = 0; i < args.length; i++) + { + var pattern = new RegExp("\\{" + i + "\\}", "gm"); + formattedString = formattedString.replace(pattern, args[i]); + } + return formattedString; + }; +} + /** * A global unique id count. * @@ -147,6 +200,19 @@ function analyzeData(wizard, options, state) }); } +/** + * Triggers the onCanceled event. + * + * @static + * @private + * @method cancel + * @param wizard {Object} The jQuery wizard object + **/ +function cancel(wizard) +{ + wizard.triggerHandler("canceled"); +} + function decreaseCurrentIndexBy(state, decreaseBy) { return state.currentIndex - decreaseBy; @@ -185,12 +251,12 @@ function destroy(wizard, options) // Empty panels if the mode is set to 'async' or 'iframe' wizard.find(".content > [data-mode='async'],.content > [data-mode='iframe']").empty(); - var wizardSubstitute = $(format("<{0} class=\"{1}\">", wizard.get(0).tagName, wizard.attr("class"))); + var wizardSubstitute = $("<{0} class=\"{1}\">".format(wizard.get(0).tagName, wizard.attr("class"))); - var wizardId = wizard._getId(); + var wizardId = wizard._id(); if (wizardId != null && wizardId !== "") { - wizardSubstitute._setId(wizardId); + wizardSubstitute._id(wizardId); } wizardSubstitute.html(wizard.find(".content").html()); @@ -224,18 +290,6 @@ function finishStep(wizard, state) } } -function format(value) -{ - for (var i = 1; i < arguments.length; i++) - { - var index = (i - 1); - var pattern = new RegExp("\\{" + index + "\\}", "gm"); - value = value.replace(pattern, arguments[i]); - } - - return value; -} - /** * Gets or creates if not exist an unique event namespace for the given wizard instance. * @@ -330,11 +384,11 @@ function getUniqueId(wizard) if (uniqueId == null) { - uniqueId = wizard._getId(); + uniqueId = wizard._id(); if (uniqueId == null) { uniqueId = "steps-uid-".concat(_uniqueId); - wizard._setId(uniqueId); + wizard._id(uniqueId); } _uniqueId++; @@ -456,9 +510,10 @@ function goToStep(wizard, options, state, index) refreshStepNavigation(wizard, options, state, oldIndex); refreshPagination(wizard, options, state); loadAsyncContent(wizard, options, state); - startTransitionEffect(wizard, options, state, index, oldIndex); - - wizard.triggerHandler("stepChanged", [index, oldIndex]); + startTransitionEffect(wizard, options, state, index, oldIndex, function() + { + wizard.triggerHandler("stepChanged", [index, oldIndex]); + }); } else { @@ -510,6 +565,8 @@ function initialize(options) { getStepAnchor(wizard, opts.startIndex).focus(); } + + wizard.triggerHandler("init", [opts.startIndex]); }); } @@ -545,7 +602,7 @@ function insertStep(wizard, options, state, index, step) // Change data step = $.extend({}, stepModel, step); insertStepToCache(wizard, index, step); - if (state.currentIndex >= index) + if (state.currentIndex !== state.stepCount && state.currentIndex >= index) { state.currentIndex++; saveCurrentStateToCookie(wizard, options, state); @@ -553,8 +610,8 @@ function insertStep(wizard, options, state, index, step) state.stepCount++; var contentContainer = wizard.find(".content"), - header = $(format("<{0}>{1}", options.headerTag, step.title)), - body = $(format("<{0}>", options.bodyTag)); + header = $("<{0}>{1}".format(options.headerTag, step.title)), + body = $("<{0}>".format(options.bodyTag)); if (step.contentMode == null || step.contentMode === contentMode.html) { @@ -570,9 +627,13 @@ function insertStep(wizard, options, state, index, step) getStepPanel(wizard, (index - 1)).after(body).after(header); } - renderBody(wizard, body, index); + renderBody(wizard, state, body, index); renderTitle(wizard, options, state, header, index); refreshSteps(wizard, options, state, index); + if (index === state.currentIndex) + { + refreshStepNavigation(wizard, options, state); + } refreshPagination(wizard, options, state); return wizard; @@ -640,7 +701,8 @@ function loadAsyncContent(wizard, options, state) { if (state.stepCount > 0) { - var currentStep = getStep(wizard, state.currentIndex); + var currentIndex = state.currentIndex, + currentStep = getStep(wizard, currentIndex); if (!options.enableContentCache || !currentStep.contentLoaded) { @@ -653,12 +715,13 @@ function loadAsyncContent(wizard, options, state) break; case contentMode.async: - var currentStepContent = getStepPanel(wizard, state.currentIndex)._aria("busy", "true") + var currentStepContent = getStepPanel(wizard, currentIndex)._aria("busy", "true") .empty().append(renderTemplate(options.loadingTemplate, { text: options.labels.loading })); $.ajax({ url: currentStep.contentUrl, cache: false }).done(function (data) { currentStepContent.empty().html(data)._aria("busy", "false").data("loaded", "1"); + wizard.triggerHandler("contentLoaded", [currentIndex]); }); break; } @@ -696,7 +759,7 @@ function paginationClick(wizard, options, state, index) if (oldIndex === state.currentIndex && isDisabled) { // Disable the step again if current index has not changed; prevents click action. - parent._disableAria(); + parent._enableAria(false); return false; } @@ -724,17 +787,21 @@ function paginationClickHandler(event) state = getState(wizard), href = anchor.attr("href"); - switch (href.substring(href.lastIndexOf("#"))) + switch (href.substring(href.lastIndexOf("#") + 1)) { - case "#finish": + case "cancel": + cancel(wizard); + break; + + case "finish": finishStep(wizard, state); break; - case "#next": + case "next": goToNextStep(wizard, options, state); break; - case "#previous": + case "previous": goToPreviousStep(wizard, options, state); break; } @@ -760,55 +827,19 @@ function refreshPagination(wizard, options, state) if (!options.forceMoveForward) { var previous = wizard.find(".actions a[href$='#previous']").parent(); - if (state.currentIndex > 0) - { - previous._enableAria(); - } - else - { - previous._disableAria(); - } + previous._enableAria(state.currentIndex > 0); } if (options.enableFinishButton && options.showFinishButtonAlways) { - if (state.stepCount === 0) - { - finish._disableAria(); - next._disableAria(); - } - else if (state.stepCount > 1 && state.stepCount > (state.currentIndex + 1)) - { - finish._enableAria(); - next._enableAria(); - } - else - { - finish._enableAria(); - next._disableAria(); - } + finish._enableAria(state.stepCount > 0); + next._enableAria(state.stepCount > 1 && state.stepCount > (state.currentIndex + 1)); } else { - if (state.stepCount === 0) - { - finish._hideAria(); - next._showAria()._disableAria(); - } - else if (state.stepCount > (state.currentIndex + 1)) - { - finish._hideAria(); - next._showAria()._enableAria(); - } - else if (!options.enableFinishButton) - { - next._disableAria(); - } - else - { - finish._showAria(); - next._hideAria(); - } + finish._showAria(options.enableFinishButton && state.stepCount === (state.currentIndex + 1)); + next._showAria(state.stepCount === 0 || state.stepCount > (state.currentIndex + 1)). + _enableAria(state.stepCount > (state.currentIndex + 1) || !options.enableFinishButton); } } } @@ -833,7 +864,7 @@ function refreshStepNavigation(wizard, options, state, oldIndex) if (oldIndex != null) { var oldStepAnchor = getStepAnchor(wizard, oldIndex); - oldStepAnchor.parent().addClass("done").removeClass("error")._deselectAria(); + oldStepAnchor.parent().addClass("done").removeClass("error")._selectAria(false); stepTitles.eq(oldIndex).removeClass("current").next(".body").removeClass("current"); currentInfo = oldStepAnchor.find(".current-info"); currentOrNewStepAnchor.focus(); @@ -863,12 +894,12 @@ function refreshSteps(wizard, options, state, index) var uniqueStepId = uniqueId + _tabSuffix + i, uniqueBodyId = uniqueId + _tabpanelSuffix + i, uniqueHeaderId = uniqueId + _titleSuffix + i, - title = wizard.find(".title").eq(i)._setId(uniqueHeaderId); + title = wizard.find(".title").eq(i)._id(uniqueHeaderId); - wizard.find(".steps a").eq(i)._setId(uniqueStepId) + wizard.find(".steps a").eq(i)._id(uniqueStepId) ._aria("controls", uniqueBodyId).attr("href", "#" + uniqueHeaderId) .html(renderTemplate(options.titleTemplate, { index: i + 1, title: title.html() })); - wizard.find(".body").eq(i)._setId(uniqueBodyId) + wizard.find(".body").eq(i)._id(uniqueBodyId) ._aria("labelledby", uniqueHeaderId); } } @@ -877,8 +908,11 @@ function registerEvents(wizard, options) { var eventNamespace = getEventNamespace(wizard); + wizard.bind("canceled" + eventNamespace, options.onCanceled); + wizard.bind("contentLoaded" + eventNamespace, options.onContentLoaded); wizard.bind("finishing" + eventNamespace, options.onFinishing); wizard.bind("finished" + eventNamespace, options.onFinished); + wizard.bind("init" + eventNamespace, options.onInit); wizard.bind("stepChanging" + eventNamespace, options.onStepChanging); wizard.bind("stepChanged" + eventNamespace, options.onStepChanged); @@ -962,8 +996,8 @@ function render(wizard, options, state) var wrapperTemplate = "<{0} class=\"{1}\">{2}", orientation = getValidEnumValue(stepsOrientation, options.stepsOrientation), verticalCssClass = (orientation === stepsOrientation.vertical) ? " vertical" : "", - contentWrapper = $(format(wrapperTemplate, options.contentContainerTag, "content " + options.clearFixCssClass, wizard.html())), - stepsWrapper = $(format(wrapperTemplate, options.stepsContainerTag, "steps " + options.clearFixCssClass, "")), + contentWrapper = $(wrapperTemplate.format(options.contentContainerTag, "content " + options.clearFixCssClass, wizard.html())), + stepsWrapper = $(wrapperTemplate.format(options.stepsContainerTag, "steps " + options.clearFixCssClass, "")), stepTitles = contentWrapper.children(options.headerTag), stepContents = contentWrapper.children(options.bodyTag); @@ -974,12 +1008,9 @@ function render(wizard, options, state) // Add WIA-ARIA support stepContents.each(function (index) { - renderBody(wizard, $(this), index); + renderBody(wizard, state, $(this), index); }); - // Make the start step visible - stepContents.eq(state.currentIndex)._showAria(); - stepTitles.each(function (index) { renderTitle(wizard, options, state, $(this), index); @@ -999,14 +1030,14 @@ function render(wizard, options, state) * @param body {Object} A jQuery body object * @param index {Integer} The position of the body */ -function renderBody(wizard, body, index) +function renderBody(wizard, state, body, index) { var uniqueId = getUniqueId(wizard), uniqueBodyId = uniqueId + _tabpanelSuffix + index, uniqueHeaderId = uniqueId + _titleSuffix + index; - body._setId(uniqueBodyId).attr("role", "tabpanel")._aria("labelledby", uniqueHeaderId) - .addClass("body")._hideAria(); + body._id(uniqueBodyId).attr("role", "tabpanel")._aria("labelledby", uniqueHeaderId) + .addClass("body")._showAria(state.currentIndex === index); } /** @@ -1029,17 +1060,22 @@ function renderPagination(wizard, options, state) if (!options.forceMoveForward) { - buttons += format(buttonTemplate, "previous", options.labels.previous); + buttons += buttonTemplate.format("previous", options.labels.previous); } - buttons += format(buttonTemplate, "next", options.labels.next); + buttons += buttonTemplate.format("next", options.labels.next); if (options.enableFinishButton) { - buttons += format(buttonTemplate, "finish", options.labels.finish); + buttons += buttonTemplate.format("finish", options.labels.finish); + } + + if (options.enableCancelButton) + { + buttons += buttonTemplate.format("cancel", options.labels.cancel); } - wizard.append(format(pagination, options.actionContainerTag, options.clearFixCssClass, + wizard.append(pagination.format(options.actionContainerTag, options.clearFixCssClass, options.labels.pagination, buttons)); refreshPagination(wizard, options, state); @@ -1103,17 +1139,14 @@ function renderTitle(wizard, options, state, header, index) stepItem = $("
  • " + title + "
  • "); - if (!options.enableAllSteps) - { - stepItem._disableAria(); - } + stepItem._enableAria(options.enableAllSteps || state.currentIndex > index); if (state.currentIndex > index) { - stepItem._enableAria().addClass("done"); + stepItem.addClass("done"); } - header._setId(uniqueHeaderId).attr("tabindex", "-1").addClass("title"); + header._id(uniqueHeaderId).attr("tabindex", "-1").addClass("title"); if (index === 0) { @@ -1158,7 +1191,7 @@ function saveCurrentStateToCookie(wizard, options, state) } } -function startTransitionEffect(wizard, options, state, index, oldIndex) +function startTransitionEffect(wizard, options, state, index, oldIndex, doneCallback) { var stepContents = wizard.find(".content > .body"), effect = getValidEnumValue(transitionEffect, options.transitionEffect), @@ -1176,7 +1209,7 @@ function startTransitionEffect(wizard, options, state, index, oldIndex) state.transitionElement = newStep; currentStep[hide](effectSpeed, function () { - var wizard = $(this)._hideAria().parent().parent(), + var wizard = $(this)._showAria(false).parent().parent(), state = getState(wizard); if (state.transitionElement) @@ -1184,10 +1217,10 @@ function startTransitionEffect(wizard, options, state, index, oldIndex) state.transitionElement[show](effectSpeed, function () { $(this)._showAria(); - }); + }).promise().done(doneCallback); state.transitionElement = null; } - }).promise(); + }); break; case transitionEffect.slideLeft: @@ -1195,15 +1228,15 @@ function startTransitionEffect(wizard, options, state, index, oldIndex) posFadeOut = (index > oldIndex) ? -(outerWidth) : outerWidth, posFadeIn = (index > oldIndex) ? outerWidth : -(outerWidth); - currentStep.animate({ left: posFadeOut }, effectSpeed, - function () { $(this)._hideAria(); }).promise(); - newStep.css("left", posFadeIn + "px")._showAria() - .animate({ left: 0 }, effectSpeed).promise(); + $.when(currentStep.animate({ left: posFadeOut }, effectSpeed, + function () { $(this)._showAria(false); }), + newStep.css("left", posFadeIn + "px")._showAria() + .animate({ left: 0 }, effectSpeed)).done(doneCallback); break; default: - currentStep._hideAria(); - newStep._showAria(); + $.when(currentStep._showAria(false), newStep._showAria()) + .done(doneCallback); break; } } @@ -1246,7 +1279,7 @@ function throwError(message) { if (arguments.length > 1) { - message = format.apply(this, arguments); + message = message.format(Array.prototype.slice.call(arguments, 1)); } throw new Error(message); @@ -1303,10 +1336,8 @@ $.fn.steps = function (method) **/ $.fn.steps.add = function (step) { - var options = getOptions(this), - state = getState(this); - - return insertStep(this, options, state, state.stepCount, step); + var state = getState(this); + return insertStep(this, getOptions(this), state, state.stepCount, step); }; /** @@ -1317,9 +1348,7 @@ $.fn.steps.add = function (step) **/ $.fn.steps.destroy = function () { - var options = getOptions(this); - - return destroy(this, options); + return destroy(this, getOptions(this)); }; /** @@ -1329,9 +1358,7 @@ $.fn.steps.destroy = function () **/ $.fn.steps.finish = function () { - var state = getState(this); - - finishStep(this, state); + finishStep(this, getState(this)); }; /** @@ -1386,10 +1413,7 @@ $.fn.steps.getStep = function (index) **/ $.fn.steps.insert = function (index, step) { - var options = getOptions(this), - state = getState(this); - - return insertStep(this, options, state, index, step); + return insertStep(this, getOptions(this), getState(this), index, step); }; /** @@ -1400,10 +1424,7 @@ $.fn.steps.insert = function (index, step) **/ $.fn.steps.next = function () { - var options = getOptions(this), - state = getState(this); - - return goToNextStep(this, options, state); + return goToNextStep(this, getOptions(this), getState(this)); }; /** @@ -1414,10 +1435,7 @@ $.fn.steps.next = function () **/ $.fn.steps.previous = function () { - var options = getOptions(this), - state = getState(this); - - return goToPreviousStep(this, options, state); + return goToPreviousStep(this, getOptions(this), getState(this)); }; /** @@ -1429,10 +1447,7 @@ $.fn.steps.previous = function () **/ $.fn.steps.remove = function (index) { - var options = getOptions(this), - state = getState(this); - - return removeStep(this, options, state, index); + return removeStep(this, getOptions(this), getState(this), index); }; /** @@ -1459,7 +1474,6 @@ $.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. * @@ -1772,6 +1786,16 @@ var defaults = $.fn.steps.defaults = { **/ enableContentCache: true, + /** + * Shows the cancel button if enabled. + * + * @property enableCancelButton + * @type Boolean + * @default false + * @for defaults + **/ + enableCancelButton: false, + /** * Shows the finish button if enabled. * @@ -1883,6 +1907,16 @@ var defaults = $.fn.steps.defaults = { **/ onStepChanged: function (event, currentIndex, priorIndex) { }, + /** + * Fires after cancelation. + * + * @property onCanceled + * @type Event + * @default function (event) { } + * @for defaults + **/ + onCanceled: function (event) { }, + /** * Fires before finishing and can be used to prevent completion by returning `false`. * Very useful for form validation. @@ -1904,6 +1938,26 @@ var defaults = $.fn.steps.defaults = { **/ onFinished: function (event, currentIndex) { }, + /** + * Fires after async content is loaded. + * + * @property onContentLoaded + * @type Event + * @default function (event, index) { } + * @for defaults + **/ + onContentLoaded: function (event, currentIndex) { }, + + /** + * Fires when the wizard is initialized. + * + * @property onInit + * @type Event + * @default function (event) { } + * @for defaults + **/ + onInit: function (event, currentIndex) { }, + /** * Contains all labels. * @@ -1912,6 +1966,16 @@ var defaults = $.fn.steps.defaults = { * @for defaults **/ labels: { + /** + * Label for the cancel button. + * + * @property cancel + * @type String + * @default "Cancel" + * @for defaults + **/ + cancel: "Cancel", + /** * This label is important for accessability reasons. * Indicates which step is activated. @@ -1975,56 +2039,4 @@ var defaults = $.fn.steps.defaults = { loading: "Loading ..." } }; - -$.fn.extend({ - _aria: function (name, value) - { - return this.attr("aria-" + name, value); - }, - - _removeAria: function (name) - { - return this.removeAttr("aria-" + name); - }, - - _enableAria: function () - { - return this.removeClass("disabled")._aria("disabled", "false"); - }, - - _disableAria: function () - { - return this.addClass("disabled")._aria("disabled", "true"); - }, - - _hideAria: function () - { - return this.hide()._aria("hidden", "true"); - }, - - _showAria: function () - { - return this.show()._aria("hidden", "false"); - }, - - _selectAria: function () - { - return this.addClass("current")._aria("selected", "true"); - }, - - _deselectAria: function () - { - return this.removeClass("current")._aria("selected", "false"); - }, - - _getId: function () - { - return this.attr("id"); - }, - - _setId: function (id) - { - return this.attr("id", id); - } -}); })(jQuery); \ No newline at end of file diff --git a/build/jquery.steps.min.js b/build/jquery.steps.min.js index b50b63c..755aedf 100644 --- a/build/jquery.steps.min.js +++ b/build/jquery.steps.min.js @@ -1,6 +1,6 @@ /*! - * jQuery Steps v1.0.4 - 12/17/2013 - * Copyright (c) 2013 Rafael Staib (http://www.jquery-steps.com) + * jQuery Steps v1.1.0 - 09/04/2014 + * Copyright (c) 2014 Rafael Staib (http://www.jquery-steps.com) * Licensed under MIT http://www.opensource.org/licenses/MIT */ -!function(a,b){function c(a,b){o(a).push(b)}function d(d,e,f){var g=d.children(e.headerTag),h=d.children(e.bodyTag);g.length>h.length?R(Z,"contents"):g.length *");e.removeData("loaded").removeData("mode").removeData("url"),e.removeAttr("id").removeAttr("role").removeAttr("tabindex").removeAttr("class").removeAttr("style")._removeAria("labelledby")._removeAria("hidden"),b.find(".content > [data-mode='async'],.content > [data-mode='iframe']").empty();var f=a(h('<{0} class="{1}">',b.get(0).tagName,b.attr("class"))),g=b._getId();return null!=g&&""!==g&&f._setId(g),f.html(b.find(".content").html()),b.after(f),b.remove(),f}function g(a,b){var c=a.find(".steps li").eq(b.currentIndex);a.triggerHandler("finishing",[b.currentIndex])?(c.addClass("done").removeClass("error"),a.triggerHandler("finished",[b.currentIndex])):c.addClass("error")}function h(a){for(var b=1;bb||b>=c.length)&&R(Y),c[b]}function q(a){var b=a.data("uid");return null==b&&(b=a._getId(),null==b&&(b="steps-uid-".concat(T),a._setId(b)),T++,a.data("uid",b)),b}function r(a,c){if(S("enumType",a),S("keyOrValue",c),"string"==typeof c){var d=a[c];return d===b&&R("The enum key '{0}' does not exist.",c),d}if("number"==typeof c){for(var e in a)if(a[e]===c)return c;R("Invalid enum value '{0}'.",c)}else R("Invalid key or value type.")}function s(a,b,c){return B(a,b,c,v(c,1))}function t(a,b,c){return B(a,b,c,e(c,1))}function u(a,b,c,d){if((0>d||d>=c.stepCount)&&R(Y),!(b.forceMoveForward&&de||e>d.stepCount)&&R(Y),f=a.extend({},bb,f),y(b,e,f),d.currentIndex>=e&&(d.currentIndex++,O(b,c,d)),d.stepCount++;var g=b.find(".content"),i=a(h("<{0}>{1}",c.headerTag,f.title)),j=a(h("<{0}>",c.bodyTag));return(null==f.contentMode||f.contentMode===$.html)&&j.html(f.content),0===e?g.prepend(j).prepend(i):k(b,e-1).after(j).after(i),K(b,j,e),N(b,c,d,i,e),F(b,c,d,e),D(b,c,d),b}function y(a,b,c){o(a).splice(b,0,c)}function z(b){var c=a(this),d=m(c),e=n(c);if(d.suppressPaginationOnFocus&&c.find(":focus").is(":input"))return b.preventDefault(),!1;var f={left:37,right:39};b.keyCode===f.left?(b.preventDefault(),t(c,d,e)):b.keyCode===f.right&&(b.preventDefault(),s(c,d,e))}function A(b,c,d){if(d.stepCount>0){var e=p(b,d.currentIndex);if(!c.enableContentCache||!e.contentLoaded)switch(r($,e.contentMode)){case $.iframe:b.find(".content > .body").eq(d.currentIndex).empty().html('