summaryrefslogtreecommitdiff
path: root/js/infinite-scroll.js
diff options
context:
space:
mode:
authorBenjamin Southall <applemansigloo@gmail.com>2016-09-25 16:34:47 +0900
committerBenjamin Southall <applemansigloo@gmail.com>2016-09-25 16:34:47 +0900
commita3b9c4405c6d4cca2a70dbb400e3ba3f65e7ea04 (patch)
tree5a2ebdb801748586e3fde7c12cbeda169b2c3e31 /js/infinite-scroll.js
parent9436524a306c8e3d6d8a6ed195e2a3c56d5cde39 (diff)
parenta4b619ae5eaab5755dc215a496854dee8f7ce395 (diff)
Merged lainchan with vichan master at 25/9/2016 a4b619ae5eaab5755dc215a496854dee8f7ce395 @czaks czaks committed on GitHub 2 days ago
Diffstat (limited to 'js/infinite-scroll.js')
-rw-r--r--js/infinite-scroll.js89
1 files changed, 45 insertions, 44 deletions
diff --git a/js/infinite-scroll.js b/js/infinite-scroll.js
index e212f9d6..b3c5c7ae 100644
--- a/js/infinite-scroll.js
+++ b/js/infinite-scroll.js
@@ -21,7 +21,7 @@ var activate = function() {
if (document.location.hash != '#all') return false;
$(window).on("scroll", function() {
- scrolltest();
+ scrolltest();
});
scrolltest();
@@ -30,53 +30,54 @@ var activate = function() {
var scrolltest = function() {
if ($(window).scrollTop() + $(window).height() + 1000 > $(document).height() && !loading) {
- load_next_page();
+ load_next_page();
}
};
var load_next_page = function() {
- if (loading) return;
- loading = true;
-
- var this_page = $(".pages a.selected:last");
- var next_page = this_page.next();
-
- var href = next_page.prop("href");
- if (!href) return;
-
- var boardheader = $('<h2>'+_('Page')+' '+next_page.html()+'</h2>');
- var loading_ind = $('<h2>'+_('Loading...')+'</h2>').insertBefore('form[name="postcontrols"]>.delete:first');
-
- $.get(href, function(data) {
- var doc = $(data);
-
- loading_ind.remove();
- boardheader.insertBefore('form[name="postcontrols"]>.delete:first');
-
- var i = 0;
-
- doc.find('div[id*="thread_"]').each(function() {
- var checkout = $(this).attr('id').replace('thread_', '');
- var $this = this;
-
- if ($('div#thread_' + checkout).length == 0) {
- // Delay DOM insertion to lessen the lag.
- setTimeout(function() {
- $($this).insertBefore('form[name="postcontrols"]>.delete:first');
- $(document).trigger('new_post', $this);
- $($this).hide().slideDown();
- }, 500*i);
- i++;
- }
- });
- setTimeout(function() {
- loading = false;
- scrolltest();
- }, 500*(i+1));
-
- next_page.addClass('selected');
- });
-
+ if (loading) return;
+ loading = true;
+
+ var this_page = $(".pages a.selected:last");
+ var next_page = this_page.next();
+
+ var href = next_page.prop("href");
+ if (!href) return;
+
+ var boardheader = $('<h2>'+_('Page')+' '+next_page.html()+'</h2>');
+ var loading_ind = $('<h2>'+_('Loading...')+'</h2>').insertBefore('#post-moderation-fields');
+
+ $.get(href, function(data) {
+ var doc = $(data);
+
+ loading_ind.remove();
+ boardheader.insertBefore('#post-moderation-fields');
+
+ var i = 0;
+
+ doc.find('div[id*="thread_"]').each(function() {
+ var checkout = $(this).attr('id').replace('thread_', '');
+ var $this = this;
+
+ if ($('div#thread_' + checkout).length == 0) {
+ // Delay DOM insertion to lessen the lag.
+ setTimeout(function() {
+ $($this).insertBefore('#post-moderation-fields');
+ $(document).trigger('new_post', $this);
+ $($this).hide().slideDown();
+ }, 500*i);
+
+ i++;
+ }
+ });
+
+ setTimeout(function() {
+ loading = false;
+ scrolltest();
+ }, 500*(i+1));
+
+ next_page.addClass('selected');
+ });
};
var button = $("<a href='#all'>"+_("All")+" </a>").prependTo(".pages");