@@ -31,7 +31,7 @@ $.widget( "ui.accordion", {
31
31
var self = this ,
32
32
options = self . options ;
33
33
34
- self . running = 0 ;
34
+ self . running = false ;
35
35
36
36
self . element . addClass ( "ui-accordion ui-widget ui-helper-reset" ) ;
37
37
@@ -344,47 +344,13 @@ $.widget( "ui.accordion", {
344
344
toHide = data . oldContent ,
345
345
down = toShow . length && ( ! toHide . length || ( toShow . index ( ) < toHide . index ( ) ) ) ;
346
346
347
- self . toShow = toShow ;
348
- self . toHide = toHide ;
349
- self . data = data ;
350
-
351
- var complete = function ( ) {
352
- if ( ! self ) {
353
- return ;
354
- }
355
- return self . _completed . apply ( self , arguments ) ;
356
- } ;
357
-
358
- // count elements to animate
359
- self . running = toHide . size ( ) === 0 ? toShow . size ( ) : toHide . size ( ) ;
347
+ self . running = true ;
348
+ function complete ( ) {
349
+ self . _completed ( data ) ;
350
+ }
360
351
361
352
if ( options . animated ) {
362
- var animOptions = {
363
- toShow : toShow ,
364
- toHide : toHide ,
365
- complete : complete ,
366
- down : down ,
367
- autoHeight : options . heightStyle !== "content"
368
- } ;
369
-
370
- if ( ! options . proxied ) {
371
- options . proxied = options . animated ;
372
- }
373
-
374
- if ( ! options . proxiedDuration ) {
375
- options . proxiedDuration = options . duration ;
376
- }
377
-
378
- options . animated = $ . isFunction ( options . proxied ) ?
379
- options . proxied ( animOptions ) :
380
- options . proxied ;
381
-
382
- options . duration = $ . isFunction ( options . proxiedDuration ) ?
383
- options . proxiedDuration ( animOptions ) :
384
- options . proxiedDuration ;
385
-
386
353
var animations = $ . ui . accordion . animations ,
387
- duration = options . duration ,
388
354
easing = options . animated ;
389
355
390
356
if ( easing && ! animations [ easing ] && ! $ . easing [ easing ] ) {
@@ -394,16 +360,22 @@ $.widget( "ui.accordion", {
394
360
animations [ easing ] = function ( options ) {
395
361
this . slide ( options , {
396
362
easing : easing ,
397
- duration : duration || 700
363
+ duration : 700
398
364
} ) ;
399
365
} ;
400
366
}
401
367
402
- animations [ easing ] ( animOptions ) ;
368
+ animations [ easing ] ( {
369
+ toShow : toShow ,
370
+ toHide : toHide ,
371
+ complete : complete ,
372
+ down : down ,
373
+ autoHeight : options . heightStyle !== "content"
374
+ } ) ;
403
375
} else {
404
376
toHide . hide ( ) ;
405
377
toShow . show ( ) ;
406
- complete ( true ) ;
378
+ complete ( ) ;
407
379
}
408
380
409
381
// TODO assert that the blur and focus triggers are really necessary, remove otherwise
@@ -421,27 +393,27 @@ $.widget( "ui.accordion", {
421
393
. focus ( ) ;
422
394
} ,
423
395
424
- _completed : function ( cancel ) {
425
- this . running = cancel ? 0 : -- this . running ;
426
- if ( this . running ) {
427
- return ;
428
- }
396
+ _completed : function ( data ) {
397
+ var toShow = data . newContent ,
398
+ toHide = data . oldContent ;
399
+
400
+ this . running = false ;
429
401
430
402
if ( this . options . heightStyle === "content" ) {
431
- this . toShow . add ( this . toHide ) . css ( {
403
+ toShow . add ( toHide ) . css ( {
432
404
height : "" ,
433
405
overflow : ""
434
406
} ) ;
435
407
}
436
408
437
409
// other classes are removed before the animation; this one needs to stay until completed
438
- this . toHide . removeClass ( "ui-accordion-content-active" ) ;
410
+ toHide . removeClass ( "ui-accordion-content-active" ) ;
439
411
// Work around for rendering bug in IE (#5421)
440
- if ( this . toHide . length ) {
441
- this . toHide . parent ( ) [ 0 ] . className = this . toHide . parent ( ) [ 0 ] . className ;
412
+ if ( toHide . length ) {
413
+ toHide . parent ( ) [ 0 ] . className = toHide . parent ( ) [ 0 ] . className ;
442
414
}
443
415
444
- this . _trigger ( "activate" , null , this . data ) ;
416
+ this . _trigger ( "activate" , null , data ) ;
445
417
}
446
418
} ) ;
447
419
0 commit comments