Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
feat(accordion): add bound panel-class support
Browse files Browse the repository at this point in the history
- Add `@` binding support for `panel-class`

Closes #5368
Closes #5596
  • Loading branch information
Daniel Blanco authored and wesleycho committed Mar 7, 2016
1 parent d6b9ee1 commit ffb5529
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/accordion/accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse'])
},
scope: {
heading: '@', // Interpolate the heading attribute onto this scope
panelClass: '@?', // Ditto with panelClass
isOpen: '=?',
isDisabled: '=?'
},
Expand Down
1 change: 1 addition & 0 deletions src/accordion/docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ The body of each accordion group is transcluded into the body of the collapsible
Whether accordion group is open or closed.

* `panel-class`
<i class="glyphicon glyphicon-eye-open"></i>
_(Default: `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.

Expand Down
19 changes: 16 additions & 3 deletions src/accordion/test/accordion.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,8 +610,8 @@ describe('uib-accordion', function() {
});
});

describe('uib-accordion group panel class - #3968', function() {
it('should use the default value when panel class is falsy', function() {
describe('uib-accordion group panel class', function() {
it('should use the default value when panel class is falsy - #3968', function() {
element = $compile('<uib-accordion><uib-accordion-group heading="Heading">Content</uib-accordion-group></uib-accordion>')(scope);
scope.$digest();
groups = element.find('.panel');
Expand All @@ -623,13 +623,26 @@ describe('uib-accordion', function() {
expect(groups.eq(0)).toHaveClass('panel-default');
});

it('should use the specified value when not falsy', function() {
it('should use the specified value when not falsy - #3968', function() {
element = $compile('<uib-accordion><uib-accordion-group heading="Heading" panel-class="custom-class">Content</uib-accordion-group></uib-accordion>')(scope);
scope.$digest();
groups = element.find('.panel');
expect(groups.eq(0)).toHaveClass('custom-class');
expect(groups.eq(0)).not.toHaveClass('panel-default');
});

it('should change class if panel-class is changed', function() {
element = $compile('<uib-accordion><uib-accordion-group heading="Heading" panel-class="{{panelClass}}">Content</uib-accordion-group></uib-accordion>')(scope);
scope.panelClass = 'custom-class';
scope.$digest();
groups = element.find('.panel');
expect(groups.eq(0)).toHaveClass('custom-class');

scope.panelClass = 'different-class';
scope.$digest();
expect(groups.eq(0)).toHaveClass('different-class');
expect(groups.eq(0)).not.toHaveClass('custom-class');
});
});
});
});

0 comments on commit ffb5529

Please sign in to comment.