diff --git a/tests/accordion.html b/tests/accordion.html index 194b130b2..275ebe0e7 100644 --- a/tests/accordion.html +++ b/tests/accordion.html @@ -33,145 +33,108 @@
-
- Standard, container is a div, header is h3 and content p - -
- There is one obvious advantage: -
-

- You've seen it coming!
- Buy now and get nothing for free!
- Well, at least no free beer. Perhaps a bear, if you can afford it. -

-
- Now that you've got... -
-

- your bear, you have to admit it!
- No, we aren't selling bears. -

-

- We could talk about renting one. -

-
- Rent one bear, ... -
-

- get two for three beer. -

-

- And now, for something completely different. -

-
+
+ There is one obvious advantage: +
+

+ You've seen it coming!
+ Buy now and get nothing for free!
+ Well, at least no free beer. Perhaps a bear, if you can afford it. +

- -
- -
- Navigation - Unordered List with anchors and nested lists. -

The first item is cloned to allow the user to select it. The - active element is choosen based on location.hash: Open Drums and click - the first item ('Drums'), then reload the page.

- - - -
- -
- With options, container is a definition list, header dt, content dd - -
-
Red
-
- Fancy stuff about red thingies. -
-
Green
-
- Green! Green! Green! -
-
Blue
-
- Cool kids are blue. -
-
- -
- -
- Divitus structure, div container, div header (class title), div - content, no active on startup and can be completely closed - -
-
-
Tennis
-
- One ball, two players. Lots of fun. -
-
-
-
Soccer
-
- One ball, 22 players. Lots of fun. -
-
-
-
Baseball
-
- Well, one ball, some guys running around, some guys hitting others with a stick.
- Sounds like fun, doesn't it? -
-
- Well, apart from the running part. -
-
+ Now that you've got... +
+

+ your bear, you have to admit it!
+ No, we aren't selling bears. +

+

+ We could talk about renting one. +

+
+ Rent one bear, ... +
+

+ get two for three beer. +

+

+ And now, for something completely different. +

- -
- -
- - - Activate via selector, eg. ':first' or 'a:first':
-
Log of the 2nd accordion
+ +
+
Red
+
+ Fancy stuff about red thingies. +
+
Green
+
+ Green! Green! Green! +
+
Blue
+
+ Cool kids are blue. +
+
+ +
+
+
Tennis
+
+ One ball, two players. Lots of fun. +
+
+
+
Soccer
+
+ One ball, 22 players. Lots of fun. +
+
+
+
Baseball
+
+ Well, one ball, some guys running around, some guys hitting others with a stick.
+ Sounds like fun, doesn't it? +
+
+ Well, apart from the running part. +
+
+
+
diff --git a/tests/accordion.js b/tests/accordion.js index 1fbd1e20c..e957acd43 100644 --- a/tests/accordion.js +++ b/tests/accordion.js @@ -10,10 +10,14 @@ jQuery.ui.accordion.defaults.animated = false; function state(accordion) { var args = $.makeArray(arguments).slice(1); $.each(args, function(i, n) { - equals(n, accordion.find("div").eq(i).is(":visible")); + equals(accordion.find("div").eq(i).is(":visible"), n); }); } +$.fn.triggerEvent = function(type, target) { + return this.triggerHandler(type, [jQuery.event.fix({ type: type, target: target })]); +} + test("basics", function() { state($('#list1').accordion(), 1, 0, 0); }); @@ -82,4 +86,17 @@ test("activate, jQuery or DOM element", function() { state(ac, 0, 1, 0); }); +function state2(accordion) { + var args = $.makeArray(arguments).slice(1); + $.each(args, function(i, n) { + equals(accordion.find("ul").eq(i).is(":visible"), n); + }); +} + +test("handle click on header-descendant", function() { + var ac = $('#navigation').accordion({ header: '.head', autoHeight: false }) + ac.triggerEvent("click", $('#navigation span:contains(Bass)')[0]); + state2(ac, 0, 1, 0); +}); + })(jQuery); diff --git a/tests/all.html b/tests/all.html index ad46f8729..e5f85a27c 100644 --- a/tests/all.html +++ b/tests/all.html @@ -64,145 +64,107 @@
-
- Standard, container is a div, header is h3 and content p - -
- There is one obvious advantage: -
-

- You've seen it coming!
- Buy now and get nothing for free!
- Well, at least no free beer. Perhaps a bear, if you can afford it. -

-
- Now that you've got... -
-

- your bear, you have to admit it!
- No, we aren't selling bears. -

-

- We could talk about renting one. -

-
- Rent one bear, ... -
-

- get two for three beer. -

-

- And now, for something completely different. -

-
+
+ There is one obvious advantage: +
+

+ You've seen it coming!
+ Buy now and get nothing for free!
+ Well, at least no free beer. Perhaps a bear, if you can afford it. +

- -
+ Now that you've got... +
+

+ your bear, you have to admit it!
+ No, we aren't selling bears. +

+

+ We could talk about renting one. +

+
+ Rent one bear, ... +
+

+ get two for three beer. +

+

+ And now, for something completely different. +

+
+ + + +
+
Red
+
+ Fancy stuff about red thingies. +
+
Green
+
+ Green! Green! Green! +
+
Blue
+
+ Cool kids are blue. +
+
-
- Navigation - Unordered List with anchors and nested lists. -

The first item is cloned to allow the user to select it. The - active element is choosen based on location.hash: Open Drums and click - the first item ('Drums'), then reload the page.

- - - -
- -
- With options, container is a definition list, header dt, content dd - -
-
Red
-
- Fancy stuff about red thingies. -
-
Green
-
- Green! Green! Green! -
-
Blue
-
- Cool kids are blue. -
-
- -
- -
- Divitus structure, div container, div header (class title), div - content, no active on startup and can be completely closed - -
+
+
+
Tennis
-
Tennis
-
- One ball, two players. Lots of fun. -
-
-
-
Soccer
-
- One ball, 22 players. Lots of fun. -
-
-
-
Baseball
-
- Well, one ball, some guys running around, some guys hitting others with a stick.
- Sounds like fun, doesn't it? -
-
- Well, apart from the running part. -
+ One ball, two players. Lots of fun.
- -
- -
- - - Activate via selector, eg. ':first' or 'a:first': +
+
Soccer
+
+ One ball, 22 players. Lots of fun. +
- -
Log of the 2nd accordion
+
+
Baseball
+
+ Well, one ball, some guys running around, some guys hitting others with a stick.
+ Sounds like fun, doesn't it? +
+
+ Well, apart from the running part. +
+
+
I'm a resizable.
diff --git a/ui/ui.accordion.js b/ui/ui.accordion.js index 00a660c0b..c7828cd9d 100644 --- a/ui/ui.accordion.js +++ b/ui/ui.accordion.js @@ -180,9 +180,7 @@ function clickHandler(event) { // due to the event delegation model, we have to check if one // of the parent elements is our actual header, and find that if ( clicked.parents(options.header).length ) { - while ( !clicked.is(options.header) ) { - clicked = clicked.parent(); - } + clicked = clicked.parents(options.header + ":first"); } var clickedActive = clicked[0] == options.active[0];