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

Commit 458a9bd

Browse files
Justin Hallpkozlowski-opensource
Justin Hall
authored andcommitted
feat(accordion): convert to bootstrap3 panel styling
1 parent b0032d6 commit 458a9bd

File tree

4 files changed

+39
-34
lines changed

4 files changed

+39
-34
lines changed

src/accordion/docs/demo.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
</accordion-group>
1414
<accordion-group heading="Dynamic Body Content">
1515
<p>The body of the accordion group grows to fit the contents</p>
16-
<button class="btn btn-small" ng-click="addItem()">Add Item</button>
16+
<button class="btn btn-default btn-small" ng-click="addItem()">Add Item</button>
1717
<div ng-repeat="item in items">{{item}}</div>
1818
</accordion-group>
1919
<accordion-group is-open="isopen">
2020
<accordion-heading>
21-
I can have markup, too! <i class="pull-right" ng-class="{'icon-chevron-down': isopen, 'icon-chevron-right': !isopen}"></i>
21+
I can have markup, too! <i class="pull-right glyphicon" ng-class="{'glyphicon-chevron-down': isopen, 'glyphicon-chevron-right': !isopen}"></i>
2222
</accordion-heading>
2323
This is just some content to illustrate fancy headings.
2424
</accordion-group>

src/accordion/test/accordion.spec.js

+27-27
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('accordion', function () {
1818
}));
1919

