diff --git a/src/accordion/accordion.js b/src/accordion/accordion.js index cb5c0b858d..1366fc1473 100644 --- a/src/accordion/accordion.js +++ b/src/accordion/accordion.js @@ -79,7 +79,9 @@ angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse']) link: function(scope, element, attrs, accordionCtrl) { accordionCtrl.addGroup(scope); + scope.openClass = attrs.openClass || 'panel-open'; scope.$watch('isOpen', function(value) { + element.toggleClass(scope.openClass, value); if (value) { accordionCtrl.closeOthers(scope); } diff --git a/src/accordion/test/accordion.spec.js b/src/accordion/test/accordion.spec.js index b3fcd94a52..fc4f0ecabd 100644 --- a/src/accordion/test/accordion.spec.js +++ b/src/accordion/test/accordion.spec.js @@ -212,7 +212,7 @@ describe('accordion', function() { expect(findGroupBody(0).scope().isOpen).toBe(false); }); - it('should add "open" when opened', function() { + it('should add, by default, "panel-open" when opened', function() { var group = groups.eq(0); findGroupLink(0).click(); scope.$digest(); @@ -224,6 +224,34 @@ describe('accordion', function() { }); }); + describe('with open-class attribute', function() { + beforeEach(function() { + var tpl = + '' + + 'Content 1' + + 'Content 2' + + ''; + element = angular.element(tpl); + $compile(element)(scope); + scope.$digest(); + groups = element.find('.panel'); + }); + afterEach(function() { + element.remove(); + }); + + it('should add &open-class when opened', function() { + var group = groups.eq(0); + findGroupLink(0).click(); + scope.$digest(); + expect(group).toHaveClass('custom-open-class'); + + findGroupLink(0).click(); + scope.$digest(); + expect(group).not.toHaveClass('custom-open-class'); + }); + }); + describe('with dynamic panels', function() { var model; beforeEach(function() { diff --git a/template/accordion/accordion-group.html b/template/accordion/accordion-group.html index 0b6274e233..8ad810abe8 100644 --- a/template/accordion/accordion-group.html +++ b/template/accordion/accordion-group.html @@ -1,4 +1,4 @@ -
+