ng2-pagination
Advanced tools
Comparing version 0.3.4 to 0.3.5
@@ -0,1 +1,6 @@ | ||
# 0.3.5 (2016-07-14) | ||
* Update codebase to **Angular 2 rc.4**. | ||
* Fix default template showing up when using custom templates (#45) | ||
* Fix buggy autoHide behaviour (#57) | ||
# 0.3.4 (2016-06-16) | ||
@@ -2,0 +7,0 @@ * Fix infinite loop in PaginatePipe when used with other impure pipes. |
@@ -272,3 +272,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
execute: function() { | ||
exports_3("DEFAULT_TEMPLATE", DEFAULT_TEMPLATE = "\n <div #template>\n <ng-content></ng-content>\n </div>\n <ul class=\"ng2-pagination\" \n role=\"navigation\" \n aria-label=\"Pagination\" \n *ngIf=\"!hasTemplate && !(autoHide && pages.length === 1)\">\n\n <li class=\"pagination-previous\" [class.disabled]=\"isFirstPage()\" *ngIf=\"directionLinks\"> \n <a *ngIf=\"1 < getCurrent()\" (click)=\"previous()\" aria-label=\"Next page\">\n Previous <span class=\"show-for-sr\">page</span>\n </a>\n <span *ngIf=\"isFirstPage()\">Previous <span class=\"show-for-sr\">page</span></span>\n </li>\n\n <li [class.current]=\"getCurrent() === page.value\" *ngFor=\"let page of pages\">\n <a (click)=\"setCurrent(page.value)\" *ngIf=\"getCurrent() !== page.value\">\n <span class=\"show-for-sr\">Page</span>\n <span>{{ page.label }}</span>\n </a>\n <div *ngIf=\"getCurrent() === page.value\">\n <span class=\"show-for-sr\">You're on page</span>\n <span>{{ page.label }}</span> \n </div>\n </li>\n\n <li class=\"pagination-next\" [class.disabled]=\"isLastPage()\" *ngIf=\"directionLinks\">\n <a *ngIf=\"!isLastPage()\" (click)=\"next()\" aria-label=\"Next page\">\n Next <span class=\"show-for-sr\">page</span>\n </a>\n <span *ngIf=\"isLastPage()\">Next <span class=\"show-for-sr\">page</span></span>\n </li>\n\n </ul>\n "); | ||
exports_3("DEFAULT_TEMPLATE", DEFAULT_TEMPLATE = "\n <div #template>\n <ng-content></ng-content>\n </div>\n <ul class=\"ng2-pagination\" \n role=\"navigation\" \n aria-label=\"Pagination\" \n *ngIf=\"!hasTemplate && !(autoHide && pages.length <= 1)\">\n\n <li class=\"pagination-previous\" [class.disabled]=\"isFirstPage()\" *ngIf=\"directionLinks\"> \n <a *ngIf=\"1 < getCurrent()\" (click)=\"previous()\" aria-label=\"Next page\">\n Previous <span class=\"show-for-sr\">page</span>\n </a>\n <span *ngIf=\"isFirstPage()\">Previous <span class=\"show-for-sr\">page</span></span>\n </li>\n\n <li [class.current]=\"getCurrent() === page.value\" *ngFor=\"let page of pages\">\n <a (click)=\"setCurrent(page.value)\" *ngIf=\"getCurrent() !== page.value\">\n <span class=\"show-for-sr\">Page</span>\n <span>{{ page.label }}</span>\n </a>\n <div *ngIf=\"getCurrent() === page.value\">\n <span class=\"show-for-sr\">You're on page</span>\n <span>{{ page.label }}</span> \n </div>\n </li>\n\n <li class=\"pagination-next\" [class.disabled]=\"isLastPage()\" *ngIf=\"directionLinks\">\n <a *ngIf=\"!isLastPage()\" (click)=\"next()\" aria-label=\"Next page\">\n Next <span class=\"show-for-sr\">page</span>\n </a>\n <span *ngIf=\"isLastPage()\">Next <span class=\"show-for-sr\">page</span></span>\n </li>\n\n </ul>\n "); | ||
exports_3("DEFAULT_STYLES", DEFAULT_STYLES = "\n.ng2-pagination {\n margin-left: 0;\n margin-bottom: 1rem; }\n .ng2-pagination::before, .ng2-pagination::after {\n content: ' ';\n display: table; }\n .ng2-pagination::after {\n clear: both; }\n .ng2-pagination li {\n -moz-user-select: none;\n -webkit-user-select: none;\n -ms-user-select: none;\n font-size: 0.875rem;\n margin-right: 0.0625rem;\n border-radius: 0; }\n .ng2-pagination li {\n display: inline-block; }\n .ng2-pagination a,\n .ng2-pagination button {\n color: #0a0a0a; \n display: block;\n padding: 0.1875rem 0.625rem;\n border-radius: 0; }\n .ng2-pagination a:hover,\n .ng2-pagination button:hover {\n background: #e6e6e6; }\n .ng2-pagination .current {\n padding: 0.1875rem 0.625rem;\n background: #2199e8;\n color: #fefefe;\n cursor: default; }\n .ng2-pagination .disabled {\n padding: 0.1875rem 0.625rem;\n color: #cacaca;\n cursor: default; } \n .ng2-pagination .disabled:hover {\n background: transparent; }\n .ng2-pagination .ellipsis::after {\n content: '\u2026';\n padding: 0.1875rem 0.625rem;\n color: #0a0a0a; }\n\n.ng2-pagination .pagination-previous a::before,\n.ng2-pagination .pagination-previous.disabled::before { \n content: '\u00AB';\n display: inline-block;\n margin-right: 0.5rem; }\n\n.ng2-pagination .pagination-next a::after,\n.ng2-pagination .pagination-next.disabled::after {\n content: '\u00BB';\n display: inline-block;\n margin-left: 0.5rem; }\n\n.ng2-pagination .show-for-sr {\n position: absolute !important;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0); }"); | ||
@@ -338,2 +338,3 @@ } | ||
} | ||
this.updatePageLinks(); | ||
}; | ||
@@ -344,4 +345,6 @@ PaginationControlsCmp.prototype.ngOnChanges = function () { | ||
PaginationControlsCmp.prototype.ngAfterViewInit = function () { | ||
var _this = this; | ||
if (this.template && 0 < this.template.nativeElement.children.length) { | ||
this.hasTemplate = true; | ||
setTimeout(function () { return _this.changeDetectorRef.markForCheck(); }); | ||
} | ||
@@ -393,2 +396,7 @@ }; | ||
var inst = this.service.getInstance(this.id); | ||
if (inst.totalItems < 1) { | ||
// when there are 0 or fewer (an error case) items, there are no "pages" as such, | ||
// but it makes sense to consider a single, empty page as the last page. | ||
return 1; | ||
} | ||
return Math.ceil(inst.totalItems / inst.itemsPerPage); | ||
@@ -395,0 +403,0 @@ }; |
@@ -57,2 +57,3 @@ "use strict"; | ||
} | ||
this.updatePageLinks(); | ||
}; | ||
@@ -63,4 +64,6 @@ PaginationControlsCmp.prototype.ngOnChanges = function () { | ||
PaginationControlsCmp.prototype.ngAfterViewInit = function () { | ||
var _this = this; | ||
if (this.template && 0 < this.template.nativeElement.children.length) { | ||
this.hasTemplate = true; | ||
setTimeout(function () { return _this.changeDetectorRef.markForCheck(); }); | ||
} | ||
@@ -112,2 +115,7 @@ }; | ||
var inst = this.service.getInstance(this.id); | ||
if (inst.totalItems < 1) { | ||
// when there are 0 or fewer (an error case) items, there are no "pages" as such, | ||
// but it makes sense to consider a single, empty page as the last page. | ||
return 1; | ||
} | ||
return Math.ceil(inst.totalItems / inst.itemsPerPage); | ||
@@ -114,0 +122,0 @@ }; |
@@ -6,3 +6,3 @@ /** | ||
"use strict"; | ||
exports.DEFAULT_TEMPLATE = "\n <div #template>\n <ng-content></ng-content>\n </div>\n <ul class=\"ng2-pagination\" \n role=\"navigation\" \n aria-label=\"Pagination\" \n *ngIf=\"!hasTemplate && !(autoHide && pages.length === 1)\">\n\n <li class=\"pagination-previous\" [class.disabled]=\"isFirstPage()\" *ngIf=\"directionLinks\"> \n <a *ngIf=\"1 < getCurrent()\" (click)=\"previous()\" aria-label=\"Next page\">\n Previous <span class=\"show-for-sr\">page</span>\n </a>\n <span *ngIf=\"isFirstPage()\">Previous <span class=\"show-for-sr\">page</span></span>\n </li>\n\n <li [class.current]=\"getCurrent() === page.value\" *ngFor=\"let page of pages\">\n <a (click)=\"setCurrent(page.value)\" *ngIf=\"getCurrent() !== page.value\">\n <span class=\"show-for-sr\">Page</span>\n <span>{{ page.label }}</span>\n </a>\n <div *ngIf=\"getCurrent() === page.value\">\n <span class=\"show-for-sr\">You're on page</span>\n <span>{{ page.label }}</span> \n </div>\n </li>\n\n <li class=\"pagination-next\" [class.disabled]=\"isLastPage()\" *ngIf=\"directionLinks\">\n <a *ngIf=\"!isLastPage()\" (click)=\"next()\" aria-label=\"Next page\">\n Next <span class=\"show-for-sr\">page</span>\n </a>\n <span *ngIf=\"isLastPage()\">Next <span class=\"show-for-sr\">page</span></span>\n </li>\n\n </ul>\n "; | ||
exports.DEFAULT_TEMPLATE = "\n <div #template>\n <ng-content></ng-content>\n </div>\n <ul class=\"ng2-pagination\" \n role=\"navigation\" \n aria-label=\"Pagination\" \n *ngIf=\"!hasTemplate && !(autoHide && pages.length <= 1)\">\n\n <li class=\"pagination-previous\" [class.disabled]=\"isFirstPage()\" *ngIf=\"directionLinks\"> \n <a *ngIf=\"1 < getCurrent()\" (click)=\"previous()\" aria-label=\"Next page\">\n Previous <span class=\"show-for-sr\">page</span>\n </a>\n <span *ngIf=\"isFirstPage()\">Previous <span class=\"show-for-sr\">page</span></span>\n </li>\n\n <li [class.current]=\"getCurrent() === page.value\" *ngFor=\"let page of pages\">\n <a (click)=\"setCurrent(page.value)\" *ngIf=\"getCurrent() !== page.value\">\n <span class=\"show-for-sr\">Page</span>\n <span>{{ page.label }}</span>\n </a>\n <div *ngIf=\"getCurrent() === page.value\">\n <span class=\"show-for-sr\">You're on page</span>\n <span>{{ page.label }}</span> \n </div>\n </li>\n\n <li class=\"pagination-next\" [class.disabled]=\"isLastPage()\" *ngIf=\"directionLinks\">\n <a *ngIf=\"!isLastPage()\" (click)=\"next()\" aria-label=\"Next page\">\n Next <span class=\"show-for-sr\">page</span>\n </a>\n <span *ngIf=\"isLastPage()\">Next <span class=\"show-for-sr\">page</span></span>\n </li>\n\n </ul>\n "; | ||
exports.DEFAULT_STYLES = "\n.ng2-pagination {\n margin-left: 0;\n margin-bottom: 1rem; }\n .ng2-pagination::before, .ng2-pagination::after {\n content: ' ';\n display: table; }\n .ng2-pagination::after {\n clear: both; }\n .ng2-pagination li {\n -moz-user-select: none;\n -webkit-user-select: none;\n -ms-user-select: none;\n font-size: 0.875rem;\n margin-right: 0.0625rem;\n border-radius: 0; }\n .ng2-pagination li {\n display: inline-block; }\n .ng2-pagination a,\n .ng2-pagination button {\n color: #0a0a0a; \n display: block;\n padding: 0.1875rem 0.625rem;\n border-radius: 0; }\n .ng2-pagination a:hover,\n .ng2-pagination button:hover {\n background: #e6e6e6; }\n .ng2-pagination .current {\n padding: 0.1875rem 0.625rem;\n background: #2199e8;\n color: #fefefe;\n cursor: default; }\n .ng2-pagination .disabled {\n padding: 0.1875rem 0.625rem;\n color: #cacaca;\n cursor: default; } \n .ng2-pagination .disabled:hover {\n background: transparent; }\n .ng2-pagination .ellipsis::after {\n content: '\u2026';\n padding: 0.1875rem 0.625rem;\n color: #0a0a0a; }\n\n.ng2-pagination .pagination-previous a::before,\n.ng2-pagination .pagination-previous.disabled::before { \n content: '\u00AB';\n display: inline-block;\n margin-right: 0.5rem; }\n\n.ng2-pagination .pagination-next a::after,\n.ng2-pagination .pagination-next.disabled::after {\n content: '\u00BB';\n display: inline-block;\n margin-left: 0.5rem; }\n\n.ng2-pagination .show-for-sr {\n position: absolute !important;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0); }"; |
{ | ||
"name": "ng2-pagination", | ||
"version": "0.3.4", | ||
"description": "Pagination for Angular2", | ||
"version": "0.3.5", | ||
"description": "Pagination for Angular 2", | ||
"main": "index.js", | ||
@@ -36,7 +36,7 @@ "scripts": { | ||
"devDependencies": { | ||
"@angular/common": "2.0.0-rc.1", | ||
"@angular/compiler": "2.0.0-rc.1", | ||
"@angular/core": "2.0.0-rc.1", | ||
"@angular/platform-browser": "2.0.0-rc.1", | ||
"@angular/platform-browser-dynamic": "2.0.0-rc.1", | ||
"@angular/common": "2.0.0-rc.4", | ||
"@angular/compiler": "2.0.0-rc.4", | ||
"@angular/core": "2.0.0-rc.4", | ||
"@angular/platform-browser": "2.0.0-rc.4", | ||
"@angular/platform-browser-dynamic": "2.0.0-rc.4", | ||
"bulma": "^0.0.14", | ||
@@ -43,0 +43,0 @@ "core-js": "^2.4.0", |
@@ -22,3 +22,3 @@ # Angular2 Pagination [![Build Status](https://travis-ci.org/michaelbromley/ng2-pagination.svg?branch=master)](https://travis-ci.org/michaelbromley/ng2-pagination) | ||
Angular 2 is not yet stable, and API changes are ongoing. Therefore, if encountering errors using this | ||
lib, ensure your version of Angular is compatible. The current version used to develop this lib is angular2 **2.0.0-rc.1 +**. | ||
lib, ensure your version of Angular is compatible. The current version used to develop this lib is angular2 **2.0.0-rc.4 +**. | ||
If you need to support a previous version of Angular 2 for now, please see the changelog for advice on which version to use. | ||
@@ -146,15 +146,15 @@ | ||
```HTML | ||
<pagination-controls #p (pageChange)="currentPage = $event"> | ||
<pagination-controls #pagination (pageChange)="currentPage = $event"> | ||
<div class="custom-pagination"> | ||
<div class="pagination-previous" [class.disabled]="p.isFirstPage()"> | ||
<a *ngIf="!p.isFirstPage()" (click)="p.previous()"> < </a> | ||
<div class="pagination-previous" [class.disabled]="pagination.isFirstPage()"> | ||
<a *ngIf="!pagination.isFirstPage()" (click)="pagination.previous()"> < </a> | ||
</div> | ||
<div *ngFor="let page of p.pages" [class.current]="p.getCurrent() === page.value"> | ||
<a (click)="p.setCurrent(page.value)" *ngIf="p.getCurrent() !== page.value"> | ||
<div *ngFor="let page of pagination.pages" [class.current]="pagination.getCurrent() === page.value"> | ||
<a (click)="pagination.setCurrent(page.value)" *ngIf="pagination.getCurrent() !== page.value"> | ||
<span>{{ page.label }}</span> | ||
</a> | ||
<div *ngIf="p.getCurrent() === page.value"> | ||
<div *ngIf="pagination.getCurrent() === page.value"> | ||
<span>{{ page.label }}</span> | ||
@@ -164,4 +164,4 @@ </div> | ||
<div class="pagination-next" [class.disabled]="p.isLastPage()" *ngIf="p.directionLinks"> | ||
<a *ngIf="!p.isLastPage()" (click)="p.next()"> > </a> | ||
<div class="pagination-next" [class.disabled]="pagination.isLastPage()" *ngIf="pagination.directionLinks"> | ||
<a *ngIf="!pagination.isLastPage()" (click)="pagination.next()"> > </a> | ||
</div> | ||
@@ -168,0 +168,0 @@ |
72350
1233