mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 14:35:47 +01:00
added postcount to topics return; started scrollspy behaviour for "postid / postcount" in topics.
This commit is contained in:
@@ -605,39 +605,53 @@
|
||||
|
||||
|
||||
|
||||
var postAuthorImage, postAuthorInfo;
|
||||
var postAuthorImage, postAuthorInfo, pagination;
|
||||
var postcount = templates.get('postcount');
|
||||
|
||||
|
||||
function updateHeader() {
|
||||
jQuery('.post-author-info').css('bottom', '0px');
|
||||
postAuthorImage = postAuthorImage || document.getElementById('post-author-image');
|
||||
postAuthorInfo = postAuthorInfo || document.getElementById('post-author-info');
|
||||
pagination = pagination || document.getElementById('pagination');
|
||||
|
||||
var scrollTop = jQuery(window).scrollTop();
|
||||
var scrollBottom = scrollTop + jQuery(window).height();
|
||||
var scrollTop = jQuery(window).scrollTop();
|
||||
var scrollBottom = scrollTop + jQuery(window).height();
|
||||
|
||||
if (scrollTop < 50) {
|
||||
postAuthorImage.src = (jQuery('.main-avatar img').attr('src'));
|
||||
postAuthorInfo.innerHTML = 'Posted by ' + jQuery('.main-post').attr('data-username') + ', ' + jQuery('.main-post').find('.relativeTimeAgo').html();
|
||||
return;
|
||||
}
|
||||
|
||||
jQuery('.sub-posts').each(function() {
|
||||
var el = jQuery(this);
|
||||
var elTop = el.offset().top;
|
||||
var height = Math.floor(el.height());
|
||||
var elBottom = elTop + (height < 300 ? height : 300);
|
||||
|
||||
var inView = ((elBottom >= scrollTop) && (elTop <= scrollBottom)
|
||||
&& (elBottom <= scrollBottom) && (elTop >= scrollTop) );
|
||||
if (scrollTop < 50) {
|
||||
postAuthorImage.src = (jQuery('.main-avatar img').attr('src'));
|
||||
postAuthorInfo.innerHTML = 'Posted by ' + jQuery('.main-post').attr('data-username') + ', ' + jQuery('.main-post').find('.relativeTimeAgo').html();
|
||||
pagination.innerHTML = '0 / ' + postcount;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (inView) {
|
||||
var count = 0;
|
||||
|
||||
postAuthorImage.src = (jQuery(this).find('.profile-image-block img').attr('src'));
|
||||
postAuthorInfo.innerHTML = 'Posted by ' + jQuery(this).attr('data-username') + ', ' + jQuery(this).find('.relativeTimeAgo').html();
|
||||
jQuery('.sub-posts').each(function() {
|
||||
count++;
|
||||
this.postnumber = count;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
var el = jQuery(this);
|
||||
var elTop = el.offset().top;
|
||||
var height = Math.floor(el.height());
|
||||
var elBottom = elTop + (height < 300 ? height : 300);
|
||||
|
||||
var inView = ((elBottom >= scrollTop) && (elTop <= scrollBottom)
|
||||
&& (elBottom <= scrollBottom) && (elTop >= scrollTop));
|
||||
|
||||
|
||||
if (inView) {
|
||||
pagination.innerHTML = this.postnumber + ' / ' + postcount;
|
||||
postAuthorImage.src = (jQuery(this).find('.profile-image-block img').attr('src'));
|
||||
postAuthorInfo.innerHTML = 'Posted by ' + jQuery(this).attr('data-username') + ', ' + jQuery(this).find('.relativeTimeAgo').html();
|
||||
}
|
||||
});
|
||||
|
||||
if (scrollTop >= jQuery(window).height()) {
|
||||
//pagination.innerHTML = postcount + ' / ' + postcount;
|
||||
}
|
||||
}
|
||||
|
||||
window.onscroll = updateHeader;
|
||||
|
||||
Reference in New Issue
Block a user