ngx-pagination-bootstrap
Version:
A bootstrap(4) based angular(4+) pagination module.
9 lines • 9 kB
JavaScript
/**
* ngx-pagination-bootstrap - A bootstrap(4) based angular(4+) pagination module.
* @version v1.6.0
* @author Manish Kumar
* @link https://github.com/manishjanky/ngx-pagination-bootstrap#readme
* @license MIT
*/
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@angular/core"),require("@angular/common"),require("@angular/forms")):"function"==typeof define&&define.amd?define(["@angular/core","@angular/common","@angular/forms"],e):"object"==typeof exports?exports.ticktock=e(require("@angular/core"),require("@angular/common"),require("@angular/forms")):t.ticktock=e(t.ng.core,t.ng.common,t.ng.forms)}("undefined"!=typeof self?self:this,function(t,e,n){return function(t){function e(a){if(n[a])return n[a].exports;var r=n[a]={i:a,l:!1,exports:{}};return t[a].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,a){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:a})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=2)}([function(t,e,n){"use strict";var a=this&&this.__decorate||function(t,e,n,a){var r,i=arguments.length,o=i<3?e:null===a?a=Object.getOwnPropertyDescriptor(e,n):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,n,a);else for(var s=t.length-1;s>=0;s--)(r=t[s])&&(o=(i<3?r(o):i>3?r(e,n,o):r(e,n))||o);return i>3&&o&&Object.defineProperty(e,n,o),o},r=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)};Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),o=function(){function t(){this.data=null,this.position="left",this.getPageData=new i.EventEmitter,this.currentPage=1,this.totalPages=[],this.pages=[],this.itemsRange={from:1,to:0},this.nullAble=null,this.pageSize=10}return t.prototype.ngOnInit=function(){null!=this.data&&(this.itemsCount=this.data.length),this.calculatePageNumbers(),this.calculateCurrentItemsRange()},t.prototype.ngOnChanges=function(t){this.currentPage=1;var e={event:t,pageNo:this.currentPage,pageSize:this.pageSize,data:this.nullAble};this.calculatePageNumbers(),this.changePageData(e)},t.prototype.calculatePageNumbers=function(){var t=Math.ceil(this.itemsCount/this.pageSize);this.totalPages=[];for(var e=0;e<t;e++)this.totalPages[e]=e+1;this.pages=this.totalPages.slice(0,5)},t.prototype.navigateToPage=function(t){this.currentPage=t;var e={event:event,pageNo:t,pageSize:this.pageSize,data:this.nullAble};this.changePageData(e)},t.prototype.changePageData=function(t){this.getPageItems(t),this.getNextPagesArrayToDisplay(),this.calculateCurrentItemsRange()},t.prototype.getPageItems=function(t){var e=null;null!=this.data&&(e=this.getCurrentPageData()),t.data=e,this.getPageData.emit(t)},t.prototype.getCurrentPageData=function(){var t=(this.currentPage-1)*this.pageSize,e=t+Number(this.pageSize);return this.data.slice(t,e)},t.prototype.getNextPagesArrayToDisplay=function(){var t=this.currentPage-3>=0?this.currentPage-3:0,e=this.currentPage+2<5?5:this.currentPage+2;e>this.totalPages.length&&(e=this.totalPages.length,t=this.totalPages.length-5<0?0:this.totalPages.length-5),this.pages=this.totalPages.slice(t,e)},t.prototype.changePageSize=function(){this.calculatePageNumbers(),this.currentPage=1;var t={event:event,pageNo:1,pageSize:this.pageSize,data:this.nullAble};this.changePageData(t)},t.prototype.nextPage=function(){this.navigateToPage(this.currentPage+1)},t.prototype.previousPage=function(){this.navigateToPage(this.currentPage-1)},t.prototype.calculateCurrentItemsRange=function(){return 0===this.itemsCount?(this.itemsRange.to=0,void(this.itemsRange.from=0)):(this.itemsRange.from=this.pageSize*this.currentPage-this.pageSize+1,this.currentPage===this.pages[this.pages.length-1]?void(this.itemsRange.to=this.itemsCount):void(this.itemsRange.to=this.pageSize*this.currentPage))},a([i.Input(),r("design:type",Number)],t.prototype,"pageSize",void 0),a([i.Input(),r("design:type",Number)],t.prototype,"itemsCount",void 0),a([i.Input(),r("design:type",Object)],t.prototype,"data",void 0),a([i.Input(),r("design:type",String)],t.prototype,"position",void 0),a([i.Output(),r("design:type",Object)],t.prototype,"getPageData",void 0),t=a([i.Component({selector:"ng-pagination",template:n(5),styles:[n(6)]}),r("design:paramtypes",[])],t)}();e.PaginationComponent=o},function(e,n){e.exports=t},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var a=n(3);e.PaginationComponent=a.PaginationComponent;var r=n(9);e.PaginationModule=r.PaginationModule},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}(n(4))},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}(n(0))},function(t,e){t.exports='<nav aria-label="pagination" class="p-1 d-flex" [ngClass]="{\'justify-content-center\':position==\'center\',\'justify-content-end\':position==\'right\'}">\r\n <select data-toggle="tooltip" data-placement="top" title="Items Per Page" [(ngModel)]="pageSize" class="form-control p-0" style="width:50px" (change)="changePageSize()">\r\n <option value="10">10</option>\r\n <option value="20">20</option>\r\n <option value="50">50</option>\r\n </select>\r\n <ul class="pagination">\r\n <li class="page-item" [ngClass]="{\'disabled\':currentPage == 1}">\r\n <button [disabled]="currentPage == 1" (click)="navigateToPage(1)" class="page-link" aria-label="first">\r\n <span aria-hidden="true">First</span>\r\n <span class="sr-only">First</span>\r\n </button>\r\n </li>\r\n <li class="page-item">\r\n <button [disabled]="currentPage == 1" (click)="previousPage()" class="page-link" aria-label="Previous">\r\n <span aria-hidden="true">«</span>\r\n <span class="sr-only">Previous</span>\r\n </button>\r\n </li>\r\n <li [ngClass]="{\'active\':currentPage == page}" class="page-item" *ngFor="let page of pages" (click)="navigateToPage(page)">\r\n <button class="page-link">{{page}}</button>\r\n </li>\r\n <li class="page-item">\r\n <button [disabled]="currentPage == totalPages[totalPages.length -1]" (click)="nextPage()" class="page-link" aria-label="Next">\r\n <span aria-hidden="true">»</span>\r\n <span class="sr-only">Next</span>\r\n </button>\r\n </li>\r\n <li class="page-item" [ngClass]="{\'disabled\':currentPage == totalPages[totalPages.length -1]}">\r\n <button [disabled]="currentPage == totalPages[totalPages.length -1]" (click)="navigateToPage(totalPages[totalPages.length -1])"\r\n class="page-link" aria-label="last">\r\n <span aria-hidden="true">Last</span>\r\n <span class="sr-only">Last</span>\r\n </button>\r\n </li>\r\n <li class="page-item d-none d-md-block">\r\n <button disabled class="page-link" aria-label="count">\r\n <span>{{itemsRange.from}} - {{itemsRange.to}} of {{itemsCount}}</span>\r\n </button>\r\n </li>\r\n </ul>\r\n</nav>'},function(t,e,n){var a=n(7);t.exports="string"==typeof a?a:a.toString()},function(t,e,n){e=t.exports=n(8)(void 0),e.push([t.i,"",""])},function(t,e){function n(t,e){var n=t[1]||"",r=t[3];if(!r)return n;if(e&&"function"==typeof btoa){var i=a(r);return[n].concat(r.sources.map(function(t){return"/*# sourceURL="+r.sourceRoot+t+" */"})).concat([i]).join("\n")}return[n].join("\n")}function a(t){return"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(t))))+" */"}t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var a=n(e,t);return e[2]?"@media "+e[2]+"{"+a+"}":a}).join("")},e.i=function(t,n){"string"==typeof t&&(t=[[null,t,""]]);for(var a={},r=0;r<this.length;r++){var i=this[r][0];"number"==typeof i&&(a[i]=!0)}for(r=0;r<t.length;r++){var o=t[r];"number"==typeof o[0]&&a[o[0]]||(n&&!o[2]?o[2]=n:n&&(o[2]="("+o[2]+") and ("+n+")"),e.push(o))}},e}},function(t,e,n){"use strict";var a=this&&this.__decorate||function(t,e,n,a){var r,i=arguments.length,o=i<3?e:null===a?a=Object.getOwnPropertyDescriptor(e,n):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,n,a);else for(var s=t.length-1;s>=0;s--)(r=t[s])&&(o=(i<3?r(o):i>3?r(e,n,o):r(e,n))||o);return i>3&&o&&Object.defineProperty(e,n,o),o};Object.defineProperty(e,"__esModule",{value:!0});var r=n(1),i=n(10),o=n(11),s=n(0),l=function(){function t(){}return t=a([r.NgModule({declarations:[s.PaginationComponent],imports:[i.CommonModule,o.FormsModule],exports:[s.PaginationComponent],providers:[],bootstrap:[]})],t)}();e.PaginationModule=l},function(t,n){t.exports=e},function(t,e){t.exports=n}])});
//# sourceMappingURL=index.umd.min.js.map