@@ -262,46 +262,21 @@ $.widget( "ui.accordion", {
262
262
} ,
263
263
264
264
_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 ] ;
284
266
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 ] ) {
287
269
return ;
288
270
}
289
271
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 ;
294
274
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
+ } ) ;
305
280
} ,
306
281
307
282
_findActive : function ( selector ) {
0 commit comments