-
Notifications
You must be signed in to change notification settings - Fork 16
/
angular-pagination.min.js
5 lines (5 loc) · 1.39 KB
/
angular-pagination.min.js
1
2
3
4
5
/*
angular-pagination v0.2.2
https://github.com/nervgh/angular-pagination
*/
angular.module("angularPagination",[]).value("paginationOptions",{itemsPerPage:10,itemsCount:100,maxNumbers:5,startPage:1,currentPage:1}).factory("Pagination",["paginationOptions",function(a){function b(b){var c=angular.copy(a);angular.extend(this,c,b),this.endPage=null,this.pages=[],this._lastPage=null,this.setCurrent(this.currentPage)}return b.prototype.setCurrent=function(a){this.endPage=Math.ceil(this.itemsCount/this.itemsPerPage),this.currentPage=this._fixPage(Math.floor(a)),this._change(this.currentPage),this._updatePages()},b.prototype.isCurrent=function(a){return this.currentPage===a},b.prototype.inRange=function(a){return this.startPage<=a&&this.endPage>=a},b.prototype.isFirst=function(a){return this.startPage===a},b.prototype.isLast=function(a){return this.endPage===a},b.prototype.onChange=function(){},b.prototype._fixPage=function(a){return a=Math.min(a,this.endPage),a=Math.max(a,this.startPage)},b.prototype._change=function(a){this._lastPage!==a&&(this._lastPage=a,this.onChange(a))},b.prototype._updatePages=function(){var a=Math.floor(this.maxNumbers/2),b=Math.max(this.currentPage-a,this.startPage),c=Math.min(b+this.maxNumbers-1,this.endPage);b=this.endPage===c?c-(this.maxNumbers-1):b,b=Math.max(b,this.startPage),this.pages.length=0;for(var d=b;c>=d;d++)this.pages.push(d)},b.create=function(a){return new b(a)},b}]);