Skip to content

Commit 6815072

Browse files
author
Rafael J. Staib
committed
Add improvement to render and insert method
1 parent e4c0ed0 commit 6815072

File tree

3 files changed

+25
-26
lines changed

3 files changed

+25
-26
lines changed

src/banner.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,4 @@
3636
* @requires jQuery (always required), jQuery.cookie (only required if saveState is `true`)
3737
*/
3838
;(function ($, undefined)
39-
{
40-
//"use strict";
39+
{

src/privates.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,6 @@ var privates = {
564564
wizard.bind("keyup.steps", privates.keyUpHandler);
565565
}
566566

567-
wizard.find(".steps a").bind("click.steps", privates.stepClickHandler); // TODO: Try to move this code line to renderTitle
568567
wizard.find(".actions a").bind("click.steps", privates.paginationClickHandler);
569568
},
570569

@@ -588,11 +587,14 @@ var privates = {
588587
// Create a content wrapper and copy HTML from the intial wizard structure
589588
var contentWrapper = $(document.createElement(options.contentContainerTag))
590589
.addClass("content").html(wizard.html()),
590+
stepsWrapper = $(document.createElement(options.stepsContainerTag))
591+
.addClass("steps").append($("<ul role=\"tablist\"></ul>")),
591592
stepTitles = contentWrapper.children(options.headerTag),
592593
stepContents = contentWrapper.children(options.bodyTag);
593594

594595
// Transform the wizard wrapper and remove the inner HTML
595-
wizard.attr("role", "application").addClass(options.cssClass).empty().append(contentWrapper);
596+
wizard.attr("role", "application").addClass(options.cssClass).empty()
597+
.append(stepsWrapper).append(contentWrapper);
596598

597599
// Add WIA-ARIA support
598600
stepContents.each(function (index)
@@ -603,19 +605,9 @@ var privates = {
603605
// Make the start step visible
604606
stepContents.eq(state.currentIndex).showAria();
605607

606-
var stepsWrapper = $(document.createElement(options.stepsContainerTag))
607-
.addClass("steps").append($("<ul role=\"tablist\"></ul>"));
608-
wizard.prepend(stepsWrapper);
609-
610608
stepTitles.each(function (index)
611609
{
612610
privates.renderTitle(wizard, options, state, $(this), index);
613-
614-
// TODO: Try to move this code block to renderTitle
615-
if (index < state.currentIndex)
616-
{
617-
wizard.find(".steps li").eq(index).disableAria().addClass("done");
618-
}
619611
});
620612

621613
privates.refreshStepNavigation(wizard, options, state);
@@ -737,6 +729,11 @@ var privates = {
737729
stepItem.disableAria();
738730
}
739731

732+
if (state.currentIndex > index)
733+
{
734+
stepItem.enableAria().addClass("done");
735+
}
736+
740737
header.setId(uniqueHeaderId).attr("tabindex", "-1").addClass("title");
741738

742739
if (index === 0)
@@ -759,6 +756,9 @@ var privates = {
759756
{
760757
stepCollection.find("li").removeClass("last").eq(index).addClass("last");
761758
}
759+
760+
// Register click event
761+
stepItem.children("a").bind("click.steps", privates.stepClickHandler);
762762
},
763763

764764
/**

src/publics.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,6 @@ $.fn.steps.insert = function (index, step)
150150

151151
privates.renderBody(this, body, index);
152152
privates.renderTitle(this, options, state, header, index);
153-
154-
// TODO: Try to move this code block to renderTitle
155-
var currentStepAnchor = this.find("#" + uniqueId + _tabSuffix + index);
156-
var currentStep = currentStepAnchor.parent();
157-
if (state.currentIndex > index)
158-
{
159-
currentStep.enableAria().addClass("done");
160-
}
161-
162-
// TODO: Try to move this code line to renderTitle
163-
currentStepAnchor.bind("click.steps", privates.stepClickHandler);
164-
165153
privates.refreshSteps(this, options, state, index);
166154
privates.refreshPagination(this, options, state);
167155

@@ -240,6 +228,18 @@ $.fn.steps.remove = function (index)
240228
return true;
241229
};
242230

231+
/**
232+
* Sets a specific step object by index.
233+
*
234+
* @method setStep
235+
* @param index {Integer} An integer that belongs to the position of a step
236+
* @param step {Object} The step object to change
237+
**/
238+
$.fn.steps.setStep = function (index, step)
239+
{
240+
throw new Error("Not yet implemented!");
241+
};
242+
243243
/**
244244
* Skips an certain amount of steps.
245245
*

0 commit comments

Comments
 (0)