This repository was archived by the owner on May 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Add option to disable pagination from outside. #3956
Closed
Closed
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e89497e
Added paginationDisabled attribute
TomaszZieleskiewicz 0c8a893
Added support for paginationDisabled attribute
TomaszZieleskiewicz c430010
Added missing line
TomaszZieleskiewicz 3c894e9
Changed to ngDisabled attribute, improved coding and added some tests.
TomaszZieleskiewicz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
angular.module('ui.bootstrap.pagination', []) | ||
|
||
.controller('PaginationController', ['$scope', '$attrs', '$parse', function ($scope, $attrs, $parse) { | ||
var self = this, | ||
ngModelCtrl = { $setViewValue: angular.noop }, // nullModelCtrl | ||
|
@@ -43,11 +42,12 @@ angular.module('ui.bootstrap.pagination', []) | |
}; | ||
|
||
this.render = function() { | ||
$scope.page = parseInt(ngModelCtrl.$viewValue, 10) || 1; | ||
$scope.page = parseInt(ngModelCtrl.$viewValue, 10) || 1; | ||
}; | ||
|
||
$scope.selectPage = function(page, evt) { | ||
if ( $scope.page !== page && page > 0 && page <= $scope.totalPages) { | ||
var disabled_click = $scope.paginationDisabled && evt !== undefined; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use a camelcased variable - In addition, |
||
if (!disabled_click && $scope.page !== page && page > 0 && page <= $scope.totalPages) { | ||
if (evt && evt.target) { | ||
evt.target.blur(); | ||
} | ||
|
@@ -75,7 +75,8 @@ angular.module('ui.bootstrap.pagination', []) | |
previousText: 'Previous', | ||
nextText: 'Next', | ||
lastText: 'Last', | ||
rotate: true | ||
rotate: true, | ||
paginationDisabled:false | ||
}) | ||
|
||
.directive('pagination', ['$parse', 'paginationConfig', function($parse, paginationConfig) { | ||
|
@@ -86,7 +87,8 @@ angular.module('ui.bootstrap.pagination', []) | |
firstText: '@', | ||
previousText: '@', | ||
nextText: '@', | ||
lastText: '@' | ||
lastText: '@', | ||
paginationDisabled:'=' | ||
}, | ||
require: ['pagination', '?ngModel'], | ||
controller: 'PaginationController', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<ul class="pagination"> | ||
<li ng-if="boundaryLinks" ng-class="{disabled: noPrevious()}"><a href ng-click="selectPage(1, $event)">{{getText('first')}}</a></li> | ||
<li ng-if="directionLinks" ng-class="{disabled: noPrevious()}"><a href ng-click="selectPage(page - 1, $event)">{{getText('previous')}}</a></li> | ||
<li ng-repeat="page in pages track by $index" ng-class="{active: page.active}"><a href ng-click="selectPage(page.number, $event)">{{page.text}}</a></li> | ||
<li ng-if="directionLinks" ng-class="{disabled: noNext()}"><a href ng-click="selectPage(page + 1, $event)">{{getText('next')}}</a></li> | ||
<li ng-if="boundaryLinks" ng-class="{disabled: noNext()}"><a href ng-click="selectPage(totalPages, $event)">{{getText('last')}}</a></li> | ||
</ul> | ||
<li ng-if="boundaryLinks" ng-class="{disabled: noPrevious()||paginationDisabled}"><a href ng-click="selectPage(1, $event)">{{getText('first')}}</a></li> | ||
<li ng-if="directionLinks" ng-class="{disabled: noPrevious()||paginationDisabled}"><a href ng-click="selectPage(page - 1, $event)">{{getText('previous')}}</a></li> | ||
<li ng-repeat="page in pages track by $index" ng-class="{active: page.active,disabled: paginationDisabled&&!page.active}"><a href ng-click="selectPage(page.number, $event)">{{page.text}}</a></li> | ||
<li ng-if="directionLinks" ng-class="{disabled: noNext()||paginationDisabled}"><a href ng-click="selectPage(page + 1, $event)">{{getText('next')}}</a></li> | ||
<li ng-if="boundaryLinks" ng-class="{disabled: noNext()||paginationDisabled}"><a href ng-click="selectPage(totalPages, $event)">{{getText('last')}}</a></li> | ||
</ul> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Undo this change.