Skip to content

Commit

Permalink
Added two new events (init and contentLoaded). Fixed issues #80, #88
Browse files Browse the repository at this point in the history
…and #97.
  • Loading branch information
rstaib committed Sep 4, 2014
1 parent 2f1742d commit ee3a794
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"tabs",
"steps"
],
"version": "1.0.8",
"version": "1.1.0",
"authors": [
{ "name": "Rafael Staib", "email": "[email protected]", "url": "http://www.rafaelstaib.com" }
],
Expand Down
Binary file removed build/jQuery.Steps.1.0.8.nupkg
Binary file not shown.
Binary file added build/jQuery.Steps.1.1.0.nupkg
Binary file not shown.
Binary file removed build/jquery.steps-1.0.8.zip
Binary file not shown.
Binary file added build/jquery.steps-1.1.0.zip
Binary file not shown.
32 changes: 29 additions & 3 deletions build/jquery.steps.js
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -565,6 +565,8 @@ function initialize(options)
{
getStepAnchor(wizard, opts.startIndex).focus();
}

wizard.triggerHandler("init", [opts.startIndex]);
});
}

Expand Down Expand Up @@ -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)
{
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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.
*
Expand Down
4 changes: 2 additions & 2 deletions build/jquery.steps.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jquery-steps",
"title": "jQuery Steps",
"version": "1.0.8",
"version": "1.1.0",
"description": "A powerful jQuery wizard plugin that supports accessibility and HTML5",
"homepage": "http://www.jquery-steps.com",
"author": {
Expand Down
20 changes: 20 additions & 0 deletions src/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,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.
*
Expand Down
10 changes: 8 additions & 2 deletions src/privates.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,8 @@ function initialize(options)
{
getStepAnchor(wizard, opts.startIndex).focus();
}

wizard.triggerHandler("init", [opts.startIndex]);
});
}

Expand Down Expand Up @@ -639,7 +641,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)
{
Expand All @@ -652,12 +655,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;
}
Expand Down Expand Up @@ -845,8 +849,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);

Expand Down
2 changes: 1 addition & 1 deletion steps.jquery.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"tabs",
"steps"
],
"version": "1.0.8",
"version": "1.1.0",
"author": {
"name": "Rafael Staib",
"email": "[email protected]",
Expand Down

0 comments on commit ee3a794

Please sign in to comment.