gitlabhq/app/assets/javascripts/pager.js

57 lines
1.1 KiB
JavaScript
Raw Normal View History

var Pager = {
limit:0,
offset:0,
2012-02-12 22:52:27 +01:00
disable:false,
init:
function(limit, preload) {
this.limit=limit;
if(preload) {
this.offset = 0;
this.getOld();
} else {
this.offset = limit;
}
this.initLoadMore();
},
getOld:
function() {
$('.loading').show();
$.ajax({
type: "GET",
url: location.href,
data: "limit=" + this.limit + "&offset=" + this.offset,
complete: function(){ $('.loading').hide()},
dataType: "script"});
},
append:
function(count, html) {
$(".content_list").append(html);
if(count > 0) {
this.offset += count;
2012-02-12 22:52:27 +01:00
} else {
this.disable = true;
}
},
initLoadMore:
function() {
2012-02-12 22:52:27 +01:00
$(document).endlessScroll({
bottomPixels: 400,
fireDelay: 1000,
fireOnce:true,
ceaseFire: function() {
return Pager.disable;
},
callback: function(i) {
$('.loading').show();
Pager.getOld();
}
2012-02-12 22:52:27 +01:00
});
}
}