UNPKG

ngx-bootstrap-ci

Version:
2 lines 11.3 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/forms"),require("@angular/common")):"function"==typeof define&&define.amd?define("ngx-bootstrap/pagination",["exports","@angular/core","@angular/forms","@angular/common"],e):e((t["ngx-bootstrap"]=t["ngx-bootstrap"]||{},t["ngx-bootstrap"].pagination={}),t.ng.core,t.ng.forms,t.ng.common)}(this,function(t,n,e,i){"use strict";var a=function(){function t(){this.main={maxSize:void 0,itemsPerPage:10,boundaryLinks:!1,directionLinks:!0,firstText:"First",previousText:"Previous",nextText:"Next",lastText:"Last",pageBtnClass:"",rotate:!0},this.pager={itemsPerPage:15,previousText:"« Previous",nextText:"Next »",pageBtnClass:"",align:!0}}return t.decorators=[{type:n.Injectable}],t}(),s={provide:e.NG_VALUE_ACCESSOR,useExisting:n.forwardRef(function(){return o}),multi:!0},o=function(){function t(t,e,i){this.elementRef=t,this.changeDetection=i,this.numPages=new n.EventEmitter,this.pageChanged=new n.EventEmitter,this.onChange=Function.prototype,this.onTouched=Function.prototype,this.inited=!1,this._page=1,this.elementRef=t,this.config||this.configureOptions(Object.assign({},e.main,e.pager))}return Object.defineProperty(t.prototype,"itemsPerPage",{get:function(){return this._itemsPerPage},set:function(t){this._itemsPerPage=t,this.totalPages=this.calculateTotalPages()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"totalItems",{get:function(){return this._totalItems},set:function(t){this._totalItems=t,this.totalPages=this.calculateTotalPages()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"totalPages",{get:function(){return this._totalPages},set:function(t){this._totalPages=t,this.numPages.emit(t),this.inited&&this.selectPage(this.page)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"page",{get:function(){return this._page},set:function(t){var e=this._page;this._page=t>this.totalPages?this.totalPages:t||1,this.changeDetection.markForCheck(),e!==this._page&&void 0!==e&&this.pageChanged.emit({page:this._page,itemsPerPage:this.itemsPerPage})},enumerable:!0,configurable:!0}),t.prototype.configureOptions=function(t){this.config=Object.assign({},t)},t.prototype.ngOnInit=function(){"undefined"!=typeof window&&(this.classMap=this.elementRef.nativeElement.getAttribute("class")||""),this.maxSize="undefined"!=typeof this.maxSize?this.maxSize:this.config.maxSize,this.rotate="undefined"!=typeof this.rotate?this.rotate:this.config.rotate,this.boundaryLinks="undefined"!=typeof this.boundaryLinks?this.boundaryLinks:this.config.boundaryLinks,this.directionLinks="undefined"!=typeof this.directionLinks?this.directionLinks:this.config.directionLinks,this.pageBtnClass="undefined"!=typeof this.pageBtnClass?this.pageBtnClass:this.config.pageBtnClass,this.itemsPerPage="undefined"!=typeof this.itemsPerPage?this.itemsPerPage:this.config.itemsPerPage,this.totalPages=this.calculateTotalPages(),this.pages=this.getPages(this.page,this.totalPages),this.inited=!0},t.prototype.writeValue=function(t){this.page=t,this.pages=this.getPages(this.page,this.totalPages)},t.prototype.getText=function(t){return this[t+"Text"]||this.config[t+"Text"]},t.prototype.noPrevious=function(){return 1===this.page},t.prototype.noNext=function(){return this.page===this.totalPages},t.prototype.registerOnChange=function(t){this.onChange=t},t.prototype.registerOnTouched=function(t){this.onTouched=t},t.prototype.selectPage=function(t,e){if(e&&e.preventDefault(),!this.disabled){if(e&&e.target)e.target.blur();this.writeValue(t),this.onChange(this.page)}},t.prototype.makePage=function(t,e,i){return{text:e,number:t,active:i}},t.prototype.getPages=function(t,e){var i=[],n=1,a=e,s="undefined"!=typeof this.maxSize&&this.maxSize<e;s&&(this.rotate?e<(a=(n=Math.max(t-Math.floor(this.maxSize/2),1))+this.maxSize-1)&&(n=(a=e)-this.maxSize+1):(n=(Math.ceil(t/this.maxSize)-1)*this.maxSize+1,a=Math.min(n+this.maxSize-1,e)));for(var o=n;o<=a;o++){var r=this.makePage(o,o.toString(),o===t);i.push(r)}if(s&&!this.rotate){if(1<n){var g=this.makePage(n-1,"...",!1);i.unshift(g)}if(a<e){var p=this.makePage(a+1,"...",!1);i.push(p)}}return i},t.prototype.calculateTotalPages=function(){var t=this.itemsPerPage<1?1:Math.ceil(this.totalItems/this.itemsPerPage);return Math.max(t||0,1)},t.decorators=[{type:n.Component,args:[{selector:"pager",template:'<ul class="pager">\n <li [class.disabled]="noPrevious()" [class.previous]="align"\n [ngClass]="{\'pull-right\': align, \'float-right\': align}"\n class="{{ pageBtnClass }}">\n <a href (click)="selectPage(page - 1, $event)">{{ getText(\'previous\') }}</a>\n </li>\n <li [class.disabled]="noNext()" [class.next]="align"\n [ngClass]="{\'pull-right\': align, \'float-right\': align}"\n class="{{ pageBtnClass }}">\n <a href (click)="selectPage(page + 1, $event)">{{ getText(\'next\') }}</a>\n </li>\n</ul>\n',providers:[s]}]}],t.ctorParameters=function(){return[{type:n.ElementRef},{type:a},{type:n.ChangeDetectorRef}]},t.propDecorators={align:[{type:n.Input}],maxSize:[{type:n.Input}],boundaryLinks:[{type:n.Input}],directionLinks:[{type:n.Input}],firstText:[{type:n.Input}],previousText:[{type:n.Input}],nextText:[{type:n.Input}],lastText:[{type:n.Input}],rotate:[{type:n.Input}],pageBtnClass:[{type:n.Input}],disabled:[{type:n.Input}],numPages:[{type:n.Output}],pageChanged:[{type:n.Output}],itemsPerPage:[{type:n.Input}],totalItems:[{type:n.Input}]},t}(),r={provide:e.NG_VALUE_ACCESSOR,useExisting:n.forwardRef(function(){return g}),multi:!0},g=function(){function t(t,e,i){this.elementRef=t,this.changeDetection=i,this.numPages=new n.EventEmitter,this.pageChanged=new n.EventEmitter,this.onChange=Function.prototype,this.onTouched=Function.prototype,this.inited=!1,this._page=1,this.elementRef=t,this.config||this.configureOptions(e.main)}return Object.defineProperty(t.prototype,"itemsPerPage",{get:function(){return this._itemsPerPage},set:function(t){this._itemsPerPage=t,this.totalPages=this.calculateTotalPages()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"totalItems",{get:function(){return this._totalItems},set:function(t){this._totalItems=t,this.totalPages=this.calculateTotalPages()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"totalPages",{get:function(){return this._totalPages},set:function(t){this._totalPages=t,this.numPages.emit(t),this.inited&&this.selectPage(this.page)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"page",{get:function(){return this._page},set:function(t){var e=this._page;this._page=t>this.totalPages?this.totalPages:t||1,this.changeDetection.markForCheck(),e!==this._page&&void 0!==e&&this.pageChanged.emit({page:this._page,itemsPerPage:this.itemsPerPage})},enumerable:!0,configurable:!0}),t.prototype.configureOptions=function(t){this.config=Object.assign({},t)},t.prototype.ngOnInit=function(){"undefined"!=typeof window&&(this.classMap=this.elementRef.nativeElement.getAttribute("class")||""),this.maxSize="undefined"!=typeof this.maxSize?this.maxSize:this.config.maxSize,this.rotate="undefined"!=typeof this.rotate?this.rotate:this.config.rotate,this.boundaryLinks="undefined"!=typeof this.boundaryLinks?this.boundaryLinks:this.config.boundaryLinks,this.directionLinks="undefined"!=typeof this.directionLinks?this.directionLinks:this.config.directionLinks,this.pageBtnClass="undefined"!=typeof this.pageBtnClass?this.pageBtnClass:this.config.pageBtnClass,this.itemsPerPage="undefined"!=typeof this.itemsPerPage?this.itemsPerPage:this.config.itemsPerPage,this.totalPages=this.calculateTotalPages(),this.pages=this.getPages(this.page,this.totalPages),this.inited=!0},t.prototype.writeValue=function(t){this.page=t,this.pages=this.getPages(this.page,this.totalPages)},t.prototype.getText=function(t){return this[t+"Text"]||this.config[t+"Text"]},t.prototype.noPrevious=function(){return 1===this.page},t.prototype.noNext=function(){return this.page===this.totalPages},t.prototype.registerOnChange=function(t){this.onChange=t},t.prototype.registerOnTouched=function(t){this.onTouched=t},t.prototype.selectPage=function(t,e){if(e&&e.preventDefault(),!this.disabled){if(e&&e.target)e.target.blur();this.writeValue(t),this.onChange(this.page)}},t.prototype.makePage=function(t,e,i){return{text:e,number:t,active:i}},t.prototype.getPages=function(t,e){var i=[],n=1,a=e,s="undefined"!=typeof this.maxSize&&this.maxSize<e;s&&(this.rotate?e<(a=(n=Math.max(t-Math.floor(this.maxSize/2),1))+this.maxSize-1)&&(n=(a=e)-this.maxSize+1):(n=(Math.ceil(t/this.maxSize)-1)*this.maxSize+1,a=Math.min(n+this.maxSize-1,e)));for(var o=n;o<=a;o++){var r=this.makePage(o,o.toString(),o===t);i.push(r)}if(s&&!this.rotate){if(1<n){var g=this.makePage(n-1,"...",!1);i.unshift(g)}if(a<e){var p=this.makePage(a+1,"...",!1);i.push(p)}}return i},t.prototype.calculateTotalPages=function(){var t=this.itemsPerPage<1?1:Math.ceil(this.totalItems/this.itemsPerPage);return Math.max(t||0,1)},t.decorators=[{type:n.Component,args:[{selector:"pagination",template:'<ul class="pagination" [ngClass]="classMap">\n <li class="pagination-first page-item"\n *ngIf="boundaryLinks"\n [class.disabled]="noPrevious()||disabled">\n <a class="page-link" href (click)="selectPage(1, $event)"\n [innerHTML]="getText(\'first\')"></a>\n </li>\n\n <li class="pagination-prev page-item"\n *ngIf="directionLinks"\n [class.disabled]="noPrevious()||disabled">\n <a class="page-link" href (click)="selectPage(page - 1, $event)"\n [innerHTML]="getText(\'previous\')"></a>\n </li>\n\n <li *ngFor="let pg of pages"\n [class.active]="pg.active"\n [class.disabled]="disabled&&!pg.active"\n class="pagination-page page-item">\n <a class="page-link" href (click)="selectPage(pg.number, $event)"\n [innerHTML]="pg.text"></a>\n </li>\n\n <li class="pagination-next page-item"\n *ngIf="directionLinks"\n [class.disabled]="noNext()||disabled">\n <a class="page-link" href (click)="selectPage(page + 1, $event)"\n [innerHTML]="getText(\'next\')"></a></li>\n\n <li class="pagination-last page-item"\n *ngIf="boundaryLinks"\n [class.disabled]="noNext()||disabled">\n <a class="page-link" href (click)="selectPage(totalPages, $event)"\n [innerHTML]="getText(\'last\')"></a></li>\n</ul>\n',providers:[r]}]}],t.ctorParameters=function(){return[{type:n.ElementRef},{type:a},{type:n.ChangeDetectorRef}]},t.propDecorators={align:[{type:n.Input}],maxSize:[{type:n.Input}],boundaryLinks:[{type:n.Input}],directionLinks:[{type:n.Input}],firstText:[{type:n.Input}],previousText:[{type:n.Input}],nextText:[{type:n.Input}],lastText:[{type:n.Input}],rotate:[{type:n.Input}],pageBtnClass:[{type:n.Input}],disabled:[{type:n.Input}],numPages:[{type:n.Output}],pageChanged:[{type:n.Output}],itemsPerPage:[{type:n.Input}],totalItems:[{type:n.Input}]},t}(),p=function(){function t(){}return t.forRoot=function(){return{ngModule:t,providers:[a]}},t.decorators=[{type:n.NgModule,args:[{imports:[i.CommonModule],declarations:[o,g],exports:[o,g]}]}],t}();t.PagerComponent=o,t.PaginationComponent=g,t.PaginationModule=p,t.PaginationConfig=a,t.ɵa=s,t.ɵb=r,Object.defineProperty(t,"__esModule",{value:!0})}); //# sourceMappingURL=ngx-bootstrap-pagination.umd.min.js.map