diff options
author | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2009-07-03 21:05:22 +0000 |
---|---|---|
committer | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2009-07-03 21:05:22 +0000 |
commit | b6bdbb421177660c9f36cfbdb66430406f615427 (patch) | |
tree | 9820b98867a6844b352783692e38a1bd47755f74 /ui | |
parent | cfe9a275c91124803f24417a97a1b4b8f6abaab5 (diff) | |
download | jquery-ui-b6bdbb421177660c9f36cfbdb66430406f615427.tar.gz jquery-ui-b6bdbb421177660c9f36cfbdb66430406f615427.zip |
accordion fix for #4653: added tests, adopted no-auto-height demo to also cover navigation option; fixed an unrelated bug, where ui-accordion-content-active was never removed
Diffstat (limited to 'ui')
-rw-r--r-- | ui/ui.accordion.js | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/ui/ui.accordion.js b/ui/ui.accordion.js index 5fb6b501a..de1a29f1e 100644 --- a/ui/ui.accordion.js +++ b/ui/ui.accordion.js @@ -27,18 +27,6 @@ $.widget("ui.accordion", { o.collapsible = !o.alwaysOpen; } - if ( o.navigation ) { - var current = this.element.find("a").filter(o.navigationFilter); - if ( current.length ) { - if ( current.filter(o.header).length ) { - this.active = current; - } else { - this.active = current.parent().parent().prev(); - current.addClass("ui-accordion-content-active"); - } - } - } - this.element.addClass("ui-accordion ui-widget ui-helper-reset"); // in lack of child-selectors in CSS we need to mark top-LIs in a UL-accordion for some IE-fix @@ -56,6 +44,20 @@ $.widget("ui.accordion", { .next() .addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom"); + if ( o.navigation ) { + var current = this.element.find("a").filter(o.navigationFilter); + if ( current.length ) { + var header = current.closest(".ui-accordion-header"); + if ( header.length ) { + // anchor within header + this.active = header; + } else { + // anchor within content + this.active = current.closest(".ui-accordion-content").prev(); + } + } + } + this.active = this._findActive(this.active || o.active).toggleClass("ui-state-default").toggleClass("ui-state-active").toggleClass("ui-corner-all").toggleClass("ui-corner-top"); this.active.next().addClass('ui-accordion-content-active'); @@ -276,7 +278,7 @@ $.widget("ui.accordion", { // switch classes this.active.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all") .find(".ui-icon").removeClass(o.icons.headerSelected).addClass(o.icons.header); - this.active.next().addClass('ui-accordion-content-active'); + this.active.next().removeClass('ui-accordion-content-active'); if (!clickedIsActive) { clicked.removeClass("ui-state-default ui-corner-all").addClass("ui-state-active ui-corner-top") .find(".ui-icon").removeClass(o.icons.header).addClass(o.icons.headerSelected); |