Skip to content

Commit ee3a794

Browse files
committed
Added two new events (init and contentLoaded). Fixed issues #80, #88 and #97.
1 parent 2f1742d commit ee3a794

12 files changed

+66
-10
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.1.0
4+
- Added event `onInit` which is fired when the component is completely initialized. Closes issue [#80](https://github.com/rstaib/jquery-steps/issues/80)
5+
- 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)
6+
37
## 1.0.8
48
- Fixed issue [#91](https://github.com/rstaib/jquery-steps/issues/91) (`stepChanged` event is fired before transitions are done)
59

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"tabs",
1414
"steps"
1515
],
16-
"version": "1.0.8",
16+
"version": "1.1.0",
1717
"authors": [
1818
{ "name": "Rafael Staib", "email": "[email protected]", "url": "http://www.rafaelstaib.com" }
1919
],

build/jQuery.Steps.1.0.8.nupkg

-19.5 KB
Binary file not shown.

build/jQuery.Steps.1.1.0.nupkg

19.6 KB
Binary file not shown.

build/jquery.steps-1.0.8.zip

-18.8 KB
Binary file not shown.

build/jquery.steps-1.1.0.zip

19 KB
Binary file not shown.

build/jquery.steps.js

+29-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* jQuery Steps v1.0.8 - 09/01/2014
2+
* jQuery Steps v1.1.0 - 09/04/2014
33
* Copyright (c) 2014 Rafael Staib (http://www.jquery-steps.com)
44
* Licensed under MIT http://www.opensource.org/licenses/MIT
55
*/
@@ -565,6 +565,8 @@ function initialize(options)
565565
{
566566
getStepAnchor(wizard, opts.startIndex).focus();
567567
}
568+
569+
wizard.triggerHandler("init", [opts.startIndex]);
568570
});
569571
}
570572

