fixed unworking infinite scroll
This commit is contained in:
parent
48bc4fc214
commit
ece9f50fb1
11 changed files with 180 additions and 66 deletions
|
@ -10,6 +10,7 @@
|
|||
//= require jquery.ui.selectmenu
|
||||
//= require jquery.tagify
|
||||
//= require jquery.cookie
|
||||
//= require jquery.endless-scroll
|
||||
//= require modernizr
|
||||
//= require chosen
|
||||
//= require raphael
|
||||
|
|
|
@ -2,6 +2,7 @@ var CommitsList = {
|
|||
ref:null,
|
||||
limit:0,
|
||||
offset:0,
|
||||
disable:false,
|
||||
|
||||
init:
|
||||
function(ref, limit) {
|
||||
|
@ -36,15 +37,21 @@ var CommitsList = {
|
|||
$("#commits_list").append(html);
|
||||
if(count > 0) {
|
||||
this.offset += count;
|
||||
this.initLoadMore();
|
||||
} else {
|
||||
this.disable = true;
|
||||
}
|
||||
},
|
||||
|
||||
initLoadMore:
|
||||
function() {
|
||||
$(window).bind('scroll', function(){
|
||||
if($(window).scrollTop() == $(document).height() - $(window).height()){
|
||||
$(window).unbind('scroll');
|
||||
$(document).endlessScroll({
|
||||
bottomPixels: 400,
|
||||
fireDelay: 1000,
|
||||
fireOnce:true,
|
||||
ceaseFire: function() {
|
||||
return CommitsList.disable;
|
||||
},
|
||||
callback: function(i) {
|
||||
CommitsList.getOld();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -3,6 +3,7 @@ var NoteList = {
|
|||
first_id: 0,
|
||||
last_id: 0,
|
||||
resource_name: null,
|
||||
disable:false,
|
||||
|
||||
init:
|
||||
function(resource_name, first_id, last_id) {
|
||||
|
@ -26,9 +27,12 @@ getOld:
|
|||
|
||||
append:
|
||||
function(id, html) {
|
||||
this.first_id = id;
|
||||
$("#notes-list").append(html);
|
||||
this.initLoadMore();
|
||||
if(this.first_id == id) {
|
||||
this.disable = true;
|
||||
} else {
|
||||
this.first_id = id;
|
||||
$("#notes-list").append(html);
|
||||
}
|
||||
},
|
||||
|
||||
replace:
|
||||
|
@ -76,11 +80,16 @@ initRefresh:
|
|||
|
||||
initLoadMore:
|
||||
function() {
|
||||
$(window).bind('scroll', function(){
|
||||
if($(window).scrollTop() == $(document).height() - $(window).height()){
|
||||
$(window).unbind('scroll');
|
||||
$(document).endlessScroll({
|
||||
bottomPixels: 400,
|
||||
fireDelay: 1000,
|
||||
fireOnce:true,
|
||||
ceaseFire: function() {
|
||||
return NoteList.disable;
|
||||
},
|
||||
callback: function(i) {
|
||||
NoteList.getOld();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
var Pager = {
|
||||
ref:null,
|
||||
limit:0,
|
||||
offset:0,
|
||||
disable:false,
|
||||
|
||||
init:
|
||||
function(ref, limit) {
|
||||
this.ref=ref;
|
||||
function(limit) {
|
||||
this.limit=limit;
|
||||
this.offset=limit;
|
||||
this.initLoadMore();
|
||||
|
@ -28,17 +27,24 @@ var Pager = {
|
|||
$(".content_list").append(html);
|
||||
if(count > 0) {
|
||||
this.offset += count;
|
||||
this.initLoadMore();
|
||||
} else {
|
||||
this.disable = true;
|
||||
}
|
||||
},
|
||||
|
||||
initLoadMore:
|
||||
function() {
|
||||
$(window).bind('scroll', function(){
|
||||
if($(window).scrollTop() == $(document).height() - $(window).height()){
|
||||
$(window).unbind('scroll');
|
||||
$(document).endlessScroll({
|
||||
bottomPixels: 400,
|
||||
fireDelay: 1000,
|
||||
fireOnce:true,
|
||||
ceaseFire: function() {
|
||||
return Pager.disable;
|
||||
},
|
||||
callback: function(i) {
|
||||
$('.loading').show();
|
||||
Pager.getOld();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
var ProjectsList = {
|
||||
limit:0,
|
||||
offset:0,
|
||||
|
||||
init:
|
||||
function(limit) {
|
||||
this.limit=limit;
|
||||
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) {
|
||||
$(".tile").append(html);
|
||||
if(count > 0) {
|
||||
this.offset += count;
|
||||
this.initLoadMore();
|
||||
}
|
||||
},
|
||||
|
||||
initLoadMore:
|
||||
function() {
|
||||
$(window).bind('scroll', function(){
|
||||
if($(window).scrollTop() == $(document).height() - $(window).height()){
|
||||
$(window).unbind('scroll');
|
||||
$('.loading').show();
|
||||
ProjectsList.getOld();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue