Skip to content

Commit e2560f6

Browse files
committed
Accordion: Always have _activate delegate to _eventHandler.
1 parent ed57047 commit e2560f6

File tree

1 file changed

+10
-35
lines changed

1 file changed

+10
-35
lines changed

ui/jquery.ui.accordion.js

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -262,46 +262,21 @@ $.widget( "ui.accordion", {
262262
},
263263

264264
_activate: function( index ) {
265-
var active = this._findActive( index )[ 0 ],
266-
eventData = {
267-
oldHeader: this.active,
268-
oldContent: this.active.next(),
269-
newHeader: $(),
270-
newContent: $()
271-
};
272-
273-
// we found a header to activate, just delegate to the event handler
274-
if ( active ) {
275-
if ( active !== this.active[ 0 ] ) {
276-
this._eventHandler({
277-
target: active,
278-
currentTarget: active,
279-
preventDefault: $.noop
280-
});
281-
}
282-
return;
283-
}
265+
var active = this._findActive( index )[ 0 ];
284266

285-
// no header to activate, check if we can collapse
286-
if ( !this.options.collapsible ) {
267+
// trying to activate the already active panel
268+
if ( active === this.active[ 0 ] ) {
287269
return;
288270
}
289271

290-
// allow the activation to be canceled
291-
if ( this._trigger( "beforeActivate", null, eventData ) === false ) {
292-
return;
293-
}
272+
// trying to collapse, simulate a click on the currently active header
273+
active = active || this.active;
294274

295-
this.active
296-
.removeClass( "ui-state-active ui-corner-top" )
297-
.addClass( "ui-state-default ui-corner-all" )
298-
.children( ".ui-accordion-header-icon" )
299-
.removeClass( this.options.icons.activeHeader )
300-
.addClass( this.options.icons.header );
301-
this.active.next().addClass( "ui-accordion-content-active" );
302-
this.options.active = false;
303-
this.active = $();
304-
this._toggle( eventData );
275+
this._eventHandler({
276+
target: active,
277+
currentTarget: active,
278+
preventDefault: $.noop
279+
});
305280
},
306281

307282
_findActive: function( selector ) {

0 commit comments

Comments
 (0)