1 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6 | };
|
7 | var __metadata = (this && this.__metadata) || function (k, v) {
|
8 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
9 | };
|
10 | System.register("pagination-instance", [], function(exports_1, context_1) {
|
11 | "use strict";
|
12 | var __moduleName = context_1 && context_1.id;
|
13 | return {
|
14 | setters:[],
|
15 | execute: function() {
|
16 | }
|
17 | }
|
18 | });
|
19 | System.register("pagination.service", ['@angular/core'], function(exports_2, context_2) {
|
20 | "use strict";
|
21 | var __moduleName = context_2 && context_2.id;
|
22 | var core_1;
|
23 | var PaginationService;
|
24 | return {
|
25 | setters:[
|
26 | function (core_1_1) {
|
27 | core_1 = core_1_1;
|
28 | }],
|
29 | execute: function() {
|
30 | PaginationService = (function () {
|
31 | function PaginationService() {
|
32 | this.change = new core_1.EventEmitter();
|
33 | this.instances = {};
|
34 | this.DEFAULT_ID = 'DEFAULT_PAGINATION_ID';
|
35 | }
|
36 | PaginationService.prototype.defaultId = function () { return this.DEFAULT_ID; };
|
37 | PaginationService.prototype.register = function (instance) {
|
38 | if (!instance.id) {
|
39 | instance.id = this.DEFAULT_ID;
|
40 | }
|
41 | if (!this.instances[instance.id]) {
|
42 | this.instances[instance.id] = instance;
|
43 | this.change.emit(instance.id);
|
44 | }
|
45 | else {
|
46 | var changed = this.updateInstance(instance);
|
47 | if (changed) {
|
48 | this.change.emit(instance.id);
|
49 | }
|
50 | }
|
51 | };
|
52 | |
53 |
|
54 |
|
55 |
|
56 | PaginationService.prototype.updateInstance = function (instance) {
|
57 | var changed = false;
|
58 | for (var prop in this.instances[instance.id]) {
|
59 | if (instance[prop] !== this.instances[instance.id][prop]) {
|
60 | this.instances[instance.id][prop] = instance[prop];
|
61 | changed = true;
|
62 | }
|
63 | }
|
64 | return changed;
|
65 | };
|
66 | |
67 |
|
68 |
|
69 | PaginationService.prototype.getCurrentPage = function (id) {
|
70 | if (this.instances[id]) {
|
71 | return this.instances[id].currentPage;
|
72 | }
|
73 | };
|
74 | |
75 |
|
76 |
|
77 | PaginationService.prototype.setCurrentPage = function (id, page) {
|
78 | if (this.instances[id]) {
|
79 | var instance = this.instances[id];
|
80 | var maxPage = Math.ceil(instance.totalItems / instance.itemsPerPage);
|
81 | if (page <= maxPage && 1 <= page) {
|
82 | this.instances[id].currentPage = page;
|
83 | this.change.emit(id);
|
84 | }
|
85 | }
|
86 | };
|
87 | |
88 |
|
89 |
|
90 | PaginationService.prototype.setTotalItems = function (id, totalItems) {
|
91 | if (this.instances[id] && 0 <= totalItems) {
|
92 | this.instances[id].totalItems = totalItems;
|
93 | this.change.emit(id);
|
94 | }
|
95 | };
|
96 | |
97 |
|
98 |
|
99 | PaginationService.prototype.setItemsPerPage = function (id, itemsPerPage) {
|
100 | if (this.instances[id]) {
|
101 | this.instances[id].itemsPerPage = itemsPerPage;
|
102 | this.change.emit(id);
|
103 | }
|
104 | };
|
105 | |
106 |
|
107 |
|
108 |
|
109 | PaginationService.prototype.getInstance = function (id) {
|
110 | if (id === void 0) { id = this.DEFAULT_ID; }
|
111 | if (this.instances[id]) {
|
112 | return this.clone(this.instances[id]);
|
113 | }
|
114 | return {};
|
115 | };
|
116 | |
117 |
|
118 |
|
119 | PaginationService.prototype.clone = function (obj) {
|
120 | var target = {};
|
121 | for (var i in obj) {
|
122 | if (obj.hasOwnProperty(i)) {
|
123 | target[i] = obj[i];
|
124 | }
|
125 | }
|
126 | return target;
|
127 | };
|
128 | return PaginationService;
|
129 | }());
|
130 | exports_2("PaginationService", PaginationService);
|
131 | }
|
132 | }
|
133 | });
|
134 | System.register("paginate.pipe", ["@angular/core", "pagination.service"], function(exports_3, context_3) {
|
135 | "use strict";
|
136 | var __moduleName = context_3 && context_3.id;
|
137 | var core_2, pagination_service_1;
|
138 | var LARGE_NUMBER, PaginatePipe;
|
139 | return {
|
140 | setters:[
|
141 | function (core_2_1) {
|
142 | core_2 = core_2_1;
|
143 | },
|
144 | function (pagination_service_1_1) {
|
145 | pagination_service_1 = pagination_service_1_1;
|
146 | }],
|
147 | execute: function() {
|
148 | LARGE_NUMBER = Number.MAX_SAFE_INTEGER;
|
149 | PaginatePipe = (function () {
|
150 | function PaginatePipe(service) {
|
151 | this.service = service;
|
152 |
|
153 | this.state = {};
|
154 | }
|
155 | PaginatePipe.prototype.transform = function (collection, args) {
|
156 |
|
157 |
|
158 |
|
159 |
|
160 | if (args instanceof Array) {
|
161 |
|
162 | args = args[0];
|
163 | }
|
164 | if (!(collection instanceof Array)) {
|
165 | var _id = args.id || this.service.defaultId;
|
166 | if (this.state[_id]) {
|
167 | return this.state[_id].slice;
|
168 | }
|
169 | else {
|
170 | return collection;
|
171 | }
|
172 | }
|
173 | var serverSideMode = args.totalItems && args.totalItems !== collection.length;
|
174 | var instance = this.createInstance(collection, args);
|
175 | var id = instance.id;
|
176 | var start, end;
|
177 | var perPage = instance.itemsPerPage;
|
178 | this.service.register(instance);
|
179 | if (!serverSideMode && collection instanceof Array) {
|
180 | perPage = +perPage || LARGE_NUMBER;
|
181 | start = (instance.currentPage - 1) * perPage;
|
182 | end = start + perPage;
|
183 | var isIdentical = this.stateIsIdentical(id, collection, start, end);
|
184 | if (isIdentical) {
|
185 | return this.state[id].slice;
|
186 | }
|
187 | else {
|
188 | var slice = collection.slice(start, end);
|
189 | this.saveState(id, collection, slice, start, end);
|
190 | this.service.change.emit(id);
|
191 | return slice;
|
192 | }
|
193 | }
|
194 |
|
195 |
|
196 | this.saveState(id, collection, collection, start, end);
|
197 | return collection;
|
198 | };
|
199 | |
200 |
|
201 |
|
202 | PaginatePipe.prototype.createInstance = function (collection, args) {
|
203 | var config = args;
|
204 | this.checkConfig(config);
|
205 | return {
|
206 | id: config.id || this.service.defaultId(),
|
207 | itemsPerPage: config.itemsPerPage || 0,
|
208 | currentPage: config.currentPage || 1,
|
209 | totalItems: config.totalItems || collection.length
|
210 | };
|
211 | };
|
212 | |
213 |
|
214 |
|
215 | PaginatePipe.prototype.checkConfig = function (config) {
|
216 | var required = ['itemsPerPage', 'currentPage'];
|
217 | var missing = required.filter(function (prop) { return !(prop in config); });
|
218 | if (0 < missing.length) {
|
219 | throw new Error("PaginatePipe: Argument is missing the following required properties: " + missing.join(', '));
|
220 | }
|
221 | };
|
222 | |
223 |
|
224 |
|
225 |
|
226 |
|
227 |
|
228 | PaginatePipe.prototype.saveState = function (id, collection, slice, start, end) {
|
229 | this.state[id] = {
|
230 | collection: collection,
|
231 | size: collection.length,
|
232 | slice: slice,
|
233 | start: start,
|
234 | end: end
|
235 | };
|
236 | };
|
237 | |
238 |
|
239 |
|
240 | PaginatePipe.prototype.stateIsIdentical = function (id, collection, start, end) {
|
241 | var state = this.state[id];
|
242 | if (!state) {
|
243 | return false;
|
244 | }
|
245 | var isMetaDataIdentical = state.size === collection.length &&
|
246 | state.start === start &&
|
247 | state.end === end;
|
248 | if (!isMetaDataIdentical) {
|
249 | return false;
|
250 | }
|
251 | return state.slice.every(function (element, index) { return element === collection[start + index]; });
|
252 | };
|
253 | PaginatePipe = __decorate([
|
254 | core_2.Pipe({
|
255 | name: 'paginate',
|
256 | pure: false
|
257 | }),
|
258 | __metadata('design:paramtypes', [pagination_service_1.PaginationService])
|
259 | ], PaginatePipe);
|
260 | return PaginatePipe;
|
261 | }());
|
262 | exports_3("PaginatePipe", PaginatePipe);
|
263 | }
|
264 | }
|
265 | });
|
266 |
|
267 |
|
268 |
|
269 |
|
270 | System.register("template", [], function(exports_4, context_4) {
|
271 | "use strict";
|
272 | var __moduleName = context_4 && context_4.id;
|
273 | var DEFAULT_TEMPLATE, DEFAULT_STYLES;
|
274 | return {
|
275 | setters:[],
|
276 | execute: function() {
|
277 | exports_4("DEFAULT_TEMPLATE", DEFAULT_TEMPLATE = "\n <pagination-template #p=\"paginationApi\"\n [id]=\"id\"\n [maxSize]=\"maxSize\"\n (pageChange)=\"pageChange.emit($event)\">\n <ul class=\"ng2-pagination\" \n role=\"navigation\" \n [attr.aria-label]=\"screenReaderPaginationLabel\" \n *ngIf=\"!(autoHide && p.pages.length <= 1)\">\n\n <li class=\"pagination-previous\" [class.disabled]=\"p.isFirstPage()\" *ngIf=\"directionLinks\"> \n <a *ngIf=\"1 < p.getCurrent()\" (click)=\"p.previous()\" [attr.aria-label]=\"previousLabel + ' ' + screenReaderPageLabel\">\n {{ previousLabel }} <span class=\"show-for-sr\">{{ screenReaderPageLabel }}</span>\n </a>\n <span *ngIf=\"p.isFirstPage()\">\n {{ previousLabel }} <span class=\"show-for-sr\">{{ screenReaderPageLabel }}</span>\n </span>\n </li>\n\n <li [class.current]=\"p.getCurrent() === page.value\" *ngFor=\"let page of p.pages\">\n <a (click)=\"p.setCurrent(page.value)\" *ngIf=\"p.getCurrent() !== page.value\">\n <span class=\"show-for-sr\">{{ screenReaderPageLabel }} </span>\n <span>{{ page.label }}</span>\n </a>\n <div *ngIf=\"p.getCurrent() === page.value\">\n <span class=\"show-for-sr\">{{ screenReaderCurrentLabel }} </span>\n <span>{{ page.label }}</span> \n </div>\n </li>\n\n <li class=\"pagination-next\" [class.disabled]=\"p.isLastPage()\" *ngIf=\"directionLinks\">\n <a *ngIf=\"!p.isLastPage()\" (click)=\"p.next()\" [attr.aria-label]=\"nextLabel + ' ' + screenReaderPageLabel\">\n {{ nextLabel }} <span class=\"show-for-sr\">{{ screenReaderPageLabel }}</span>\n </a>\n <span *ngIf=\"p.isLastPage()\">\n {{ nextLabel }} <span class=\"show-for-sr\">{{ screenReaderPageLabel }}</span>\n </span>\n </li>\n\n </ul>\n </pagination-template>\n ");
|
278 | exports_4("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 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); }");
|
279 | }
|
280 | }
|
281 | });
|
282 | System.register("pagination-controls.component", ['@angular/core', "template"], function(exports_5, context_5) {
|
283 | "use strict";
|
284 | var __moduleName = context_5 && context_5.id;
|
285 | var core_3, template_1;
|
286 | var PaginationControlsComponent;
|
287 | return {
|
288 | setters:[
|
289 | function (core_3_1) {
|
290 | core_3 = core_3_1;
|
291 | },
|
292 | function (template_1_1) {
|
293 | template_1 = template_1_1;
|
294 | }],
|
295 | execute: function() {
|
296 | |
297 |
|
298 |
|
299 | PaginationControlsComponent = (function () {
|
300 | function PaginationControlsComponent() {
|
301 | this.maxSize = 7;
|
302 | this.previousLabel = 'Previous';
|
303 | this.nextLabel = 'Next';
|
304 | this.screenReaderPaginationLabel = 'Pagination';
|
305 | this.screenReaderPageLabel = 'page';
|
306 | this.screenReaderCurrentLabel = "You're on page";
|
307 | this.pageChange = new core_3.EventEmitter();
|
308 | this._directionLinks = true;
|
309 | this._autoHide = false;
|
310 | }
|
311 | Object.defineProperty(PaginationControlsComponent.prototype, "directionLinks", {
|
312 | get: function () {
|
313 | return this._directionLinks;
|
314 | },
|
315 | set: function (value) {
|
316 | this._directionLinks = !!value && value !== 'false';
|
317 | },
|
318 | enumerable: true,
|
319 | configurable: true
|
320 | });
|
321 | Object.defineProperty(PaginationControlsComponent.prototype, "autoHide", {
|
322 | get: function () {
|
323 | return this._autoHide;
|
324 | },
|
325 | set: function (value) {
|
326 | this._autoHide = !!value && value !== 'false';
|
327 | },
|
328 | enumerable: true,
|
329 | configurable: true
|
330 | });
|
331 | __decorate([
|
332 | core_3.Input(),
|
333 | __metadata('design:type', String)
|
334 | ], PaginationControlsComponent.prototype, "id", void 0);
|
335 | __decorate([
|
336 | core_3.Input(),
|
337 | __metadata('design:type', Number)
|
338 | ], PaginationControlsComponent.prototype, "maxSize", void 0);
|
339 | __decorate([
|
340 | core_3.Input(),
|
341 | __metadata('design:type', Boolean)
|
342 | ], PaginationControlsComponent.prototype, "directionLinks", null);
|
343 | __decorate([
|
344 | core_3.Input(),
|
345 | __metadata('design:type', Boolean)
|
346 | ], PaginationControlsComponent.prototype, "autoHide", null);
|
347 | __decorate([
|
348 | core_3.Input(),
|
349 | __metadata('design:type', String)
|
350 | ], PaginationControlsComponent.prototype, "previousLabel", void 0);
|
351 | __decorate([
|
352 | core_3.Input(),
|
353 | __metadata('design:type', String)
|
354 | ], PaginationControlsComponent.prototype, "nextLabel", void 0);
|
355 | __decorate([
|
356 | core_3.Input(),
|
357 | __metadata('design:type', String)
|
358 | ], PaginationControlsComponent.prototype, "screenReaderPaginationLabel", void 0);
|
359 | __decorate([
|
360 | core_3.Input(),
|
361 | __metadata('design:type', String)
|
362 | ], PaginationControlsComponent.prototype, "screenReaderPageLabel", void 0);
|
363 | __decorate([
|
364 | core_3.Input(),
|
365 | __metadata('design:type', String)
|
366 | ], PaginationControlsComponent.prototype, "screenReaderCurrentLabel", void 0);
|
367 | __decorate([
|
368 | core_3.Output(),
|
369 | __metadata('design:type', core_3.EventEmitter)
|
370 | ], PaginationControlsComponent.prototype, "pageChange", void 0);
|
371 | PaginationControlsComponent = __decorate([
|
372 | core_3.Component({
|
373 | selector: 'pagination-controls',
|
374 | template: template_1.DEFAULT_TEMPLATE,
|
375 | styles: [template_1.DEFAULT_STYLES],
|
376 | changeDetection: core_3.ChangeDetectionStrategy.OnPush,
|
377 | encapsulation: core_3.ViewEncapsulation.None
|
378 | }),
|
379 | __metadata('design:paramtypes', [])
|
380 | ], PaginationControlsComponent);
|
381 | return PaginationControlsComponent;
|
382 | }());
|
383 | exports_5("PaginationControlsComponent", PaginationControlsComponent);
|
384 | }
|
385 | }
|
386 | });
|
387 | System.register("pagination-controls.directive", ['@angular/core', "pagination.service"], function(exports_6, context_6) {
|
388 | "use strict";
|
389 | var __moduleName = context_6 && context_6.id;
|
390 | var core_4, pagination_service_2;
|
391 | var PaginationControlsDirective;
|
392 | return {
|
393 | setters:[
|
394 | function (core_4_1) {
|
395 | core_4 = core_4_1;
|
396 | },
|
397 | function (pagination_service_2_1) {
|
398 | pagination_service_2 = pagination_service_2_1;
|
399 | }],
|
400 | execute: function() {
|
401 | |
402 |
|
403 |
|
404 |
|
405 |
|
406 | PaginationControlsDirective = (function () {
|
407 | function PaginationControlsDirective(service, changeDetectorRef) {
|
408 | var _this = this;
|
409 | this.service = service;
|
410 | this.changeDetectorRef = changeDetectorRef;
|
411 | this.maxSize = 7;
|
412 | this.pageChange = new core_4.EventEmitter();
|
413 | this.pages = [];
|
414 | this.changeSub = this.service.change
|
415 | .subscribe(function (id) {
|
416 | if (_this.id === id) {
|
417 | _this.updatePageLinks();
|
418 | _this.changeDetectorRef.markForCheck();
|
419 | _this.changeDetectorRef.detectChanges();
|
420 | }
|
421 | });
|
422 | }
|
423 | PaginationControlsDirective.prototype.ngOnInit = function () {
|
424 | if (this.id === undefined) {
|
425 | this.id = this.service.defaultId();
|
426 | }
|
427 | this.updatePageLinks();
|
428 | };
|
429 | PaginationControlsDirective.prototype.ngOnChanges = function (changes) {
|
430 | this.updatePageLinks();
|
431 | };
|
432 | PaginationControlsDirective.prototype.ngOnDestroy = function () {
|
433 | this.changeSub.unsubscribe();
|
434 | };
|
435 | |
436 |
|
437 |
|
438 | PaginationControlsDirective.prototype.previous = function () {
|
439 | this.checkValidId();
|
440 | this.setCurrent(this.getCurrent() - 1);
|
441 | };
|
442 | |
443 |
|
444 |
|
445 | PaginationControlsDirective.prototype.next = function () {
|
446 | this.checkValidId();
|
447 | this.setCurrent(this.getCurrent() + 1);
|
448 | };
|
449 | |
450 |
|
451 |
|
452 | PaginationControlsDirective.prototype.isFirstPage = function () {
|
453 | return this.getCurrent() === 1;
|
454 | };
|
455 | |
456 |
|
457 |
|
458 | PaginationControlsDirective.prototype.isLastPage = function () {
|
459 | return this.getLastPage() === this.getCurrent();
|
460 | };
|
461 | |
462 |
|
463 |
|
464 | PaginationControlsDirective.prototype.setCurrent = function (page) {
|
465 | this.pageChange.emit(page);
|
466 | };
|
467 | |
468 |
|
469 |
|
470 | PaginationControlsDirective.prototype.getCurrent = function () {
|
471 | return this.service.getCurrentPage(this.id);
|
472 | };
|
473 | |
474 |
|
475 |
|
476 | PaginationControlsDirective.prototype.getLastPage = function () {
|
477 | var inst = this.service.getInstance(this.id);
|
478 | if (inst.totalItems < 1) {
|
479 |
|
480 |
|
481 | return 1;
|
482 | }
|
483 | return Math.ceil(inst.totalItems / inst.itemsPerPage);
|
484 | };
|
485 | PaginationControlsDirective.prototype.checkValidId = function () {
|
486 | if (!this.service.getInstance(this.id).id) {
|
487 | console.warn("PaginationControlsDirective: the specified id \"" + this.id + "\" does not match any registered PaginationInstance");
|
488 | }
|
489 | };
|
490 | |
491 |
|
492 |
|
493 |
|
494 |
|
495 | PaginationControlsDirective.prototype.updatePageLinks = function () {
|
496 | var _this = this;
|
497 | var inst = this.service.getInstance(this.id);
|
498 | var correctedCurrentPage = this.outOfBoundCorrection(inst);
|
499 | if (correctedCurrentPage !== inst.currentPage) {
|
500 | setTimeout(function () {
|
501 | _this.setCurrent(correctedCurrentPage);
|
502 | _this.pages = _this.createPageArray(inst.currentPage, inst.itemsPerPage, inst.totalItems, _this.maxSize);
|
503 | });
|
504 | }
|
505 | else {
|
506 | this.pages = this.createPageArray(inst.currentPage, inst.itemsPerPage, inst.totalItems, this.maxSize);
|
507 | }
|
508 | };
|
509 | |
510 |
|
511 |
|
512 |
|
513 | PaginationControlsDirective.prototype.outOfBoundCorrection = function (instance) {
|
514 | var totalPages = Math.ceil(instance.totalItems / instance.itemsPerPage);
|
515 | if (totalPages < instance.currentPage && 0 < totalPages) {
|
516 | return totalPages;
|
517 | }
|
518 | else if (instance.currentPage < 1) {
|
519 | return 1;
|
520 | }
|
521 | return instance.currentPage;
|
522 | };
|
523 | |
524 |
|
525 |
|
526 | PaginationControlsDirective.prototype.createPageArray = function (currentPage, itemsPerPage, totalItems, paginationRange) {
|
527 |
|
528 | paginationRange = +paginationRange;
|
529 | var pages = [];
|
530 | var totalPages = Math.ceil(totalItems / itemsPerPage);
|
531 | var halfWay = Math.ceil(paginationRange / 2);
|
532 | var isStart = currentPage <= halfWay;
|
533 | var isEnd = totalPages - halfWay < currentPage;
|
534 | var isMiddle = !isStart && !isEnd;
|
535 | var ellipsesNeeded = paginationRange < totalPages;
|
536 | var i = 1;
|
537 | while (i <= totalPages && i <= paginationRange) {
|
538 | var label = void 0;
|
539 | var pageNumber = this.calculatePageNumber(i, currentPage, paginationRange, totalPages);
|
540 | var openingEllipsesNeeded = (i === 2 && (isMiddle || isEnd));
|
541 | var closingEllipsesNeeded = (i === paginationRange - 1 && (isMiddle || isStart));
|
542 | if (ellipsesNeeded && (openingEllipsesNeeded || closingEllipsesNeeded)) {
|
543 | label = '...';
|
544 | }
|
545 | else {
|
546 | label = pageNumber;
|
547 | }
|
548 | pages.push({
|
549 | label: label,
|
550 | value: pageNumber
|
551 | });
|
552 | i++;
|
553 | }
|
554 | return pages;
|
555 | };
|
556 | |
557 |
|
558 |
|
559 |
|
560 | PaginationControlsDirective.prototype.calculatePageNumber = function (i, currentPage, paginationRange, totalPages) {
|
561 | var halfWay = Math.ceil(paginationRange / 2);
|
562 | if (i === paginationRange) {
|
563 | return totalPages;
|
564 | }
|
565 | else if (i === 1) {
|
566 | return i;
|
567 | }
|
568 | else if (paginationRange < totalPages) {
|
569 | if (totalPages - halfWay < currentPage) {
|
570 | return totalPages - paginationRange + i;
|
571 | }
|
572 | else if (halfWay < currentPage) {
|
573 | return currentPage - halfWay + i;
|
574 | }
|
575 | else {
|
576 | return i;
|
577 | }
|
578 | }
|
579 | else {
|
580 | return i;
|
581 | }
|
582 | };
|
583 | __decorate([
|
584 | core_4.Input(),
|
585 | __metadata('design:type', String)
|
586 | ], PaginationControlsDirective.prototype, "id", void 0);
|
587 | __decorate([
|
588 | core_4.Input(),
|
589 | __metadata('design:type', Number)
|
590 | ], PaginationControlsDirective.prototype, "maxSize", void 0);
|
591 | __decorate([
|
592 | core_4.Output(),
|
593 | __metadata('design:type', core_4.EventEmitter)
|
594 | ], PaginationControlsDirective.prototype, "pageChange", void 0);
|
595 | PaginationControlsDirective = __decorate([
|
596 | core_4.Directive({
|
597 | selector: 'pagination-template,[pagination-template]',
|
598 | exportAs: 'paginationApi'
|
599 | }),
|
600 | __metadata('design:paramtypes', [pagination_service_2.PaginationService, core_4.ChangeDetectorRef])
|
601 | ], PaginationControlsDirective);
|
602 | return PaginationControlsDirective;
|
603 | }());
|
604 | exports_6("PaginationControlsDirective", PaginationControlsDirective);
|
605 | }
|
606 | }
|
607 | });
|
608 | System.register("ng2-pagination", ['@angular/core', '@angular/common', "paginate.pipe", "pagination.service", "pagination-controls.component", "pagination-controls.directive"], function(exports_7, context_7) {
|
609 | "use strict";
|
610 | var __moduleName = context_7 && context_7.id;
|
611 | var core_5, common_1, paginate_pipe_1, pagination_service_3, pagination_controls_component_1, pagination_controls_directive_1;
|
612 | var Ng2PaginationModule;
|
613 | return {
|
614 | setters:[
|
615 | function (core_5_1) {
|
616 | core_5 = core_5_1;
|
617 | },
|
618 | function (common_1_1) {
|
619 | common_1 = common_1_1;
|
620 | },
|
621 | function (paginate_pipe_1_1) {
|
622 | paginate_pipe_1 = paginate_pipe_1_1;
|
623 | exports_7({
|
624 | "PaginatePipe": paginate_pipe_1_1["PaginatePipe"]
|
625 | });
|
626 | },
|
627 | function (pagination_service_3_1) {
|
628 | pagination_service_3 = pagination_service_3_1;
|
629 | exports_7({
|
630 | "PaginationService": pagination_service_3_1["PaginationService"]
|
631 | });
|
632 | },
|
633 | function (pagination_controls_component_1_1) {
|
634 | pagination_controls_component_1 = pagination_controls_component_1_1;
|
635 | exports_7({
|
636 | "PaginationControlsComponent": pagination_controls_component_1_1["PaginationControlsComponent"]
|
637 | });
|
638 | },
|
639 | function (pagination_controls_directive_1_1) {
|
640 | pagination_controls_directive_1 = pagination_controls_directive_1_1;
|
641 | exports_7({
|
642 | "PaginationControlsDirective": pagination_controls_directive_1_1["PaginationControlsDirective"]
|
643 | });
|
644 | }],
|
645 | execute: function() {
|
646 | Ng2PaginationModule = (function () {
|
647 | function Ng2PaginationModule() {
|
648 | }
|
649 | Ng2PaginationModule = __decorate([
|
650 | core_5.NgModule({
|
651 | imports: [common_1.CommonModule],
|
652 | declarations: [
|
653 | paginate_pipe_1.PaginatePipe,
|
654 | pagination_controls_component_1.PaginationControlsComponent,
|
655 | pagination_controls_directive_1.PaginationControlsDirective
|
656 | ],
|
657 | providers: [pagination_service_3.PaginationService],
|
658 | exports: [paginate_pipe_1.PaginatePipe, pagination_controls_component_1.PaginationControlsComponent, pagination_controls_directive_1.PaginationControlsDirective]
|
659 | }),
|
660 | __metadata('design:paramtypes', [])
|
661 | ], Ng2PaginationModule);
|
662 | return Ng2PaginationModule;
|
663 | }());
|
664 | exports_7("Ng2PaginationModule", Ng2PaginationModule);
|
665 | }
|
666 | }
|
667 | });
|