Skip to content

Commit 90b0615

Browse files
author
Rafael J. Staib
committed
Substitute ol by ul for steps and add aria-selected
1 parent 47478af commit 90b0615

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

demo/css/jquery.steps.css

+7-7
Original file line numberDiff line numberDiff line change
@@ -39,35 +39,35 @@
3939
font-weight: bold;
4040
}
4141

42-
.wizard > .steps > ol > li,
43-
.wizard > .actions > ul > li
42+
.wizard li[role="tab"],
43+
.wizard > .actions li
4444
{
4545
float: left;
4646
}
4747

48-
.wizard > .steps a
48+
.wizard li[role="tab"] a
4949
{
5050
background: #999;
5151
}
5252

53-
.wizard > .steps .disabled a
53+
.wizard li[role="tab"].disabled a
5454
{
5555
background: #ccc;
5656
cursor: default;
5757
}
5858

59-
.wizard > .steps .current a
59+
.wizard li[role="tab"].current a
6060
{
6161
background: rgb(241, 101, 41);
6262
cursor: default;
6363
}
6464

65-
.wizard > .steps .done a
65+
.wizard li[role="tab"].done a
6666
{
6767
background: #4cff00;
6868
}
6969

70-
.wizard > .steps .error a
70+
.wizard li[role="tab"].error a
7171
{
7272
background: #f00;
7373
}

jquery.steps.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@
633633
var wizard = $(this),
634634
options = wizard.data("options"),
635635
state = wizard.data("state"),
636-
currentStep = $(".steps li:eq(" + state.currentIndex + ")", wizard);
636+
currentStep = $("li[role=tab]:eq(" + state.currentIndex + ")", wizard);
637637

