-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathpaper-datatable-api-footer.js
69 lines (59 loc) · 1.38 KB
/
paper-datatable-api-footer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
class DtPaperDatatableApiFooter
extends Polymer.mixinBehaviors([Polymer.AppLocalizeBehavior], Polymer.Element) {
static get is() {
return 'paper-datatable-api-footer';
}
static get properties() {
return {
footerPosition: String,
size: {
type: Number,
notify: true,
},
page: {
type: Number,
notify: true,
},
availableSize: Array,
};
}
_computeCurrentSize(page, size) {
return page * size + 1;
}
_computeCurrentMaxSize(page, size, totalElements) {
const maxSize = size * (page + 1);
return maxSize > totalElements ? totalElements : maxSize;
}
_nextPage() {
if (this.page + 1 < this.totalPages) {
this.page = this.page + 1;
}
}
_prevPage() {
if (this.page > 0) {
this.page = this.page - 1;
}
}
_nextButtonEnabled(page, totalPages) {
return page + 1 < totalPages;
}
_prevButtonEnabled(page) {
return page > 0;
}
_newSizeIsSelected() {
const newSize = this.$$('paper-listbox').selected;
if (newSize) {
if (this.oldPage !== null && this.oldPage !== undefined) {
this.page = 0;
}
this.size = newSize;
}
}
_computePosition(position) {
if (position === 'right') {
return 'end-justified';
}
return '';
}
}
customElements.define(DtPaperDatatableApiFooter.is, DtPaperDatatableApiFooter);