2012-02-08 00:00:49 +01:00
|
|
|
var Pager = {
|
|
|
|
limit:0,
|
|
|
|
offset:0,
|
2012-02-12 22:52:27 +01:00
|
|
|
disable:false,
|
2012-02-08 00:00:49 +01:00
|
|
|
|
|
|
|
init:
|
2013-01-07 13:36:01 +01:00
|
|
|
function(limit, preload) {
|
2012-02-08 00:00:49 +01:00
|
|
|
this.limit=limit;
|
2013-01-07 13:36:01 +01:00
|
|
|
|
|
|
|
if(preload) {
|
|
|
|
this.offset = 0;
|
|
|
|
this.getOld();
|
|
|
|
} else {
|
|
|
|
this.offset = limit;
|
|
|
|
}
|
|
|
|
|
2012-02-08 00:00:49 +01:00
|
|
|
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;
|
2012-02-08 00:00:49 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
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();
|
2012-02-08 00:00:49 +01:00
|
|
|
Pager.getOld();
|
|
|
|
}
|
2012-02-12 22:52:27 +01:00
|
|
|
});
|
2012-02-08 00:00:49 +01:00
|
|
|
}
|
|
|
|
}
|