@@ -699,7 +701,8 @@ function loadAsyncContent(wizard, options, state)
699701
{
700702
if (state.stepCount > 0)
701703
{
702-
var currentStep = getStep(wizard, state.currentIndex);
704+
var currentIndex = state.currentIndex,
705+
currentStep = getStep(wizard, currentIndex);
703706

704707
if (!options.enableContentCache || !currentStep.contentLoaded)
705708
{
@@ -712,12 +715,13 @@ function loadAsyncContent(wizard, options, state)
712715
break;
713716

714717
case contentMode.async:
715-
var currentStepContent = getStepPanel(wizard, state.currentIndex)._aria("busy", "true")
718+
var currentStepContent = getStepPanel(wizard, currentIndex)._aria("busy", "true")
716719
.empty().append(renderTemplate(options.loadingTemplate, { text: options.labels.loading }));
717720

718721
$.ajax({ url: currentStep.contentUrl, cache: false }).done(function (data)
719722
{
720723
currentStepContent.empty().html(data)._aria("busy", "false").data("loaded", "1");
724+
wizard.triggerHandler("contentLoaded", [currentIndex]);
721725
});
722726
break;
723727
}
@@ -905,8 +909,10 @@ function registerEvents(wizard, options)
905909
var eventNamespace = getEventNamespace(wizard);
906910

907911
wizard.bind("canceled" + eventNamespace, options.onCanceled);
912+
wizard.bind("contentLoaded" + eventNamespace, options.onContentLoaded);
908913
wizard.bind("finishing" + eventNamespace, options.onFinishing);
909914
wizard.bind("finished" + eventNamespace, options.onFinished);
915+
wizard.bind("init" + eventNamespace, options.onInit);
910916
wizard.bind("stepChanging" + eventNamespace, options.onStepChanging);
911917
wizard.bind("stepChanged" + eventNamespace, options.onStepChanged);
912918

@@ -1932,6 +1938,26 @@ var defaults = $.fn.steps.defaults = {
19321938
**/
19331939
onFinished: function (event, currentIndex) { },
19341940

1941+
/**
1942+
* Fires after async content is loaded.
1943+
*
1944+
* @property onContentLoaded
1945+
* @type Event
1946+
* @default function (event, index) { }
1947+
* @for defaults
1948+
**/
1949+
onContentLoaded: function (event, currentIndex) { },
1950+
1951+
/**
1952+
* Fires when the wizard is initialized.
1953+
*
1954+
* @property onInit
1955+
* @type Event
1956+
* @default function (event) { }
1957+
* @for defaults
1958+
**/
1959+
onInit: function (event, currentIndex) { },
1960+
19351961
/**
19361962
* Contains all labels.
19371963
*

build/jquery.steps.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jquery-steps",
33
"title": "jQuery Steps",
4-
"version": "1.0.8",
4+
"version": "1.1.0",
55
"description": "A powerful jQuery wizard plugin that supports accessibility and HTML5",
66
"homepage": "http://www.jquery-steps.com",
77
"author": {

src/defaults.js

+20
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,26 @@ var defaults = $.fn.steps.defaults = {
340340
**/
341341
onFinished: function (event, currentIndex) { },
342342

343+
/**
344+
* Fires after async content is loaded.
345+
*
346+
* @property onContentLoaded
347+
* @type Event
348+
* @default function (event, index) { }
349+
* @for defaults
350+
**/
351+
onContentLoaded: function (event, currentIndex) { },
352+
353+
/**
354+
* Fires when the wizard is initialized.
355+
*
356+
* @property onInit
357+
* @type Event
358+
* @default function (event) { }
359+
* @for defaults
360+
**/
361+
onInit: function (event, currentIndex) { },
362+
343363
/**
344364
* Contains all labels.
345365
*

src/privates.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ function initialize(options)
505505
{
506506
getStepAnchor(wizard, opts.startIndex).focus();
507507
}
508+
509+
wizard.triggerHandler("init", [opts.startIndex]);
508510
});
509511
}
510512

@@ -639,7 +641,8 @@ function loadAsyncContent(wizard, options, state)
639641
{
640642
if (state.stepCount > 0)
641643
{
642-
var currentStep = getStep(wizard, state.currentIndex);
644+
var currentIndex = state.currentIndex,
645+
currentStep = getStep(wizard, currentIndex);
643646

644647
if (!options.enableContentCache || !currentStep.contentLoaded)
645648
{
@@ -652,12 +655,13 @@ function loadAsyncContent(wizard, options, state)
652655
break;
653656

654657
case contentMode.async:
655-
var currentStepContent = getStepPanel(wizard, state.currentIndex)._aria("busy", "true")
658+
var currentStepContent = getStepPanel(wizard, currentIndex)._aria("busy", "true")
656659
.empty().append(renderTemplate(options.loadingTemplate, { text: options.labels.loading }));
657660

658661
$.ajax({ url: currentStep.contentUrl, cache: false }).done(function (data)
659662
{
660663
currentStepContent.empty().html(data)._aria("busy", "false").data("loaded", "1");
664+
wizard.triggerHandler("contentLoaded", [currentIndex]);
661665
});
662666
break;
663667
}
@@ -845,8 +849,10 @@ function registerEvents(wizard, options)
845849
var eventNamespace = getEventNamespace(wizard);
846850

847851
wizard.bind("canceled" + eventNamespace, options.onCanceled);
852+
wizard.bind("contentLoaded" + eventNamespace, options.onContentLoaded);
848853
wizard.bind("finishing" + eventNamespace, options.onFinishing);
849854
wizard.bind("finished" + eventNamespace, options.onFinished);
855+
wizard.bind("init" + eventNamespace, options.onInit);
850856
wizard.bind("stepChanging" + eventNamespace, options.onStepChanging);
851857
wizard.bind("stepChanged" + eventNamespace, options.onStepChanged);
852858

steps.jquery.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"tabs",
1515
"steps"
1616
],
17-
"version": "1.0.8",
17+
"version": "1.1.0",
1818
"author": {
1919
"name": "Rafael Staib",
2020
"email": "[email protected]",

0 commit comments

Comments
 (0)