diff --git a/CHANGELOG.md b/CHANGELOG.md index d32a3b9..0fc2821 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # 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) diff --git a/bower.json b/bower.json index 507ce75..7b63e2b 100644 --- a/bower.json +++ b/bower.json @@ -13,7 +13,7 @@ "tabs", "steps" ], - "version": "1.0.8", + "version": "1.1.0", "authors": [ { "name": "Rafael Staib", "email": "me@rafaelstaib.com", "url": "http://www.rafaelstaib.com" } ], diff --git a/build/jQuery.Steps.1.0.8.nupkg b/build/jQuery.Steps.1.0.8.nupkg deleted file mode 100644 index a1cae02..0000000 Binary files a/build/jQuery.Steps.1.0.8.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.8.zip b/build/jquery.steps-1.0.8.zip deleted file mode 100644 index d25d9a5..0000000 Binary files a/build/jquery.steps-1.0.8.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 a8846d2..956b05a 100644 --- a/build/jquery.steps.js +++ b/build/jquery.steps.js @@ -1,5 +1,5 @@ /*! - * jQuery Steps v1.0.8 - 09/01/2014 + * 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 */ @@ -565,6 +565,8 @@ function initialize(options) { getStepAnchor(wizard, opts.startIndex).focus(); } + + wizard.triggerHandler("init", [opts.startIndex]); }); } @@ -699,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) { @@ -712,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; } @@ -905,8 +909,10 @@ 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); @@ -1932,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. * diff --git a/build/jquery.steps.min.js b/build/jquery.steps.min.js index b9d1a6c..755aedf 100644 --- a/build/jquery.steps.min.js +++ b/build/jquery.steps.min.js @@ -1,6 +1,6 @@ /*! - * jQuery Steps v1.0.8 - 09/01/2014 + * 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('<{0} class="{1}">'.format(b.get(0).tagName,b.attr("class"))),g=b._id();return null!=g&&""!==g&&f._id(g),f.html(b.find(".content").html()),b.after(f),b.remove(),f}function h(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 i(a){var b=a.data("eventNamespace");return null==b&&(b="."+q(a),a.data("eventNamespace",b)),b}function j(a,b){var c=q(a);return a.find("#"+c+V+b)}function k(a,b){var c=q(a);return a.find("#"+c+W+b)}function l(a,b){var c=q(a);return a.find("#"+c+X+b)}function m(a){return a.data("options")}function n(a){return a.data("state")}function o(a){return a.data("steps")}function p(a,b){var c=o(a);return(0>b||b>=c.length)&&R(Y),c[b]}function q(a){var b=a.data("uid");return null==b&&(b=a._id(),null==b&&(b="steps-uid-".concat(T),a._id(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,f(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!==d.stepCount&&d.currentIndex>=e&&(d.currentIndex++,O(b,c,d)),d.stepCount++;var g=b.find(".content"),h=a("<{0}>{1}".format(c.headerTag,f.title)),i=a("<{0}>".format(c.bodyTag));return(null==f.contentMode||f.contentMode===$.html)&&i.html(f.content),0===e?g.prepend(i).prepend(h):k(b,e-1).after(i).after(h),K(b,d,i,e),N(b,c,d,h,e),F(b,c,d,e),e===d.currentIndex&&E(b,c,d),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('