summaryrefslogtreecommitdiff
path: root/js/auto-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/auto-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/auto-scroll.js')
-rw-r--r--js/auto-scroll.js27
1 files changed, 27 insertions, 0 deletions
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','<label id=\'autoScroll\'><input type=\'checkbox\' />' + ' Scroll to new posts' + '</label>');
+ $('#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(' (<input class="auto-scroll" type="checkbox"></input> 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));
+ }
+ });
+ }
+});