aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-02-04 21:52:09 -0500
committerScott González <scott.gonzalez@gmail.com>2011-02-04 21:52:09 -0500
commite2560f654e6f427768089cbb41673c2e9a82145f (patch)
tree742fb5a9793c279f96a0ea857a91b333cb1f94ac /ui
parented57047bf968244a168050ab63344e3c0d5546ee (diff)
downloadjquery-ui-e2560f654e6f427768089cbb41673c2e9a82145f.tar.gz
jquery-ui-e2560f654e6f427768089cbb41673c2e9a82145f.zip
Accordion: Always have _activate delegate to _eventHandler.
Diffstat (limited to 'ui')
-rw-r--r--ui/jquery.ui.accordion.js45
1 files changed, 10 insertions, 35 deletions
diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js
index 9bfa35435..36c1c2c75 100644
--- a/ui/jquery.ui.accordion.js
+++ b/ui/jquery.ui.accordion.js
@@ -262,46 +262,21 @@ $.widget( "ui.accordion", {
},
_activate: function( index ) {
- var active = this._findActive( index )[ 0 ],
- eventData = {
- oldHeader: this.active,
- oldContent: this.active.next(),
- newHeader: $(),
- newContent: $()
- };
-
- // we found a header to activate, just delegate to the event handler
- if ( active ) {
- if ( active !== this.active[ 0 ] ) {
- this._eventHandler({
- target: active,
- currentTarget: active,
- preventDefault: $.noop
- });
- }
- return;
- }
+ var active = this._findActive( index )[ 0 ];
- // no header to activate, check if we can collapse
- if ( !this.options.collapsible ) {
+ // trying to activate the already active panel
+ if ( active === this.active[ 0 ] ) {
return;
}
- // allow the activation to be canceled
- if ( this._trigger( "beforeActivate", null, eventData ) === false ) {
- return;
- }
+ // trying to collapse, simulate a click on the currently active header
+ active = active || this.active;
- this.active
- .removeClass( "ui-state-active ui-corner-top" )
- .addClass( "ui-state-default ui-corner-all" )
- .children( ".ui-accordion-header-icon" )
- .removeClass( this.options.icons.activeHeader )
- .addClass( this.options.icons.header );
- this.active.next().addClass( "ui-accordion-content-active" );
- this.options.active = false;
- this.active = $();
- this._toggle( eventData );
+ this._eventHandler({
+ target: active,
+ currentTarget: active,
+ preventDefault: $.noop
+ });
},
_findActive: function( selector ) {