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

Commit 8cbeff0

Browse files
Justin Hallpkozlowski-opensource
Justin Hall
authored andcommitted
feat(accordion): convert to bootstrap3 panel styling
1 parent c6197ed commit 8cbeff0

File tree

4 files changed

+38
-33
lines changed

4 files changed

+38
-33
lines changed

src/accordion/docs/demo.html

Lines changed: 2 additions & 2 deletions
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>
2020
<accordion-heading>
21-
I can have markup, too! <i class="icon-check"></i>
21+
I can have markup, too! <i class="glyphicon glyphicon-check"></i>
2222
</accordion-heading>
2323
This is just some content to illustrate fancy headings.
2424
</accordion-group>

src/accordion/test/accordionSpec.js

Lines changed: 26 additions & 26 deletions
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
});
@@ -226,10 +226,10 @@ describe('accordion', function () {
226226
scope.open2 = true;
227227
$compile(element)(scope);
228228
scope.$digest();
229-
groups = element.find('.accordion-group');
229+
groups = element.find('.panel');
230230
});
231231

232-
it('should open the group with isOpen set to true', function () {
232+
it('should open the panel with isOpen set to true', function () {
233233
expect(findGroupBody(0).scope().isOpen).toBe(false);
234234
expect(findGroupBody(1).scope().isOpen).toBe(true);
235235
});
@@ -249,14 +249,14 @@ describe('accordion', function () {
249249
angular.element(document.body).append(element);
250250
$compile(element)(scope);
251251
scope.$digest();
252-
groups = element.find('.accordion-group');
252+
groups = element.find('.panel');
253253
});
254254

255255
afterEach(function() {
256256
element.remove();
257257
});
258258

259-
it('should have visible group body when the group with isOpen set to true', function () {
259+
it('should have visible panel body when the group with isOpen set to true', function () {
260260
expect(findGroupBody(0)[0].clientHeight).not.toBe(0);
261261
expect(findGroupBody(1)[0].clientHeight).toBe(0);
262262
});
@@ -273,7 +273,7 @@ describe('accordion', function () {
273273
'</accordion>';
274274
element = $compile(tpl)(scope);
275275
scope.$digest();
276-
groups = element.find('.accordion-group');
276+
groups = element.find('.panel');
277277
});
278278
it('transcludes the <accordion-heading> content into the heading link', function() {
279279
expect(findGroupLink(0).text()).toBe('Heading Element 123 ');
@@ -295,7 +295,7 @@ describe('accordion', function () {
295295
'</accordion>';
296296
element = $compile(tpl)(scope);
297297
scope.$digest();
298-
groups = element.find('.accordion-group');
298+
groups = element.find('.panel');
299299
});
300300
it('transcludes the <accordion-heading> content into the heading link', function() {
301301
expect(findGroupLink(0).text()).toBe('Heading Element 123 ');
@@ -310,7 +310,7 @@ describe('accordion', function () {
310310
it('should clone the accordion-heading for each group', function() {
311311
element = $compile('<accordion><accordion-group ng-repeat="x in [1,2,3]"><accordion-heading>{{x}}</accordion-heading></accordion-group></accordion>')(scope);
312312
scope.$digest();
313-
groups = element.find('.accordion-group');
313+
groups = element.find('.panel');
314314
expect(groups.length).toBe(3);
315315
expect(findGroupLink(0).text()).toBe('1');
316316
expect(findGroupLink(1).text()).toBe('2');
@@ -323,7 +323,7 @@ describe('accordion', function () {
323323
it('should clone the accordion-heading for each group', function() {
324324
element = $compile('<accordion><accordion-group ng-repeat="x in [1,2,3]"><div accordion-heading>{{x}}</div></accordion-group></accordion>')(scope);
325325
scope.$digest();
326-
groups = element.find('.accordion-group');
326+
groups = element.find('.panel');
327327
expect(groups.length).toBe(3);
328328
expect(findGroupLink(0).text()).toBe('1');
329329
expect(findGroupLink(1).text()).toBe('2');
Lines changed: 9 additions & 4 deletions
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 href="" 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

Lines changed: 1 addition & 1 deletion
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)