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

Commit dbd6f73

Browse files
committed
chore(pagination): unify code style
- Fix up the code style for consistency Closes #4176
1 parent ba2ce24 commit dbd6f73

File tree

3 files changed

+79
-76
lines changed

3 files changed

+79
-76
lines changed

Diff for: src/pagination/pagination.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
angular.module('ui.bootstrap.pagination', [])
2-
.controller('PaginationController', ['$scope', '$attrs', '$parse', function ($scope, $attrs, $parse) {
2+
.controller('PaginationController', ['$scope', '$attrs', '$parse', function($scope, $attrs, $parse) {
33
var self = this,
44
ngModelCtrl = { $setViewValue: angular.noop }, // nullModelCtrl
55
setNumPages = $attrs.numPages ? $parse($attrs.numPages).assign : angular.noop;
@@ -60,12 +60,14 @@ angular.module('ui.bootstrap.pagination', [])
6060
}
6161
};
6262

63-
$scope.getText = function( key ) {
63+
$scope.getText = function(key) {
6464
return $scope[key + 'Text'] || self.config[key + 'Text'];
6565
};
66+
6667
$scope.noPrevious = function() {
6768
return $scope.page === 1;
6869
};
70+
6971
$scope.noNext = function() {
7072
return $scope.page === $scope.totalPages;
7173
};
@@ -136,11 +138,11 @@ angular.module('ui.bootstrap.pagination', [])
136138

137139
// Default page limits
138140
var startPage = 1, endPage = totalPages;
139-
var isMaxSized = ( angular.isDefined(maxSize) && maxSize < totalPages );
141+
var isMaxSized = angular.isDefined(maxSize) && maxSize < totalPages;
140142

141143
// recompute if maxSize
142-
if ( isMaxSized ) {
143-
if ( rotate ) {
144+
if (isMaxSized) {
145+
if (rotate) {
144146
// Current page is displayed in the middle of the visible ones
145147
startPage = Math.max(currentPage - Math.floor(maxSize/2), 1);
146148
endPage = startPage + maxSize - 1;
@@ -166,13 +168,13 @@ angular.module('ui.bootstrap.pagination', [])
166168
}
167169

168170
// Add links to move between page sets
169-
if ( isMaxSized && ! rotate ) {
170-
if ( startPage > 1 ) {
171+
if (isMaxSized && ! rotate) {
172+
if (startPage > 1) {
171173
var previousPageSet = makePage(startPage - 1, '...', false);
172174
pages.unshift(previousPageSet);
173175
}
174176

175-
if ( endPage < totalPages ) {
177+
if (endPage < totalPages) {
176178
var nextPageSet = makePage(endPage + 1, '...', false);
177179
pages.push(nextPageSet);
178180
}

Diff for: src/pagination/test/pager.spec.js

+15-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
describe('pager directive', function () {
2-
var $compile, $rootScope, $document, $templateCache, element;
1+
describe('pager directive', function() {
2+
var $compile, $rootScope, $document, $templateCache, body, element;
33
beforeEach(module('ui.bootstrap.pagination'));
44
beforeEach(module('template/pagination/pager.html'));
55
beforeEach(inject(function(_$compile_, _$rootScope_, _$document_, _$templateCache_) {
@@ -9,6 +9,7 @@ describe('pager directive', function () {
99
$rootScope.currentPage = 3;
1010
$document = _$document_;
1111
$templateCache = _$templateCache_;
12+
body = $document.find('body');
1213
element = $compile('<pager total-items="total" ng-model="currentPage"></pager>')($rootScope);
1314
$rootScope.$digest();
1415
}));
@@ -117,8 +118,8 @@ describe('pager directive', function () {
117118
expect(getPaginationEl(-1).text()).toBe('Next »');
118119
});
119120

120-
it('should blur the "next" link after it has been clicked', function () {
121-
$document.find('body').append(element);
121+
it('should blur the "next" link after it has been clicked', function() {
122+
body.append(element);
122123
var linkEl = getPaginationLinkEl(element, -1);
123124

124125
linkEl.focus();
@@ -130,8 +131,8 @@ describe('pager directive', function () {
130131
element.remove();
131132
});
132133

133-
it('should blur the "prev" link after it has been clicked', function () {
134-
$document.find('body').append(element);
134+
it('should blur the "prev" link after it has been clicked', function() {
135+
body.append(element);
135136
var linkEl = getPaginationLinkEl(element, -1);
136137

137138
linkEl.focus();
@@ -152,7 +153,7 @@ describe('pager directive', function () {
152153
expect(element.html()).toBe('baz');
153154
});
154155

155-
describe('`items-per-page`', function () {
156+
describe('`items-per-page`', function() {
156157
beforeEach(function() {
157158
$rootScope.perpage = 5;
158159
element = $compile('<pager total-items="total" items-per-page="perpage" ng-model="currentPage"></pager>')($rootScope);
@@ -176,7 +177,7 @@ describe('pager directive', function () {
176177
});
177178
});
178179

179-
describe('when `page` is not a number', function () {
180+
describe('when `page` is not a number', function() {
180181
it('handles string', function() {
181182
updateCurrentPage('1');
182183
expect(getPaginationEl(0)).toHaveClass('disabled');
@@ -186,7 +187,7 @@ describe('pager directive', function () {
186187
});
187188
});
188189

189-
describe('`num-pages`', function () {
190+
describe('`num-pages`', function() {
190191
beforeEach(function() {
191192
$rootScope.numpg = null;
192193
element = $compile('<pager total-items="total" ng-model="currentPage" num-pages="numpg"></pager>')($rootScope);
@@ -213,18 +214,18 @@ describe('pager directive', function () {
213214
angular.extend(pagerConfig, originalConfig);
214215
}));
215216

216-
it('should change paging text', function () {
217+
it('should change paging text', function() {
217218
expect(getPaginationEl(0).text()).toBe('PR');
218219
expect(getPaginationEl(-1).text()).toBe('NE');
219220
});
220221

221-
it('should not align previous & next page link', function () {
222+
it('should not align previous & next page link', function() {
222223
expect(getPaginationEl(0)).not.toHaveClass('previous');
223224
expect(getPaginationEl(-1)).not.toHaveClass('next');
224225
});
225226
});
226227

227-
describe('override configuration from attributes', function () {
228+
describe('override configuration from attributes', function() {
228229
beforeEach(function() {
229230
element = $compile('<pager align="false" previous-text="<" next-text=">" total-items="total" ng-model="currentPage"></pager>')($rootScope);
230231
$rootScope.$digest();
@@ -234,12 +235,12 @@ describe('pager directive', function () {
234235
expect(getPaginationBarSize()).toBe(2);
235236
});
236237

237-
it('should change paging text from attributes', function () {
238+
it('should change paging text from attributes', function() {
238239
expect(getPaginationEl(0).text()).toBe('<');
239240
expect(getPaginationEl(-1).text()).toBe('>');
240241
});
241242

242-
it('should not align previous & next page link', function () {
243+
it('should not align previous & next page link', function() {
243244
expect(getPaginationEl(0)).not.toHaveClass('previous');
244245
expect(getPaginationEl(-1)).not.toHaveClass('next');
245246
});

0 commit comments

Comments
 (0)