Skip to content

Commit 7833dac

Browse files
author
0xAX
committed
[#1] close-all bug fixed
1 parent 70e0ed7 commit 7833dac

3 files changed

Lines changed: 17 additions & 17 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ node_modules/
99
/docs/
1010
/test/coverage/
1111
!.gitignore
12-
!dist/
12+
!dist/
13+
css/

dist/angular-semantic-ui-0.0.1.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/accordion/accordion.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)