638638
if (wizard.triggerHandler("finishing", [state.currentIndex]))
639639
{
@@ -668,7 +668,7 @@
668668
var contentContainer = wizard.children(".content");
669669
$(".title:eq(" + index + ")", contentContainer).remove();
670670
$(".body:eq(" + index + ")", contentContainer).remove();
671-
$(".steps > ol > li:eq(" + index + ")", wizard).remove();
671+
$("li[role=tab]:eq(" + index + ")", wizard).remove();
672672

673673
// Reset state values
674674
if (state.currentIndex > index)
@@ -682,13 +682,13 @@
682682
// Set the "first" class to the new first step button
683683
if (index === 0)
684684
{
685-
$(".steps > ol > li:first", wizard).addClass("first");
685+
$("li[role=tab]:first", wizard).addClass("first");
686686
}
687687

688688
// Set the "last" class to the new last step button
689689
if (index === state.stepCount)
690690
{
691-
$(".steps > ol > li:eq(" + index + ")", wizard).addClass("last");
691+
$("li[role=tab]:eq(" + index + ")", wizard).addClass("last");
692692
}
693693

694694
updateSteps(wizard, index);
@@ -769,7 +769,7 @@
769769
state.currentStep = getStepProperties(wizard, state.currentIndex);
770770

771771
// Add click event
772-
$(".steps > ol > li:eq(" + index + ") > a", wizard).bind("click.steps", stepClickHandler);
772+
$("li[role=tab]:eq(" + index + ") > a", wizard).bind("click.steps", stepClickHandler);
773773

774774
updateSteps(wizard, index);
775775
refreshActionState(wizard);
@@ -810,7 +810,7 @@
810810

811811
if (opts.autoFocus && _uniqueId === 1)
812812
{
813-
$(".steps li.current a", $this).focus();
813+
$("li[role=tab].current a", $this).focus();
814814
}
815815

816816
$this.bind("finishing.steps", opts.onFinishing);
@@ -1025,7 +1025,7 @@
10251025
stepContents.eq(startIndex).show().attr("aria-hidden", "false");
10261026

10271027
var stepsWrapper = $(document.createElement(options.stepsContainerTag))
1028-
.addClass("steps").append($("<ol role=\"tablist\"></ol>"));
1028+
.addClass("steps").append($("<ul role=\"tablist\"></ul>"));
10291029
wizard.prepend(stepsWrapper);
10301030

10311031
stepTitles.each(function (index)
@@ -1034,12 +1034,12 @@
10341034

10351035
if (index < startIndex)
10361036
{
1037-
$(".steps > ol > li:eq(" + index + ")", wizard).addClass("done");
1037+
$("li[role=tab]:eq(" + index + ")", wizard).addClass("done");
10381038
}
10391039

10401040
if (index > startIndex && !options.enableAllSteps)
10411041
{
1042-
$(".steps > ol > li:eq(" + index + ")", wizard).addClass("disabled")
1042+
$("li[role=tab]:eq(" + index + ")", wizard).addClass("disabled")
10431043
.attr("aria-disabled", "true");
10441044
}
10451045
});
@@ -1109,7 +1109,7 @@
11091109
uniqueHeaderId = uniqueId + "-header-" + index,
11101110
options = wizard.data("options"),
11111111
state = wizard.data("state"),
1112-
stepCollection = $(".steps > ol", wizard),
1112+
stepCollection = $(".steps > ul", wizard),
11131113
title = renderTemplate(options.titleTemplate, {
11141114
index: index + 1,
11151115
title: header.html()
@@ -1197,7 +1197,7 @@
11971197
uniqueBodyId = uniqueId + "-tabpanel-" + i,
11981198
uniqueHeaderId = uniqueId + "-header-" + i,
11991199
title = $(".content > .title:eq(" + i + ")", wizard).attr("id", uniqueHeaderId);
1200-
$(".steps > ol > li:eq(" + i + ") > a", wizard).attr("id", uniqueStepId)
1200+
$("li[role=tab]:eq(" + i + ") > a", wizard).attr("id", uniqueStepId)
12011201
.attr("aria-controls", uniqueBodyId).attr("href", "#" + uniqueHeaderId)
12021202
.html(renderTemplate(options.titleTemplate, { index: i + 1, title: title.html() }));
12031203
$(".content > .body:eq(" + i + ")", wizard).attr("id", uniqueBodyId)
@@ -1225,13 +1225,13 @@
12251225

12261226
if (oldIndex != null)
12271227
{
1228-
var oldStep = steps.eq(oldIndex).addClass("done").removeClass("current error");
1228+
var oldStep = steps.eq(oldIndex).addClass("done").removeClass("current error").attr("aria-selected", "false");
12291229
stepTitles.eq(oldIndex).removeClass("current").next(".body").removeClass("current");
12301230
currentInfo = $("a > .current-info", oldStep);
12311231
currentOrNewStep.children("a").focus();
12321232
}
12331233

1234-
currentOrNewStep.addClass("current").removeClass("disabled done")
1234+
currentOrNewStep.addClass("current").attr("aria-selected", "true").removeClass("disabled done")
12351235
.attr("aria-disabled", "false").children("a").prepend(currentInfo);
12361236
stepTitles.eq(index).addClass("current").next(".body").addClass("current");
12371237
}

test/tests.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ test("stepClassFirstAndLast", 12, function ()
3838
{
3939
function checkOnlyFirstItemHasClass()
4040
{
41-
var steps = $("#vis > .steps > ol > li");
41+
var steps = $("#vis li[role=tab]");
4242
for (var i = 0; i < steps.length; i++)
4343
{
4444
if (i > 0 && steps.eq(i).hasClass("first"))
@@ -51,7 +51,7 @@ test("stepClassFirstAndLast", 12, function ()
5151

5252
function checkOnlyLastItemHasClass()
5353
{
54-
var steps = $("#vis > .steps > ol > li");
54+
var steps = $("#vis li[role=tab]");
5555
for (var i = 0; i < steps.length; i++)
5656
{
5757
if (i < (steps.length - 1) && steps.eq(i).hasClass("last"))
@@ -96,7 +96,7 @@ test("stepClassCurrent", 6, function ()
9696
{
9797
function checkOnlyItemOnPositionHasClass(index)
9898
{
99-
var steps = $("#vis > .steps > ol > li");
99+
var steps = $("#vis li[role=tab]");
100100
for (var i = 0; i < steps.length; i++)
101101
{
102102
if (i !== index && steps.eq(i).hasClass("current"))
@@ -135,28 +135,28 @@ test("stepClassDisabledAndDone", 12, function ()
135135
{
136136
function checkOnlyItemAfterPositionHasClass(index)
137137
{
138-
var steps = $("#vis > .steps > ol > li");
138+
var steps = $("#vis li[role=tab]");
139139
for (var i = 0; i < steps.length; i++)
140140
{
141141
if (i <= index && steps.eq(i).hasClass("disabled"))
142142
{
143143
return false;
144144
}
145145
}
146-
return (index > (steps.length - 1)) ? $("#vis > .steps > ol > li:gt(" + index + ")").hasClass("disabled") : true;
146+
return (index > (steps.length - 1)) ? $("#vis li[role=tab]:gt(" + index + ")").hasClass("disabled") : true;
147147
}
148148

149149
function checkOnlyItemBeforePositionHasClass(index)
150150
{
151-
var steps = $("#vis > .steps > ol > li");
151+
var steps = $("#vis li[role=tab]");
152152
for (var i = 0; i < steps.length; i++)
153153
{
154154
if (i >= index && steps.eq(i).hasClass("done"))
155155
{
156156
return false;
157157
}
158158
}
159-
return (index > 0) ? $("#vis > .steps > ol > li:lt(" + index + ")").hasClass("done") : true;
159+
return (index > 0) ? $("#vis li[role=tab]:lt(" + index + ")").hasClass("done") : true;
160160
}
161161

162162
ok(checkOnlyItemAfterPositionHasClass(0), "Valid after init (disabled)!");

0 commit comments

Comments
 (0)