Add in Zixaphirs infinite scrolling
This commit is contained in:
parent
3aea514ca1
commit
a418ba15e1
@ -2249,6 +2249,7 @@
|
|||||||
this.searchInput = $('#index-search', this.navLinks);
|
this.searchInput = $('#index-search', this.navLinks);
|
||||||
this.currentPage = this.getCurrentPage();
|
this.currentPage = this.getCurrentPage();
|
||||||
$.on(window, 'popstate', this.cb.popstate);
|
$.on(window, 'popstate', this.cb.popstate);
|
||||||
|
$.on(d, 'scroll', Index.scroll);
|
||||||
$.on(this.pagelist, 'click', this.cb.pageNav);
|
$.on(this.pagelist, 'click', this.cb.pageNav);
|
||||||
$.on(this.searchInput, 'input', this.onSearchInput);
|
$.on(this.searchInput, 'input', this.onSearchInput);
|
||||||
$.on($('#index-search-clear', this.navLinks), 'click', this.clearSearch);
|
$.on($('#index-search-clear', this.navLinks), 'click', this.clearSearch);
|
||||||
@ -2273,6 +2274,39 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
scroll: $.debounce(100, function() {
|
||||||
|
var nodes, nodesPerPage, pageNum;
|
||||||
|
if (Conf['Index Mode'] !== 'paged' || ((d.body.scrollTop || doc.scrollTop) <= doc.scrollHeight - (300 + window.innerHeight))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pageNum = Index.getCurrentPage() + 1;
|
||||||
|
if (pageNum >= Index.pagesNum) {
|
||||||
|
return Index.endNotice();
|
||||||
|
}
|
||||||
|
nodesPerPage = Index.threadsNumPerPage * 2;
|
||||||
|
history.pushState(null, '', "/" + g.BOARD + "/" + pageNum);
|
||||||
|
nodes = Index.sortedNodes.slice(nodesPerPage * pageNum, nodesPerPage * (pageNum + 1));
|
||||||
|
if (Conf['Show Replies']) {
|
||||||
|
Index.buildReplies(nodes);
|
||||||
|
}
|
||||||
|
$.add(Index.root, nodes);
|
||||||
|
return Index.setPage();
|
||||||
|
}),
|
||||||
|
endNotice: (function() {
|
||||||
|
var notify, reset;
|
||||||
|
notify = false;
|
||||||
|
reset = function() {
|
||||||
|
return notify = false;
|
||||||
|
};
|
||||||
|
return function() {
|
||||||
|
if (notify) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
notify = true;
|
||||||
|
new Notice('info', "Last page reached.", 2);
|
||||||
|
return setTimeout(reset, 3 * $.SECOND);
|
||||||
|
};
|
||||||
|
})(),
|
||||||
cb: {
|
cb: {
|
||||||
mode: function() {
|
mode: function() {
|
||||||
Index.togglePagelist();
|
Index.togglePagelist();
|
||||||
|
|||||||
@ -2259,6 +2259,7 @@
|
|||||||
this.searchInput = $('#index-search', this.navLinks);
|
this.searchInput = $('#index-search', this.navLinks);
|
||||||
this.currentPage = this.getCurrentPage();
|
this.currentPage = this.getCurrentPage();
|
||||||
$.on(window, 'popstate', this.cb.popstate);
|
$.on(window, 'popstate', this.cb.popstate);
|
||||||
|
$.on(d, 'scroll', Index.scroll);
|
||||||
$.on(this.pagelist, 'click', this.cb.pageNav);
|
$.on(this.pagelist, 'click', this.cb.pageNav);
|
||||||
$.on(this.searchInput, 'input', this.onSearchInput);
|
$.on(this.searchInput, 'input', this.onSearchInput);
|
||||||
$.on($('#index-search-clear', this.navLinks), 'click', this.clearSearch);
|
$.on($('#index-search-clear', this.navLinks), 'click', this.clearSearch);
|
||||||
@ -2283,6 +2284,39 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
scroll: $.debounce(100, function() {
|
||||||
|
var nodes, nodesPerPage, pageNum;
|
||||||
|
if (Conf['Index Mode'] !== 'paged' || ((d.body.scrollTop || doc.scrollTop) <= doc.scrollHeight - (300 + window.innerHeight))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pageNum = Index.getCurrentPage() + 1;
|
||||||
|
if (pageNum >= Index.pagesNum) {
|
||||||
|
return Index.endNotice();
|
||||||
|
}
|
||||||
|
nodesPerPage = Index.threadsNumPerPage * 2;
|
||||||
|
history.pushState(null, '', "/" + g.BOARD + "/" + pageNum);
|
||||||
|
nodes = Index.sortedNodes.slice(nodesPerPage * pageNum, nodesPerPage * (pageNum + 1));
|
||||||
|
if (Conf['Show Replies']) {
|
||||||
|
Index.buildReplies(nodes);
|
||||||
|
}
|
||||||
|
$.add(Index.root, nodes);
|
||||||
|
return Index.setPage();
|
||||||
|
}),
|
||||||
|
endNotice: (function() {
|
||||||
|
var notify, reset;
|
||||||
|
notify = false;
|
||||||
|
reset = function() {
|
||||||
|
return notify = false;
|
||||||
|
};
|
||||||
|
return function() {
|
||||||
|
if (notify) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
notify = true;
|
||||||
|
new Notice('info', "Last page reached.", 2);
|
||||||
|
return setTimeout(reset, 3 * $.SECOND);
|
||||||
|
};
|
||||||
|
})(),
|
||||||
cb: {
|
cb: {
|
||||||
mode: function() {
|
mode: function() {
|
||||||
Index.togglePagelist();
|
Index.togglePagelist();
|
||||||
|
|||||||
@ -79,6 +79,7 @@ Index =
|
|||||||
@searchInput = $ '#index-search', @navLinks
|
@searchInput = $ '#index-search', @navLinks
|
||||||
@currentPage = @getCurrentPage()
|
@currentPage = @getCurrentPage()
|
||||||
$.on window, 'popstate', @cb.popstate
|
$.on window, 'popstate', @cb.popstate
|
||||||
|
$.on d, 'scroll', Index.scroll
|
||||||
$.on @pagelist, 'click', @cb.pageNav
|
$.on @pagelist, 'click', @cb.pageNav
|
||||||
$.on @searchInput, 'input', @onSearchInput
|
$.on @searchInput, 'input', @onSearchInput
|
||||||
$.on $('#index-search-clear', @navLinks), 'click', @clearSearch
|
$.on $('#index-search-clear', @navLinks), 'click', @clearSearch
|
||||||
@ -101,6 +102,26 @@ Index =
|
|||||||
$.asap (-> $('.pagelist') or d.readyState isnt 'loading'), ->
|
$.asap (-> $('.pagelist') or d.readyState isnt 'loading'), ->
|
||||||
$.replace $('.pagelist'), Index.pagelist
|
$.replace $('.pagelist'), Index.pagelist
|
||||||
|
|
||||||
|
scroll: $.debounce 100, ->
|
||||||
|
return if Conf['Index Mode'] isnt 'paged' or ((d.body.scrollTop or doc.scrollTop) <= doc.scrollHeight - (300 + window.innerHeight))
|
||||||
|
pageNum = Index.getCurrentPage() + 1
|
||||||
|
return Index.endNotice() if pageNum >= Index.pagesNum
|
||||||
|
nodesPerPage = Index.threadsNumPerPage * 2
|
||||||
|
history.pushState null, '', "/#{g.BOARD}/#{pageNum}"
|
||||||
|
nodes = Index.sortedNodes[nodesPerPage * pageNum ... nodesPerPage * (pageNum + 1)]
|
||||||
|
Index.buildReplies nodes if Conf['Show Replies']
|
||||||
|
$.add Index.root, nodes
|
||||||
|
Index.setPage()
|
||||||
|
|
||||||
|
endNotice: do ->
|
||||||
|
notify = false
|
||||||
|
reset = -> notify = false
|
||||||
|
return ->
|
||||||
|
return if notify
|
||||||
|
notify = true
|
||||||
|
new Notice 'info', "Last page reached.", 2
|
||||||
|
setTimeout reset, 3 * $.SECOND
|
||||||
|
|
||||||
cb:
|
cb:
|
||||||
mode: ->
|
mode: ->
|
||||||
Index.togglePagelist()
|
Index.togglePagelist()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user