-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.js
104 lines (96 loc) · 2.98 KB
/
test.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
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
/*global m, Pagination, window*/
'use strict';
(function (m, Pagination) {
var array = [],
i,
module = {};
for (i = 0; i < 100; i += 1) {
array.push({
id: i,
name: 'name ' + i
});
}
function list(data) {
return m('.ui.segment.sixteen.wide.column', [
m('ul.ui.bulleted.list', data.map(function (item) {
return m('li', {
key: item.id
}, item.name);
}))
]);
}
function table(data) {
return m('.ui.sixteen.wide.column', [
m('table.ui.table', [
m('tbody', data.map(function (item) {
return m('tr', {
key: item.id
}, [
m('td', item.id),
m('td', item.name)
]);
}))
])
]);
}
module.controller = function () {
module.vm.init();
this.pagination = m.component(Pagination, {
data: module.vm.data,
rowsperpage: module.vm.rowsperpage,
pagerender: list,
wrapperclass: 'column'
});
this.paginationCtrl = new this.pagination.controller();
};
module.vm = {};
module.vm.init = function () {
this.data = array;
this.rowsperpage = 10;
this.page = m.prop(3);
};
module.view = function (ctrl) {
return m('.ui.grid.page.one.column', [
m('h1', 'Pagination'),
m.component(Pagination, {
data: module.vm.data,
rowsperpage: module.vm.rowsperpage,
pagerender: list,
wrapperclass: 'column',
page: module.vm.page/*,
classes: {
leftIconClass: 'glyphicon glyphicon-arrow-left',
rightIconClass: 'glyphicon glyphicon-arrow-right'
}*/
}),
m.component(Pagination, {
data: module.vm.data,
rowsperpage: module.vm.rowsperpage,
pagerender: table,
wrapperclass: 'column',
classes: {
leftIconClass: 'left arrow icon',
rightIconClass: 'right arrow icon'
}
}),
m('.row', [
m('.column', [
m('br')
])
]),
ctrl.pagination.view(ctrl.paginationCtrl),
m('.row', [
m('.column', [
m('button.ui.button', {
onclick: function () {
module.vm.data.splice(30, 10);
ctrl.paginationCtrl.goToPage(4);
module.vm.page(4);
}
}, 'go to page 3')
])
])
]);
};
m.mount(window.document.body, module);
}(m, Pagination));