diff --git a/src/accordion/accordion.js b/src/accordion/accordion.js index 1366fc1473..0d24ba4979 100644 --- a/src/accordion/accordion.js +++ b/src/accordion/accordion.js @@ -80,6 +80,7 @@ angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse']) accordionCtrl.addGroup(scope); scope.openClass = attrs.openClass || 'panel-open'; + scope.panelClass = attrs.panelClass; scope.$watch('isOpen', function(value) { element.toggleClass(scope.openClass, value); if (value) { diff --git a/src/accordion/docs/readme.md b/src/accordion/docs/readme.md index 7a186cb020..7d850b95f2 100644 --- a/src/accordion/docs/readme.md +++ b/src/accordion/docs/readme.md @@ -13,5 +13,7 @@ The body of each accordion group is transcluded in to the body of the collapsibl ### Accordion Group Settings ### + * `panel-class` (Defaults: `panel-default`) : + Add ability to use Bootstrap's contextual panel classes (panel-primary, panel-success, panel-info, etc...) or your own. This must be a string. * `template-url` (Defaults: `template/accordion/accordion-group.html`) : Add ability to override the template url used. Note that this must be a string diff --git a/src/accordion/test/accordion.spec.js b/src/accordion/test/accordion.spec.js index 12236aa806..c0b11e1d13 100644 --- a/src/accordion/test/accordion.spec.js +++ b/src/accordion/test/accordion.spec.js @@ -515,7 +515,6 @@ describe('accordion', function() { }); }); - describe('accordion-heading attribute, with repeating accordion-groups', function() { it('should clone the accordion-heading for each group', function() { element = $compile('
{{x}}
')(scope); @@ -528,5 +527,26 @@ describe('accordion', function() { }); }); + describe('accordion group panel class - #3968', function() { + it('should use the default value when panel class is falsy', function() { + element = $compile('Content')(scope); + scope.$digest(); + groups = element.find('.panel'); + expect(groups.eq(0)).toHaveClass('panel-default'); + + element = $compile('Content')(scope); + scope.$digest(); + groups = element.find('.panel'); + expect(groups.eq(0)).toHaveClass('panel-default'); + }); + + it('should use the specified value when not falsy', function() { + element = $compile('Content')(scope); + scope.$digest(); + groups = element.find('.panel'); + expect(groups.eq(0)).toHaveClass('custom-class'); + expect(groups.eq(0)).not.toHaveClass('panel-default'); + }); + }); }); }); diff --git a/template/accordion/accordion-group.html b/template/accordion/accordion-group.html index 8ad810abe8..aec5413578 100644 --- a/template/accordion/accordion-group.html +++ b/template/accordion/accordion-group.html @@ -1,4 +1,4 @@ -
+