1 | /*
|
---|
2 | * accordion_core.js
|
---|
3 | */
|
---|
4 |
|
---|
5 |
|
---|
6 | (function($) {
|
---|
7 |
|
---|
8 | $.ui.accordion.prototype.options.animated = false;
|
---|
9 |
|
---|
10 | function state(accordion) {
|
---|
11 | var args = $.makeArray(arguments).slice(1);
|
---|
12 | var result = [];
|
---|
13 | $.each(args, function(i, n) {
|
---|
14 | result.push( accordion.find(".ui-accordion-content").eq(i).is(":visible") ? 1 : 0 );
|
---|
15 | });
|
---|
16 | same(args, result)
|
---|
17 | }
|
---|
18 |
|
---|
19 | module("accordion: core");
|
---|
20 |
|
---|
21 | test("handle click on header-descendant", function() {
|
---|
22 | var ac = $('#navigation').accordion({ autoHeight: false });
|
---|
23 | $('#navigation h2:eq(1) a').trigger("click");
|
---|
24 | state(ac, 0, 1, 0);
|
---|
25 | });
|
---|
26 |
|
---|
27 | test("accessibility", function () {
|
---|
28 | expect(9);
|
---|
29 | var ac = $('#list1').accordion().accordion("activate", 1);
|
---|
30 | var headers = $(".ui-accordion-header");
|
---|
31 |
|
---|
32 | equals( headers.eq(1).attr("tabindex"), "0", "active header should have tabindex=0");
|
---|
33 | equals( headers.eq(0).attr("tabindex"), "-1", "inactive header should have tabindex=-1");
|
---|
34 | equals( ac.attr("role"), "tablist", "main role");
|
---|
35 | equals( headers.attr("role"), "tab", "tab roles");
|
---|
36 | equals( headers.next().attr("role"), "tabpanel", "tabpanel roles");
|
---|
37 | equals( headers.eq(1).attr("aria-expanded"), "true", "active tab has aria-expanded");
|
---|
38 | equals( headers.eq(0).attr("aria-expanded"), "false", "inactive tab has aria-expanded");
|
---|
39 | ac.accordion("activate", 0);
|
---|
40 | equals( headers.eq(0).attr("aria-expanded"), "true", "newly active tab has aria-expanded");
|
---|
41 | equals( headers.eq(1).attr("aria-expanded"), "false", "newly inactive tab has aria-expanded");
|
---|
42 | });
|
---|
43 |
|
---|
44 | })(jQuery);
|
---|