From 129eb154b3c74289e0b21f6ff11a0034e232a59d Mon Sep 17 00:00:00 2001 From: 8chan Date: Thu, 26 Feb 2015 02:07:22 +0000 Subject: [PATCH] Merge --- js/auto-scroll.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 js/auto-scroll.js diff --git a/js/auto-scroll.js b/js/auto-scroll.js new file mode 100644 index 00000000..b8343f5e --- /dev/null +++ b/js/auto-scroll.js @@ -0,0 +1,27 @@ +$('document').ready(function () { + var autoScroll = localStorage['autoScroll'] ? true : false; + if (window.Options && Options.get_tab('general')){ + Options.extend_tab('general',''); + $('#autoScroll').find('input').prop('checked', autoScroll); + } + $('#autoScroll').on('change', function() { + if(autoScroll) { + delete localStorage.autoScroll; + } else { + localStorage.autoScroll = true; + } + autoScroll =! autoScroll + if(active_page == 'thread') + $('input.auto-scroll').prop('checked', autoScroll); + }); + if (active_page == 'thread') { + $('span[id="updater"]').children('a').after(' ( Scroll to New posts)'); + $('input.auto-scroll').prop('checked', autoScroll); + $(document).on('new_post', function (e, post) { + if ($('input.auto-scroll').prop('checked')) + { + scrollTo(0, $(post).offset().top - window.innerHeight + $(post).outerHeight(true)); + } + }); + } +});