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

Commit 568ea56

Browse files
Justin Hallpkozlowski-opensource
authored andcommitted
feat(pagination): bootstrap3 support
1 parent 68e19ef commit 568ea56

File tree

4 files changed

+26
-31
lines changed

4 files changed

+26
-31
lines changed

src/pagination/docs/demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ <h4>Default</h4>
66
<pagination direction-links="false" boundary-links="true" total-items="totalItems" page="currentPage"></pagination>
77
<pagination direction-links="false" total-items="totalItems" page="currentPage" num-pages="smallnumPages"></pagination>
88

9-
<button class="btn" ng-click="setPage(3)">Set current page to: 3</button>
9+
<button class="btn btn-info" ng-click="setPage(3)">Set current page to: 3</button>
1010
The selected page no: {{currentPage}}
1111

1212
<hr />

src/pagination/test/pagination.spec.js

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe('pagination directive', function () {
1+
ddescribe('pagination directive', function () {
22
var $compile, $rootScope, element;
33
beforeEach(module('ui.bootstrap.pagination'));
44
beforeEach(module('template/pagination/pagination.html'));
@@ -7,7 +7,7 @@ describe('pagination directive', function () {
77
$rootScope = _$rootScope_;
88
$rootScope.total = 47; // 5 pages
99
$rootScope.currentPage = 3;
10-
element = $compile('<pagination total-items="total" page="currentPage"></pagination>')($rootScope);
10+
element = $compile('<div><pagination total-items="total" page="currentPage"></pagination></div>')($rootScope);
1111
$rootScope.$digest();
1212
}));
1313

@@ -28,10 +28,6 @@ describe('pagination directive', function () {
2828
$rootScope.$digest();
2929
}
3030

31-
it('has a "pagination" css class', function() {
32-
expect(element.hasClass('pagination')).toBe(true);
33-
});
34-
3531
it('contains one ul and num-pages + 2 li elements', function() {
3632
expect(element.find('ul').length).toBe(1);
3733
expect(getPaginationBarSize()).toBe(7);
@@ -98,7 +94,7 @@ describe('pagination directive', function () {
9894
describe('`items-per-page`', function () {
9995
beforeEach(inject(function() {
10096
$rootScope.perpage = 5;
101-
element = $compile('<pagination total-items="total" items-per-page="perpage" page="currentPage" on-select-page="selectPageHandler(page)"></pagination>')($rootScope);
97+
element = $compile('<div><pagination total-items="total" items-per-page="perpage" page="currentPage" on-select-page="selectPageHandler(page)"></pagination></div>')($rootScope);
10298
$rootScope.$digest();
10399
}));
104100

@@ -141,7 +137,7 @@ describe('pagination directive', function () {
141137
describe('executes `on-select-page` expression', function () {
142138
beforeEach(inject(function() {
143139
$rootScope.selectPageHandler = jasmine.createSpy('selectPageHandler');
144-
element = $compile('<pagination total-items="total" page="currentPage" on-select-page="selectPageHandler(page)"></pagination>')($rootScope);
140+
element = $compile('<div><pagination total-items="total" page="currentPage" on-select-page="selectPageHandler(page)"></pagination></div>')($rootScope);
145141
$rootScope.$digest();
146142
}));
147143

@@ -166,7 +162,7 @@ describe('pagination directive', function () {
166162
$rootScope.total = 98; // 10 pages
167163
$rootScope.currentPage = 3;
168164
$rootScope.maxSize = 5;
169-
element = $compile('<pagination total-items="total" page="currentPage" max-size="maxSize"></pagination>')($rootScope);
165+
element = $compile('<div><pagination total-items="total" page="currentPage" max-size="maxSize"></pagination></div>')($rootScope);
170166
$rootScope.$digest();
171167
}));
172168

@@ -198,7 +194,7 @@ describe('pagination directive', function () {
198194
clickPaginationEl(0);
199195

200196
expect($rootScope.currentPage).toBe(6);
201-
expect(getPaginationEl(3)).toHaveClass('active');
197+
expect(getPaginationEl(3)).toHaveClass('active');
202198
expect(getPaginationEl(3).text()).toBe(''+$rootScope.currentPage);
203199
});
204200

@@ -235,7 +231,7 @@ describe('pagination directive', function () {
235231
$rootScope.currentPage = 7;
236232
$rootScope.maxSize = 5;
237233
$rootScope.rotate = false;
238-
element = $compile('<pagination total-items="total" page="currentPage" max-size="maxSize" rotate="rotate"></pagination>')($rootScope);
234+
element = $compile('<div><pagination total-items="total" page="currentPage" max-size="maxSize" rotate="rotate"></pagination></div>')($rootScope);
239235
$rootScope.$digest();
240236
}));
241237

@@ -295,7 +291,7 @@ describe('pagination directive', function () {
295291

296292
describe('pagination directive with `boundary-links`', function () {
297293
beforeEach(inject(function() {
298-
element = $compile('<pagination boundary-links="true" total-items="total" page="currentPage"></pagination>')($rootScope);
294+
element = $compile('<div><pagination boundary-links="true" total-items="total" page="currentPage"></pagination></div>')($rootScope);
299295
$rootScope.$digest();
300296
}));
301297

@@ -351,15 +347,15 @@ describe('pagination directive', function () {
351347
});
352348

353349
it('changes "first" & "last" text from attributes', function() {
354-
element = $compile('<pagination boundary-links="true" first-text="<<<" last-text=">>>" total-items="total" page="currentPage"></pagination>')($rootScope);
350+
element = $compile('<div><pagination boundary-links="true" first-text="<<<" last-text=">>>" total-items="total" page="currentPage"></pagination></div>')($rootScope);
355351
$rootScope.$digest();
356352

357353
expect(getPaginationEl(0).text()).toBe('<<<');
358354
expect(getPaginationEl(-1).text()).toBe('>>>');
359355
});
360356

361357
it('changes "previous" & "next" text from attributes', function() {
362-
element = $compile('<pagination boundary-links="true" previous-text="<<" next-text=">>" total-items="total" page="currentPage"></pagination>')($rootScope);
358+
element = $compile('<div><pagination boundary-links="true" previous-text="<<" next-text=">>" total-items="total" page="currentPage"></pagination></div>')($rootScope);
363359
$rootScope.$digest();
364360

365361
expect(getPaginationEl(1).text()).toBe('<<');
@@ -369,7 +365,7 @@ describe('pagination directive', function () {
369365
it('changes "first" & "last" text from interpolated attributes', function() {
370366
$rootScope.myfirstText = '<<<';
371367
$rootScope.mylastText = '>>>';
372-
element = $compile('<pagination boundary-links="true" first-text="{{myfirstText}}" last-text="{{mylastText}}" total-items="total" page="currentPage"></pagination>')($rootScope);
368+
element = $compile('<div><pagination boundary-links="true" first-text="{{myfirstText}}" last-text="{{mylastText}}" total-items="total" page="currentPage"></pagination></div>')($rootScope);
373369
$rootScope.$digest();
374370

375371
expect(getPaginationEl(0).text()).toBe('<<<');
@@ -379,7 +375,7 @@ describe('pagination directive', function () {
379375
it('changes "previous" & "next" text from interpolated attributes', function() {
380376
$rootScope.previousText = '<<';
381377
$rootScope.nextText = '>>';
382-
element = $compile('<pagination boundary-links="true" previous-text="{{previousText}}" next-text="{{nextText}}" total-items="total" page="currentPage"></pagination>')($rootScope);
378+
element = $compile('<div><pagination boundary-links="true" previous-text="{{previousText}}" next-text="{{nextText}}" total-items="total" page="currentPage"></pagination></div>')($rootScope);
383379
$rootScope.$digest();
384380

385381
expect(getPaginationEl(1).text()).toBe('<<');
@@ -389,7 +385,7 @@ describe('pagination directive', function () {
389385

390386
describe('pagination directive with just number links', function () {
391387
beforeEach(inject(function() {
392-
element = $compile('<pagination direction-links="false" total-items="total" page="currentPage"></pagination>')($rootScope);
388+
element = $compile('<div><pagination direction-links="false" total-items="total" page="currentPage"></pagination></div>')($rootScope);
393389
$rootScope.$digest();
394390
}));
395391

@@ -441,7 +437,7 @@ describe('pagination directive', function () {
441437
describe('with just boundary & number links', function () {
442438
beforeEach(inject(function() {
443439
$rootScope.directions = false;
444-
element = $compile('<pagination boundary-links="true" direction-links="directions" total-items="total" page="currentPage"></pagination>')($rootScope);
440+
element = $compile('<div><pagination boundary-links="true" direction-links="directions" total-items="total" page="currentPage"></pagination></div>')($rootScope);
445441
$rootScope.$digest();
446442
}));
447443

@@ -473,7 +469,7 @@ describe('pagination directive', function () {
473469
describe('`num-pages`', function () {
474470
beforeEach(inject(function() {
475471
$rootScope.numpg = null;
476-
element = $compile('<pagination total-items="total" page="currentPage" num-pages="numpg"></pagination>')($rootScope);
472+
element = $compile('<div><pagination total-items="total" page="currentPage" num-pages="numpg"></pagination></div>')($rootScope);
477473
$rootScope.$digest();
478474
}));
479475

@@ -493,7 +489,7 @@ describe('pagination directive', function () {
493489
paginationConfig.previousText = 'PR';
494490
paginationConfig.nextText = 'NE';
495491
paginationConfig.lastText = 'LA';
496-
element = $compile('<pagination total-items="total" page="currentPage"></pagination>')($rootScope);
492+
element = $compile('<div><pagination total-items="total" page="currentPage"></pagination></div>')($rootScope);
497493
$rootScope.$digest();
498494
}));
499495
afterEach(inject(function(paginationConfig) {
@@ -515,7 +511,7 @@ describe('pagination directive', function () {
515511

516512
describe('override configuration from attributes', function () {
517513
beforeEach(inject(function() {
518-
element = $compile('<pagination boundary-links="true" first-text="<<" previous-text="<" next-text=">" last-text=">>" total-items="total" page="currentPage"></pagination>')($rootScope);
514+
element = $compile('<div><pagination boundary-links="true" first-text="<<" previous-text="<" next-text=">" last-text=">>" total-items="total" page="currentPage"></pagination></div>')($rootScope);
519515
$rootScope.$digest();
520516
}));
521517

@@ -531,4 +527,4 @@ describe('pagination directive', function () {
531527
});
532528
});
533529

534-
});
530+
});

template/pagination/pager.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<div class="pager">
2-
<ul>
3-
<li ng-repeat="page in pages" ng-class="{disabled: page.disabled, previous: page.previous, next: page.next}"><a ng-click="selectPage(page.number)">{{page.text}}</a></li>
4-
</ul>
5-
</div>
1+
<ul class="pager">
2+
<li ng-repeat="page in pages" ng-class="{disabled: page.disabled, previous: page.previous, next: page.next}">
3+
<a ng-click="selectPage(page.number)">{{page.text}}</a>
4+
</li>
5+
</ul>

template/pagination/pagination.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<div class="pagination"><ul>
1+
<ul class="pagination">
22
<li ng-repeat="page in pages" ng-class="{active: page.active, disabled: page.disabled}"><a ng-click="selectPage(page.number)">{{page.text}}</a></li>
3-
</ul>
4-
</div>
3+
</ul>

0 commit comments

Comments
 (0)