1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-28 17:31:00 +01:00
vichan/js/auto-scroll.js

28 lines
1.0 KiB
JavaScript
Raw Normal View History

2015-02-26 03:07:22 +01:00
$('document').ready(function () {
var autoScroll = localStorage['autoScroll'] ? true : false;
if (window.Options && Options.get_tab('general')){
2015-03-15 10:40:27 +01:00
$('#auto-update-fs').append('<label id=\'autoScroll\'><input type=\'checkbox\' />' + _('Scroll to new posts') + '</label>');
2015-02-26 03:07:22 +01:00
$('#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') {
2015-03-15 10:40:27 +01:00
$('span[id="updater"]').children('a').after(' (<input class="auto-scroll" type="checkbox"></input> '+_('Scroll to new posts')+')');
2015-02-26 03:07:22 +01:00
$('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));
}
});
}
});