@@ 117-151 (lines=35) @@ | ||
114 | closeOthers: true |
|
115 | }) |
|
116 | ||
117 | .controller('UibAccordionController', ['$scope', '$attrs', 'uibAccordionConfig', function($scope, $attrs, accordionConfig) { |
|
118 | // This array keeps track of the accordion groups |
|
119 | this.groups = []; |
|
120 | ||
121 | // Ensure that all the groups in this accordion are closed, unless close-others explicitly says not to |
|
122 | this.closeOthers = function(openGroup) { |
|
123 | var closeOthers = angular.isDefined($attrs.closeOthers) ? |
|
124 | $scope.$eval($attrs.closeOthers) : accordionConfig.closeOthers; |
|
125 | if (closeOthers) { |
|
126 | angular.forEach(this.groups, function(group) { |
|
127 | if (group !== openGroup) { |
|
128 | group.isOpen = false; |
|
129 | } |
|
130 | }); |
|
131 | } |
|
132 | }; |
|
133 | ||
134 | // This is called from the accordion-group directive to add itself to the accordion |
|
135 | this.addGroup = function(groupScope) { |
|
136 | var that = this; |
|
137 | this.groups.push(groupScope); |
|
138 | ||
139 | groupScope.$on('$destroy', function(event) { |
|
140 | that.removeGroup(groupScope); |
|
141 | }); |
|
142 | }; |
|
143 | ||
144 | // This is called from the accordion-group directive when to remove itself |
|
145 | this.removeGroup = function(group) { |
|
146 | var index = this.groups.indexOf(group); |
|
147 | if (index !== -1) { |
|
148 | this.groups.splice(index, 1); |
|
149 | } |
|
150 | }; |
|
151 | }]) |
|
152 | ||
153 | // The accordion directive simply sets up the directive controller |
|
154 | // and adds an accordion CSS class to itself element. |
@@ 116-150 (lines=35) @@ | ||
113 | closeOthers: true |
|
114 | }) |
|
115 | ||
116 | .controller('UibAccordionController', ['$scope', '$attrs', 'uibAccordionConfig', function($scope, $attrs, accordionConfig) { |
|
117 | // This array keeps track of the accordion groups |
|
118 | this.groups = []; |
|
119 | ||
120 | // Ensure that all the groups in this accordion are closed, unless close-others explicitly says not to |
|
121 | this.closeOthers = function(openGroup) { |
|
122 | var closeOthers = angular.isDefined($attrs.closeOthers) ? |
|
123 | $scope.$eval($attrs.closeOthers) : accordionConfig.closeOthers; |
|
124 | if (closeOthers) { |
|
125 | angular.forEach(this.groups, function(group) { |
|
126 | if (group !== openGroup) { |
|
127 | group.isOpen = false; |
|
128 | } |
|
129 | }); |
|
130 | } |
|
131 | }; |
|
132 | ||
133 | // This is called from the accordion-group directive to add itself to the accordion |
|
134 | this.addGroup = function(groupScope) { |
|
135 | var that = this; |
|
136 | this.groups.push(groupScope); |
|
137 | ||
138 | groupScope.$on('$destroy', function(event) { |
|
139 | that.removeGroup(groupScope); |
|
140 | }); |
|
141 | }; |
|
142 | ||
143 | // This is called from the accordion-group directive when to remove itself |
|
144 | this.removeGroup = function(group) { |
|
145 | var index = this.groups.indexOf(group); |
|
146 | if (index !== -1) { |
|
147 | this.groups.splice(index, 1); |
|
148 | } |
|
149 | }; |
|
150 | }]) |
|
151 | ||
152 | // The accordion directive simply sets up the directive controller |
|
153 | // and adds an accordion CSS class to itself element. |