diff options
| author | Appleman1234 <applemansigloo@gmail.com> | 2016-12-15 18:25:42 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-12-15 18:25:42 +0900 |
| commit | cae526e65a20f3da2d8884c4d8e8978c54120000 (patch) | |
| tree | 2954153dd49f616f5018490058ff4bfbd17300d3 /js/auto-scroll.js | |
| parent | b58fab98147a92c8e6d22f15d23684508b6bb811 (diff) | |
| parent | 5feae402cb55d49963bfd2c6f5a33d10690ecbc1 (diff) | |
Merge pull request #79 from lainchan/clean_prod_vichan_update
Merge vichan changes from upstream and changes directly applied to the site.
Diffstat (limited to 'js/auto-scroll.js')
| -rw-r--r-- | js/auto-scroll.js | 27 |
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)); + } + }); + } +}); |
