forked from BlogEngine/BlogEngine.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlistpager.js
More file actions
27 lines (27 loc) · 734 Bytes
/
listpager.js
File metadata and controls
27 lines (27 loc) · 734 Bytes
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
function listPagerInit(p) {
p.pagedItems = [];
p.currentPage = 0;
if (p.itemsPerPage === undefined) {
p.itemsPerPage = 5;
}
p.prevPage = function () {
if (p.currentPage > 0) {
p.currentPage--;
}
};
p.nextPage = function () {
if (p.currentPage < p.pagedItems.length - 1) {
p.currentPage++;
}
};
init = function () {
for (var i = 0; i < p.items.length; i++) {
if (i % p.itemsPerPage === 0) {
p.pagedItems[Math.floor(i / p.itemsPerPage)] = [p.items[i]];
} else {
p.pagedItems[Math.floor(i / p.itemsPerPage)].push(p.items[i]);
}
}
};
init();
}