-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpaginator.js
41 lines (34 loc) · 1.14 KB
/
paginator.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
window.PaginatorView = Backbone.View.extend({
el: '.paginator',
initialize: function () {
this.setPaginatorControls();
},
events: {
"click .paginator #moveright" : "nextPage",
"click .paginator #moveleft" : "prevPage"
},
setPaginatorControls: function()
{
this.resetControlls(this.collection.options.page_offset, this.collection.options.max_page_offset);
},
prevPage: function () {
this.setPaginatorControls();
this.collection.fetch( {
data: {
'page_offset' : --this.collection.options.page_offset
}
} );
},
nextPage: function () {
this.setPaginatorControls();
this.collection.fetch( {
data: {
'page_offset' : ++this.collection.options.page_offset
}
} );
},
resetControlls : function (page_offset, max_page_offset) {
$(this.el).find('#moveleft').css('visibility', (page_offset == 0)? 'visible':'hidden');
$(this.el).find('#moveright').css('visibility', (page_offset == max_page_offset)? 'hidden':'visible');
}
});