-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexm-paging.html
More file actions
170 lines (147 loc) · 5.04 KB
/
exm-paging.html
File metadata and controls
170 lines (147 loc) · 5.04 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../paper-icon-button/paper-icon-button.html">
<link rel="import" href="../paper-dropdown-menu/paper-dropdown-menu.html">
<link rel="import" href="../paper-menu/paper-menu.html">
<link rel="import" href="../paper-item/paper-item.html">
<link rel="import" href="../paper-styles/typography.html">
<link rel="import" href="exm-icons.html">
<!--
`exm-paging` is the paging controll element that can be positioned at the footer of the table.
```html
<table is="exm-datatable">
<tbody is="exm-tbody" items='[[items]]'>
...
</tbody>
</table>
<exm-paging total-items="[[totalItems]]" page-index="{{pageIndex}}" page-size="{{pageSize}}"></exm-paging>
```
### Styling
The following custom properties and mixins are also available for styling:
Custom property | Description | Default
----------------|-------------|----------
`--exm-paging-background-color` | Background color | `none`
`--exm-paging-text-color` | Text color | `87% black`
`--exm-paging-border-top-divider-color` | Divider color of the top border | `#DBDBDB`
`--exm-paging` | Mixin applied to host element | `{}`
`--exm-paging-icon-color` | Text color of table| `54% black`
`--exm-paging-icon-disabled-color` | Mixin applied to the datatable | `36% black`
`--exm-paging-page-information` | Mixin applied to page information container | `{}`
@element exm-paging
@demo demo/index.html
-->
<dom-module id="exm-paging">
<style>
:host {
display: block;
@apply(--paper-font-common-base);
background: var(--exm-paging-background-color, none);
color: var(--exm-paging-text-color, rgba(0,0,0,.87));
font-size: 12px;
font-weight: 500;
height:56px;
padding:0px 6px;
border-top: 1px solid var(--exm-paging-border-top-divider-color, --divider-color);
@apply(--layout-horizontal);
@apply(--layout-end-justified);
@apply(--layout-center);
@apply(--exm-paging);
}
paper-dropdown-menu {
--paper-input-container-input: {
font-size: 12px;
font-weight: 500;
};
--paper-dropdown-menu: {
text-align: right;
width: 68px;
};
--paper-dropdown-menu-icon: {
color: var(--exm-paging-icon-color, rgba(0,0,0,.54));
};
--paper-icon-button: {
color: var(--exm-paging-icon-color, rgba(0,0,0,.54));
};
--paper-icon-button-disabled: {
color: var(--exm-paging-icon-disabled-color, rgba(0,0,0,.36));
};
--paper-input-container-underline-focus: { display: none; };
--paper-input-container-underline-disabled: { display: none; };
--paper-input-container-underline: { display: none; };
}
paper-icon-button {
margin: 0 4px;
}
.page-information {
margin: 0 20px 0 32px;
@apply(--exm-paging-page-information);
}
</style>
<template>
<span>Rows per page:</span>
<paper-dropdown-menu no-label-float>
<paper-menu class="dropdown-content" selected="{{pageSize}}" attr-for-selected="value">
<paper-item value="5">5</paper-item>
<paper-item value="10">10</paper-item>
<paper-item value="25">25</paper-item>
<paper-item value="50">50</paper-item>
<paper-item value="100">100</paper-item>
</paper-menu>
</paper-dropdown-menu>
<span class="page-information">
[[_pageInfoStart(pageIndex, pageSize)]]
-
[[_pageInfoEnd(pageIndex,pageSize,totalItems)]] of [[totalItems]]
</span>
<paper-icon-button icon="exm-icons:chevron-left" on-tap="previousPage" disabled="[[_isFirstPage(pageIndex)]]"></paper-icon-button>
<paper-icon-button icon="exm-icons:chevron-right" on-tap="nextPage" disabled="[[_isLastPage(pageIndex, pageSize, totalItems)]]"></paper-icon-button>
</template>
<script>
Polymer({
is: 'exm-paging',
properties: {
/**
* Total items
*/
totalItems: {
type: Number,
value: 0
},
/**
* This property can be used to change the current visible page
*/
pageIndex: {
type: Number,
notify: true,
value: 0
},
/**
* Set the page size of the table. Valid options are 5/10/25/50/100
*/
pageSize: {
type: Number,
notify: true,
value: 10
}
},
_pageInfoStart: function(pageIndex, pageSize) {
return pageIndex * pageSize;
},
_pageInfoEnd: function(pageIndex, pageSize, totalItems) {
var end = (pageIndex + 1) * pageSize;
return end < totalItems ? end : totalItems;
},
_isFirstPage: function() {
return this.pageIndex < 1;
},
_isLastPage: function() {
return ((this.pageIndex + 1) * this.pageSize) > this.totalItems;
},
nextPage: function() {
this.pageIndex++;
},
previousPage: function() {
this.pageIndex--;
}
});
</script>
</dom-module>