pagination - scroll to top / bottom arrows

v1.18.x
psychobunny 12 years ago
parent f39932ece7
commit abd909d23b

@ -18,7 +18,7 @@
#pagination { .pagination-block {
position: absolute; position: absolute;
background: rgb(34, 34, 34); background: rgb(34, 34, 34);
right: 0px; right: 0px;

@ -33,7 +33,7 @@ var ajaxify = {};
app.enter_room('global'); app.enter_room('global');
pagination = pagination || document.getElementById('pagination'); pagination = pagination || document.getElementById('pagination');
if (pagination) pagination.style.display = 'none'; if (pagination) pagination.parentNode.style.display = 'none';
window.onscroll = null; window.onscroll = null;
// end // end

@ -374,6 +374,18 @@ var socket,
}); });
} }
app.scrollToTop = function() {
$('body,html').animate({
scrollTop: 0
});
};
app.scrollToBottom = function() {
$('body,html').animate({
scrollTop: $('html').height() - 100
});
}
app.scrollToPost = function(pid) { app.scrollToPost = function(pid) {
if(!pid) if(!pid)

@ -620,16 +620,16 @@
postAuthorInfo = postAuthorInfo || document.getElementById('post-author-info'); postAuthorInfo = postAuthorInfo || document.getElementById('post-author-info');
pagination = pagination || document.getElementById('pagination'); pagination = pagination || document.getElementById('pagination');
pagination.style.display = 'block'; pagination.parentNode.style.display = 'block';
var windowHeight = jQuery(window).height(); var windowHeight = jQuery(window).height();
var scrollTop = jQuery(window).scrollTop(); var scrollTop = jQuery(window).scrollTop();
var scrollBottom = scrollTop + windowHeight; var scrollBottom = scrollTop + windowHeight;
if (scrollTop < 50) { if (scrollTop < 50 && postcount > 1) {
postAuthorImage.src = (jQuery('.main-avatar img').attr('src')); postAuthorImage.src = (jQuery('.main-avatar img').attr('src'));
postAuthorInfo.innerHTML = 'Posted by ' + jQuery('.main-post').attr('data-username') + ', ' + jQuery('.main-post').find('.relativeTimeAgo').html(); postAuthorInfo.innerHTML = 'Posted by ' + jQuery('.main-post').attr('data-username') + ', ' + jQuery('.main-post').find('.relativeTimeAgo').html();
pagination.innerHTML = '0 / ' + postcount; pagination.innerHTML = '0 out of ' + postcount;
return; return;
} }
@ -657,9 +657,11 @@
} }
}); });
setTimeout(function() {
if(scrollTop + windowHeight == jQuery(document).height()) { if(scrollTop + windowHeight == jQuery(document).height()) {
pagination.innerHTML = postcount + ' / ' + postcount; pagination.innerHTML = postcount + ' / ' + postcount;
} }
}, 100);
} }
window.onscroll = updateHeader; window.onscroll = updateHeader;

@ -82,7 +82,11 @@
</li> </li>
</ul> </ul>
<div id="pagination"></div> <div class="pagination-block">
<i class="icon-upload pointer" onclick="app.scrollToTop()"></i>
<span id="pagination"></span>
<i class="icon-upload pointer icon-rotate-180" onclick="app.scrollToBottom()"></i>
</div>
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save