11/*!
2- * # Semantic UI 1.12.3 - Accordion
2+ * # Semantic UI 2.0.0 - Accordion
33 * http://github.com/semantic-org/semantic-ui/
44 *
55 *
6- * Copyright 2014 Contributors
6+ * Copyright 2015 Contributors
77 * Released under the MIT license
88 * http://opensource.org/licenses/MIT
99 *
@@ -105,7 +105,7 @@ $.fn.accordion = function(parameters) {
105105 events : function ( ) {
106106 module . debug ( 'Binding delegated events' ) ;
107107 $module
108- . on ( 'click' + eventNamespace , selector . trigger , module . event . click )
108+ . on ( settings . on + eventNamespace , selector . trigger , module . event . click )
109109 ;
110110 }
111111 } ,
@@ -153,54 +153,59 @@ $.fn.accordion = function(parameters) {
153153 $activeContent = $activeTitle . next ( $content ) ,
154154 isAnimating = $activeContent . hasClass ( className . animating ) ,
155155 isActive = $activeContent . hasClass ( className . active ) ,
156- isUnopen = ( ! isActive && ! isAnimating )
156+ isOpen = ( isActive || isAnimating )
157157 ;
158- if ( isUnopen ) {
159- module . debug ( 'Opening accordion content' , $activeTitle ) ;
160- if ( settings . exclusive ) {
161- module . closeOthers . call ( $activeTitle ) ;
158+ if ( isOpen ) {
159+ module . debug ( 'Accordion already open, skipping' , $activeContent ) ;
160+ return ;
161+ }
162+ module . debug ( 'Opening accordion content' , $activeTitle ) ;
163+ settings . onOpening . call ( $activeContent ) ;
164+ if ( settings . exclusive ) {
165+ module . closeOthers . call ( $activeTitle ) ;
166+ }
167+ $activeTitle
168+ . addClass ( className . active )
169+ ;
170+ $activeContent
171+ . stop ( true , true )
172+ . addClass ( className . animating )
173+ ;
174+ if ( settings . animateChildren ) {
175+ if ( $ . fn . transition !== undefined && $module . transition ( 'is supported' ) ) {
176+ $activeContent
177+ . children ( )
178+ . transition ( {
179+ animation : 'fade in' ,
180+ queue : false ,
181+ useFailSafe : true ,
182+ debug : settings . debug ,
183+ verbose : settings . verbose ,
184+ duration : settings . duration
185+ } )
186+ ;
162187 }
163- $activeTitle
164- . addClass ( className . active )
165- ;
166- $activeContent . addClass ( className . animating ) ;
167- if ( settings . animateChildren ) {
168- if ( $ . fn . transition !== undefined && $module . transition ( 'is supported' ) ) {
169- $activeContent
170- . children ( )
171- . transition ( {
172- animation : 'fade in' ,
173- queue : false ,
174- useFailSafe : true ,
175- debug : settings . debug ,
176- verbose : settings . verbose ,
177- duration : settings . duration
178- } )
179- ;
180- }
181- else {
182- $activeContent
183- . children ( )
184- . stop ( true )
185- . animate ( {
186- opacity : 1
187- } , settings . duration , module . resetOpacity )
188- ;
189- }
188+ else {
189+ $activeContent
190+ . children ( )
191+ . stop ( true , true )
192+ . animate ( {
193+ opacity : 1
194+ } , settings . duration , module . resetOpacity )
195+ ;
190196 }
191- $activeContent
192- . stop ( true )
193- . slideDown ( settings . duration , settings . easing , function ( ) {
194- $activeContent
195- . removeClass ( className . animating )
196- . addClass ( className . active )
197- ;
198- module . reset . display . call ( this ) ;
199- settings . onOpen . call ( this ) ;
200- settings . onChange . call ( this ) ;
201- } )
202- ;
203197 }
198+ $activeContent
199+ . slideDown ( settings . duration , settings . easing , function ( ) {
200+ $activeContent
201+ . removeClass ( className . animating )
202+ . addClass ( className . active )
203+ ;
204+ module . reset . display . call ( this ) ;
205+ settings . onOpen . call ( this ) ;
206+ settings . onChange . call ( this ) ;
207+ } )
208+ ;
204209 } ,
205210
206211 close : function ( query ) {
@@ -218,10 +223,12 @@ $.fn.accordion = function(parameters) {
218223 ;
219224 if ( ( isActive || isOpening ) && ! isClosing ) {
220225 module . debug ( 'Closing accordion content' , $activeContent ) ;
226+ settings . onClosing . call ( $activeContent ) ;
221227 $activeTitle
222228 . removeClass ( className . active )
223229 ;
224230 $activeContent
231+ . stop ( true , true )
225232 . addClass ( className . animating )
226233 ;
227234 if ( settings . animateChildren ) {
@@ -241,15 +248,14 @@ $.fn.accordion = function(parameters) {
241248 else {
242249 $activeContent
243250 . children ( )
244- . stop ( true )
251+ . stop ( true , true )
245252 . animate ( {
246253 opacity : 0
247254 } , settings . duration , module . resetOpacity )
248255 ;
249256 }
250257 }
251258 $activeContent
252- . stop ( true )
253259 . slideUp ( settings . duration , settings . easing , function ( ) {
254260 $activeContent
255261 . removeClass ( className . animating )
@@ -291,6 +297,10 @@ $.fn.accordion = function(parameters) {
291297 $openTitles
292298 . removeClass ( className . active )
293299 ;
300+ $openContents
301+ . removeClass ( className . animating )
302+ . stop ( true , true )
303+ ;
294304 if ( settings . animateChildren ) {
295305 if ( $ . fn . transition !== undefined && $module . transition ( 'is supported' ) ) {
296306 $openContents
@@ -307,15 +317,14 @@ $.fn.accordion = function(parameters) {
307317 else {
308318 $openContents
309319 . children ( )
310- . stop ( )
320+ . stop ( true , true )
311321 . animate ( {
312322 opacity : 0
313323 } , settings . duration , module . resetOpacity )
314324 ;
315325 }
316326 }
317327 $openContents
318- . stop ( )
319328 . slideUp ( settings . duration , settings . easing , function ( ) {
320329 $ ( this ) . removeClass ( className . active ) ;
321330 module . reset . display . call ( this ) ;
@@ -422,7 +431,7 @@ $.fn.accordion = function(parameters) {
422431 } ) ;
423432 }
424433 clearTimeout ( module . performance . timer ) ;
425- module . performance . timer = setTimeout ( module . performance . display , 100 ) ;
434+ module . performance . timer = setTimeout ( module . performance . display , 500 ) ;
426435 } ,
427436 display : function ( ) {
428437 var
@@ -534,9 +543,11 @@ $.fn.accordion.settings = {
534543 namespace : 'accordion' ,
535544
536545 debug : false ,
537- verbose : true ,
546+ verbose : false ,
538547 performance : true ,
539548
549+ on : 'click' ,
550+
540551 exclusive : true ,
541552 collapsible : true ,
542553 closeNested : false ,
@@ -545,7 +556,10 @@ $.fn.accordion.settings = {
545556 duration : 350 ,
546557 easing : 'easeOutQuad' ,
547558
559+
560+ onOpening : function ( ) { } ,
548561 onOpen : function ( ) { } ,
562+ onClosing : function ( ) { } ,
549563 onClose : function ( ) { } ,
550564 onChange : function ( ) { } ,
551565
0 commit comments