2020
describe('addGroup', function() {
21-
it('adds a the specified group to the collection', function() {
21+
it('adds a the specified panel to the collection', function() {
2222
var group1, group2;
2323
ctrl.addGroup(group1 = $scope.$new());
2424
ctrl.addGroup(group2 = $scope.$new());
@@ -35,23 +35,23 @@ describe('accordion', function () {
3535
ctrl.addGroup(group2 = { isOpen: true, $on : angular.noop });
3636
ctrl.addGroup(group3 = { isOpen: true, $on : angular.noop });
3737
});
38-
it('should close other groups if close-others attribute is not defined', function() {
38+
it('should close other panels if close-others attribute is not defined', function() {
3939
delete $attrs.closeOthers;
4040
ctrl.closeOthers(group2);
4141
expect(group1.isOpen).toBe(false);
4242
expect(group2.isOpen).toBe(true);
4343
expect(group3.isOpen).toBe(false);
4444
});
4545

46-
it('should close other groups if close-others attribute is true', function() {
46+
it('should close other panels if close-others attribute is true', function() {
4747
$attrs.closeOthers = 'true';
4848
ctrl.closeOthers(group3);
4949
expect(group1.isOpen).toBe(false);
5050
expect(group2.isOpen).toBe(false);
5151
expect(group3.isOpen).toBe(true);
5252
});
5353

54-
it('should not close other groups if close-others attribute is false', function() {
54+
it('should not close other panels if close-others attribute is false', function() {
5555
$attrs.closeOthers = 'false';
5656
ctrl.closeOthers(group2);
5757
expect(group1.isOpen).toBe(true);
@@ -70,7 +70,7 @@ describe('accordion', function () {
7070
accordionConfig.closeOthers = originalCloseOthers;
7171
}));
7272

73-
it('should not close other groups if accordionConfig.closeOthers is false', function() {
73+
it('should not close other panels if accordionConfig.closeOthers is false', function() {
7474
ctrl.closeOthers(group2);
7575
expect(group1.isOpen).toBe(true);
7676
expect(group2.isOpen).toBe(true);
@@ -80,7 +80,7 @@ describe('accordion', function () {
8080
});
8181

8282
describe('removeGroup', function() {
83-
it('should remove the specified group', function () {
83+
it('should remove the specified panel', function () {
8484
var group1, group2, group3;
8585
ctrl.addGroup(group1 = $scope.$new());
8686
ctrl.addGroup(group2 = $scope.$new());
@@ -90,7 +90,7 @@ describe('accordion', function () {
9090
expect(ctrl.groups[0]).toBe(group1);
9191
expect(ctrl.groups[1]).toBe(group3);
9292
});
93-
it('should ignore remove of non-existing group', function () {
93+
it('should ignore remove of non-existing panel', function () {
9494
var group1, group2;
9595
ctrl.addGroup(group1 = $scope.$new());
9696
ctrl.addGroup(group2 = $scope.$new());
@@ -109,7 +109,7 @@ describe('accordion', function () {
109109
return groups.eq(index).find('a').eq(0);
110110
};
111111
var findGroupBody = function (index) {
112-
return groups.eq(index).find('.accordion-body').eq(0);
112+
return groups.eq(index).find('.panel-collapse').eq(0);
113113
};
114114

115115

@@ -122,7 +122,7 @@ describe('accordion', function () {
122122
element = groups = scope = $compile = undefined;
123123
});
124124

125-
describe('with static groups', function () {
125+
describe('with static panels', function () {
126126
beforeEach(function () {
127127
var tpl =
128128
"<accordion>" +
@@ -133,13 +133,13 @@ describe('accordion', function () {
133133
angular.element(document.body).append(element);
134134
$compile(element)(scope);
135135
scope.$digest();
136-
groups = element.find('.accordion-group');
136+
groups = element.find('.panel');
137137
});
138138
afterEach(function() {
139139
element.remove();
140140
});
141141

142-
it('should create accordion groups with content', function () {
142+
it('should create accordion panels with content', function () {
143143
expect(groups.length).toEqual(2);
144144
expect(findGroupLink(0).text()).toEqual('title 1');
145145
expect(findGroupBody(0).text().trim()).toEqual('Content 1');
@@ -168,7 +168,7 @@ describe('accordion', function () {
168168
});
169169
});
170170

171-
describe('with dynamic groups', function () {
171+
describe('with dynamic panels', function () {
172172
var model;
173173
beforeEach(function () {
174174
var tpl =
@@ -185,15 +185,15 @@ describe('accordion', function () {
185185
scope.$digest();
186186
});
187187

188-
it('should have no groups initially', function () {
189-
groups = element.find('.accordion-group');
188+
it('should have no panels initially', function () {
189+
groups = element.find('.panel');
190190
expect(groups.length).toEqual(0);
191191
});
192192

193-
it('should have a group for each model item', function() {
193+
it('should have a panel for each model item', function() {
194194
scope.groups = model;
195195
scope.$digest();
196-
groups = element.find('.accordion-group');
196+
groups = element.find('.panel');
197197
expect(groups.length).toEqual(2);
198198
expect(findGroupLink(0).text()).toEqual('title 1');
199199
expect(findGroupBody(0).text().trim()).toEqual('Content 1');
@@ -204,12 +204,12 @@ describe('accordion', function () {
204204
it('should react properly on removing items from the model', function () {
205205
scope.groups = model;
206206
scope.$digest();
207-
groups = element.find('.accordion-group');
207+
groups = element.find('.panel');
208208
expect(groups.length).toEqual(2);
209209

210210
scope.groups.splice(0,1);
211211
scope.$digest();
212-
groups = element.find('.accordion-group');
212+
groups = element.find('.panel');
213213
expect(groups.length).toEqual(1);
214214
});
215215
});
@@ -225,10 +225,10 @@ describe('accordion', function () {
225225
scope.open = { first: false, second: true };
226226
$compile(element)(scope);
227227
scope.$digest();
228-
groups = element.find('.accordion-group');
228+
groups = element.find('.panel');
229229
});
230230

231-
it('should open the group with isOpen set to true', function () {
231+
it('should open the panel with isOpen set to true', function () {
232232
expect(findGroupBody(0).scope().isOpen).toBe(false);
233233
expect(findGroupBody(1).scope().isOpen).toBe(true);
234234
});
@@ -258,14 +258,14 @@ describe('accordion', function () {
258258
angular.element(document.body).append(element);
259259
$compile(element)(scope);
260260
scope.$digest();
261-
groups = element.find('.accordion-group');
261+
groups = element.find('.panel');
262262
});
263263

264264
afterEach(function() {
265265
element.remove();
266266
});
267267

268-
it('should have visible group body when the group with isOpen set to true', function () {
268+
it('should have visible panel body when the group with isOpen set to true', function () {
269269
expect(findGroupBody(0)[0].clientHeight).not.toBe(0);
270270
expect(findGroupBody(1)[0].clientHeight).toBe(0);
271271
});
@@ -286,7 +286,7 @@ describe('accordion', function () {
286286
$compile(element)(scope);
287287
scope.$digest();
288288

289-
groups = element.find('.accordion-group');
289+
groups = element.find('.panel');
290290
});
291291

292292
it('should have visible group body when the group with isOpen set to true', function () {
@@ -318,7 +318,7 @@ describe('accordion', function () {
318318
'</accordion>';
319319
element = $compile(tpl)(scope);
320320
scope.$digest();
321-
groups = element.find('.accordion-group');
321+
groups = element.find('.panel');
322322
});
323323
it('transcludes the <accordion-heading> content into the heading link', function() {
324324
expect(findGroupLink(0).text()).toBe('Heading Element 123 ');
@@ -340,7 +340,7 @@ describe('accordion', function () {
340340
'</accordion>';
341341
element = $compile(tpl)(scope);
342342
scope.$digest();
343-
groups = element.find('.accordion-group');
343+
groups = element.find('.panel');
344344
});
345345
it('transcludes the <accordion-heading> content into the heading link', function() {
346346
expect(findGroupLink(0).text()).toBe('Heading Element 123 ');
@@ -355,7 +355,7 @@ describe('accordion', function () {
355355
it('should clone the accordion-heading for each group', function() {
356356
element = $compile('<accordion><accordion-group ng-repeat="x in [1,2,3]"><accordion-heading>{{x}}</accordion-heading></accordion-group></accordion>')(scope);
357357
scope.$digest();
358-
groups = element.find('.accordion-group');
358+
groups = element.find('.panel');
359359
expect(groups.length).toBe(3);
360360
expect(findGroupLink(0).text()).toBe('1');
361361
expect(findGroupLink(1).text()).toBe('2');
@@ -368,7 +368,7 @@ describe('accordion', function () {
368368
it('should clone the accordion-heading for each group', function() {
369369
element = $compile('<accordion><accordion-group ng-repeat="x in [1,2,3]"><div accordion-heading>{{x}}</div></accordion-group></accordion>')(scope);
370370
scope.$digest();
371-
groups = element.find('.accordion-group');
371+
groups = element.find('.panel');
372372
expect(groups.length).toBe(3);
373373
expect(findGroupLink(0).text()).toBe('1');
374374
expect(findGroupLink(1).text()).toBe('2');
+9-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
<div class="accordion-group">
2-
<div class="accordion-heading" ><a class="accordion-toggle" ng-click="isOpen = !isOpen" accordion-transclude="heading">{{heading}}</a></div>
3-
<div class="accordion-body" collapse="!isOpen">
4-
<div class="accordion-inner" ng-transclude></div> </div>
1+
<div class="panel panel-default">
2+
<div class="panel-heading">
3+
<h4 class="panel-title">
4+
<a class="accordion-toggle" ng-click="isOpen = !isOpen" accordion-transclude="heading">{{heading}}</a>
5+
</h4>
6+
</div>
7+
<div class="panel-collapse" collapse="!isOpen">
8+
<div class="panel-body" ng-transclude></div>
9+
</div>
510
</div>

template/accordion/accordion.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<div class="accordion" ng-transclude></div>
1+
<div class="panel-group" ng-transclude></div>

0 commit comments

Comments
 (0)