diff options
author | Paul Bakaus <paul.bakaus@googlemail.com> | 2009-02-02 02:11:32 +0000 |
---|---|---|
committer | Paul Bakaus <paul.bakaus@googlemail.com> | 2009-02-02 02:11:32 +0000 |
commit | 43ebec65763a6cd62b1d5189af83a954bb54ea53 (patch) | |
tree | 595c174735dac30783d68f34704cf23b05035bc2 /ui | |
parent | 844d0c18332d9317aba8531d9be3200ce2b2315d (diff) | |
download | jquery-ui-43ebec65763a6cd62b1d5189af83a954bb54ea53.tar.gz jquery-ui-43ebec65763a6cd62b1d5189af83a954bb54ea53.zip |
accordion: deprecated alwaysOpen option, introduced collapsible option (invert value) (fixes #3969)
Diffstat (limited to 'ui')
-rw-r--r-- | ui/ui.accordion.js | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/ui/ui.accordion.js b/ui/ui.accordion.js index c14d59319..c9330f64c 100644 --- a/ui/ui.accordion.js +++ b/ui/ui.accordion.js @@ -118,6 +118,11 @@ $.widget("ui.accordion", { contents.css("height", ""); } }, + + _setData: function(key, value) { + if(key == 'alwaysOpen') { key = 'collapsible'; value = !value; } + $.widget.prototype._setData.apply(this, arguments); + }, _keydown: function(event) { @@ -206,7 +211,7 @@ $.widget("ui.accordion", { if (o.disabled) return false; // called only when using activate(false) to close all parts programmatically - if (!event.target && !o.alwaysOpen) { + if (!event.target && o.collapsible) { 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'); @@ -228,7 +233,7 @@ $.widget("ui.accordion", { var clickedIsActive = clicked[0] == this.active[0]; // if animations are still active, or the active header is the target, ignore click - if (this.running || (o.alwaysOpen && clickedIsActive)) { + if (this.running || (!o.collapsible && clickedIsActive)) { return false; } @@ -247,9 +252,9 @@ $.widget("ui.accordion", { toHide = this.active.next(), data = { options: o, - newHeader: clickedIsActive && !o.alwaysOpen ? $([]) : clicked, + newHeader: clickedIsActive && o.collapsible ? $([]) : clicked, oldHeader: this.active, - newContent: clickedIsActive && !o.alwaysOpen ? $([]) : toShow.find('> *'), + newContent: clickedIsActive && o.collapsible ? $([]) : toShow.find('> *'), oldContent: toHide.find('> *') }, down = this.headers.index( this.active[0] ) > this.headers.index( clicked[0] ); @@ -281,7 +286,7 @@ $.widget("ui.accordion", { var animOptions = {}; - if ( !o.alwaysOpen && clickedIsActive ) { + if ( o.collapsible && clickedIsActive ) { animOptions = { toShow: $([]), toHide: toHide, @@ -330,7 +335,7 @@ $.widget("ui.accordion", { } else { - if (!o.alwaysOpen && clickedIsActive) { + if (o.collapsible && clickedIsActive) { toShow.toggle(); } else { toHide.hide(); @@ -371,7 +376,8 @@ $.extend($.ui.accordion, { defaults: { active: null, autoHeight: true, - alwaysOpen: true, + alwaysOpen: true, //deprecated, use collapsible + collapsible: false, animated: 'slide', clearStyle: false, event: "click", @@ -422,7 +428,7 @@ $.extend($.ui.accordion, { options.toShow.css({ height: 0, overflow: 'hidden' }).show(); options.toHide.filter(":hidden").each(options.complete).end().filter(":visible").animate(hideProps,{ step: function(now, settings) { - // if the alwaysOpen option is set to false, we may not have + // if the collapsible option is set to true, we may not have // a content pane to show if (!options.toShow[0]) { return; } |