blob: 3e1c1b4a393c6e95c9c8933abccdebfcc8fe2446 [file] [log] [blame]
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/common"),require("@angular/material/icon"),require("@angular/material/button"),require("@angular/core"),require("@angular/cdk/coercion"),require("@angular/cdk/bidi")):"function"==typeof define&&define.amd?define("@covalent/core/paging",["exports","@angular/common","@angular/material/icon","@angular/material/button","@angular/core","@angular/cdk/coercion","@angular/cdk/bidi"],e):e((t.covalent=t.covalent||{},t.covalent.core=t.covalent.core||{},t.covalent.core.paging={}),t.ng.common,t.ng.material.icon,t.ng.material.button,t.ng.core,t.ng.cdk.coercion,t.ng.cdk.bidi)}(this,function(t,e,i,n,a,o,r){"use strict";var g=(Object.defineProperty(s.prototype,"pageLinkCount",{get:function(){return this._pageLinkCount},set:function(t){this._pageLinkCount=o.coerceNumberProperty(t),this._calculatePageLinks(),this._changeDetectorRef.markForCheck()},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"pageSize",{get:function(){return this._pageSize},set:function(t){this._pageSize=o.coerceNumberProperty(t),this._page=1,this._initialized&&this._handleOnChange(),this._changeDetectorRef.markForCheck()},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"total",{get:function(){return this._total},set:function(t){this._total=o.coerceNumberProperty(t),this._calculateRows(),this._calculatePageLinks(),this._changeDetectorRef.markForCheck()},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"pageLinks",{get:function(){return this._pageLinks},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"range",{get:function(){return(this._toRow?this._fromRow:0)+"-"+this._toRow},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"page",{get:function(){return this._page},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"maxPage",{get:function(){return Math.ceil(this._total/this._pageSize)},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"isRTL",{get:function(){return!!this._dir&&"rtl"===this._dir.dir},enumerable:!0,configurable:!0}),s.prototype.ngOnInit=function(){this._page=o.coerceNumberProperty(this.initialPage),this._calculateRows(),this._calculatePageLinks(),this._initialized=!0,this._changeDetectorRef.markForCheck()},s.prototype.navigateToPage=function(t){return(1===t||1<=t&&t<=this.maxPage)&&(this._page=o.coerceNumberProperty(Math.floor(t)),this._handleOnChange(),!0)},s.prototype.firstPage=function(){return this.navigateToPage(1)},s.prototype.prevPage=function(){return this.navigateToPage(this._page-1)},s.prototype.nextPage=function(){return this.navigateToPage(this._page+1)},s.prototype.lastPage=function(){return this.navigateToPage(this.maxPage)},s.prototype.isMinPage=function(){return this._page<=1},s.prototype.isMaxPage=function(){return this._page>=this.maxPage},s.prototype._calculateRows=function(){var t=this._pageSize*this._page;this._fromRow=this._pageSize*(this._page-1)+1,this._toRow=this._total>t?t:this._total},s.prototype._calculatePageLinks=function(){this.isMaxPage()&&(this._hitEnd=!0,this._hitStart=!1),this.isMinPage()&&(this._hitEnd=!1,this._hitStart=!0);var t=this.pageLinkCount;this.pageLinkCount>this.maxPage&&(t=this.maxPage),this._pageLinks=[];for(var e=Math.floor(t/2),i=0;i<t;i++)t%2==0&&this.page+e>this.maxPage||t%2!=0&&this.page+e>=this.maxPage?this._pageLinks[i]=this.maxPage-(t-(i+1)):(2<t||t<=2&&this._hitEnd)&&0<this.page-e?this._pageLinks[i]=this.page-e+i:this.page-e<=0?this._pageLinks[i]=i+1:this._pageLinks[i]=this.page+i},s.prototype._handleOnChange=function(){this._calculateRows(),this._calculatePageLinks();var t={page:this._page,maxPage:this.maxPage,pageSize:this._pageSize,total:this._total,fromRow:this._fromRow,toRow:this._toRow};this._changeDetectorRef.markForCheck(),this.onChange.emit(t)},s.decorators=[{type:a.Component,args:[{changeDetection:a.ChangeDetectionStrategy.OnPush,selector:"td-paging-bar",template:'<div class="td-paging-bar" (change)="$event.stopPropagation()" >\n <ng-content></ng-content>\n <div class="td-paging-bar-navigation">\n <button mat-icon-button class="td-paging-bar-first-page" type="button" *ngIf="firstLast" [disabled]="isMinPage()" (click)="firstPage()">\n <mat-icon>{{ isRTL ? \'skip_next\' : \'skip_previous\' }}</mat-icon>\n </button>\n <button mat-icon-button class="td-paging-bar-prev-page" type="button" [disabled]="isMinPage()" (click)="prevPage()">\n <mat-icon>{{ isRTL ? \'navigate_next\' : \'navigate_before\' }}</mat-icon>\n </button>\n <ng-template *ngIf="pageLinkCount > 0" let-link let-index="index" ngFor [ngForOf]="pageLinks">\n <button class="td-paging-bar-link-page" mat-icon-button type="button" [color]="page === link ? \'accent\' : \'\'" (click)="navigateToPage(link)">{{link}}</button>\n </ng-template>\n <button mat-icon-button class="td-paging-bar-next-page" type="button" [disabled]="isMaxPage()" (click)="nextPage()">\n <mat-icon>{{ isRTL ? \'navigate_before\' : \'navigate_next\' }}</mat-icon>\n </button>\n <button mat-icon-button class="td-paging-bar-last-page" type="button" *ngIf="firstLast" [disabled]="isMaxPage()" (click)="lastPage()">\n <mat-icon>{{ isRTL ? \'skip_previous\' : \'skip_next\' }}</mat-icon>\n </button>\n </div>\n</div>',styles:[":host{display:block}:host .td-paging-bar{height:48px;-webkit-box-sizing:border-box;box-sizing:border-box;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-ms-flex-line-pack:center;align-content:center;max-width:100%;-webkit-box-pack:end;-ms-flex-pack:end;justify-content:flex-end}:host .td-paging-bar ::ng-deep>*{margin:0 10px}:host .td-paging-bar [mat-icon-button]{font-size:12px;font-weight:400}"]}]}],s.ctorParameters=function(){return[{type:r.Dir,decorators:[{type:a.Optional}]},{type:a.ChangeDetectorRef}]},s.propDecorators={firstLast:[{type:a.Input,args:["firstLast"]}],initialPage:[{type:a.Input,args:["initialPage"]}],pageLinkCount:[{type:a.Input,args:["pageLinkCount"]}],pageSize:[{type:a.Input,args:["pageSize"]}],total:[{type:a.Input,args:["total"]}],onChange:[{type:a.Output,args:["change"]}]},s);function s(t,e){this._dir=t,this._changeDetectorRef=e,this._pageSize=50,this._total=0,this._page=1,this._fromRow=1,this._toRow=1,this._initialized=!1,this._pageLinks=[],this._pageLinkCount=0,this._hitEnd=!1,this._hitStart=!1,this.firstLast=!0,this.initialPage=1,this.onChange=new a.EventEmitter}var c=(p.decorators=[{type:a.NgModule,args:[{imports:[e.CommonModule,i.MatIconModule,n.MatButtonModule],declarations:[g],exports:[g]}]}],p);function p(){}t.CovalentPagingModule=c,t.TdPagingBarComponent=g,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=covalent-core-paging.umd.min.js.map