@@ -15,19 +15,23 @@ angular.module('angularify.semantic.accordion', [])
1515 return $scope . accordions ;
1616 }
1717
18- this . closeAll = function ( ) {
18+ this . closeAll = function ( scope ) {
1919 var i = 0 ;
2020 var isCloseAll = false ;
2121
22+ var index = $scope . accordions . indexOf ( scope ) ;
23+
2224 for ( i in $scope . accordions ) {
2325 if ( $scope . accordions [ i ] . close )
2426 isCloseAll = true ;
2527 }
2628
2729 if ( isCloseAll == true ) {
2830 for ( i in $scope . accordions ) {
29- $scope . accordions [ i ] . class = 'title' ;
30- $scope . accordions [ i ] . content_class = 'content' ;
31+ if ( i == index ) { } else {
32+ $scope . accordions [ i ] . class = 'title' ;
33+ $scope . accordions [ i ] . content_class = 'content' ;
34+ }
3135 }
3236
3337 return true ;
@@ -112,20 +116,15 @@ angular.module('angularify.semantic.accordion', [])
112116 //
113117 scope . click_on_accordeon_tab = function ( ) {
114118 // class all first of all
115- if ( AccordionController . closeAll ( ) == true )
116- scope . isOpen = false ;
117-
118- // change current state
119- scope . isOpen = ! scope . isOpen ;
119+ AccordionController . closeAll ( scope )
120120
121- if ( scope . isOpen == true ) {
121+ if ( scope . content_class == 'active content' ) {
122+ scope . class = 'title' ;
123+ scope . content_class = 'content' ;
124+ } else {
122125 scope . class = 'active title' ;
123- scope . content_class = 'active content' ;
124- return ;
125- }
126-
127- scope . class = 'title' ;
128- scope . content_class = 'content' ;
126+ scope . content_class = 'active content' ;
127+ }
129128 }
130129 }
131130 }
0 commit comments