mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-12 00:45:47 +01:00
added postcount to topics return; started scrollspy behaviour for "postid / postcount" in topics.
This commit is contained in:
@@ -605,12 +605,15 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
var postAuthorImage, postAuthorInfo;
|
var postAuthorImage, postAuthorInfo, pagination;
|
||||||
|
var postcount = templates.get('postcount');
|
||||||
|
|
||||||
|
|
||||||
function updateHeader() {
|
function updateHeader() {
|
||||||
jQuery('.post-author-info').css('bottom', '0px');
|
jQuery('.post-author-info').css('bottom', '0px');
|
||||||
postAuthorImage = postAuthorImage || document.getElementById('post-author-image');
|
postAuthorImage = postAuthorImage || document.getElementById('post-author-image');
|
||||||
postAuthorInfo = postAuthorInfo || document.getElementById('post-author-info');
|
postAuthorInfo = postAuthorInfo || document.getElementById('post-author-info');
|
||||||
|
pagination = pagination || document.getElementById('pagination');
|
||||||
|
|
||||||
var scrollTop = jQuery(window).scrollTop();
|
var scrollTop = jQuery(window).scrollTop();
|
||||||
var scrollBottom = scrollTop + jQuery(window).height();
|
var scrollBottom = scrollTop + jQuery(window).height();
|
||||||
@@ -618,26 +621,37 @@
|
|||||||
if (scrollTop < 50) {
|
if (scrollTop < 50) {
|
||||||
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;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var count = 0;
|
||||||
|
|
||||||
jQuery('.sub-posts').each(function() {
|
jQuery('.sub-posts').each(function() {
|
||||||
|
count++;
|
||||||
|
this.postnumber = count;
|
||||||
|
|
||||||
|
|
||||||
var el = jQuery(this);
|
var el = jQuery(this);
|
||||||
var elTop = el.offset().top;
|
var elTop = el.offset().top;
|
||||||
var height = Math.floor(el.height());
|
var height = Math.floor(el.height());
|
||||||
var elBottom = elTop + (height < 300 ? height : 300);
|
var elBottom = elTop + (height < 300 ? height : 300);
|
||||||
|
|
||||||
var inView = ((elBottom >= scrollTop) && (elTop <= scrollBottom)
|
var inView = ((elBottom >= scrollTop) && (elTop <= scrollBottom)
|
||||||
&& (elBottom <= scrollBottom) && (elTop >= scrollTop) );
|
&& (elBottom <= scrollBottom) && (elTop >= scrollTop));
|
||||||
|
|
||||||
|
|
||||||
if (inView) {
|
if (inView) {
|
||||||
|
pagination.innerHTML = this.postnumber + ' / ' + postcount;
|
||||||
postAuthorImage.src = (jQuery(this).find('.profile-image-block img').attr('src'));
|
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();
|
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;
|
window.onscroll = updateHeader;
|
||||||
|
|||||||
@@ -42,7 +42,9 @@
|
|||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
</button>
|
</button>
|
||||||
<a class="navbar-brand" href="/">{title}</a>
|
<a class="navbar-brand" href="/">{title}<div id="pagination">
|
||||||
|
0 / 0
|
||||||
|
</div></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="navbar-collapse collapse">
|
<div class="navbar-collapse collapse">
|
||||||
@@ -56,7 +58,12 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="/users">Users</a>
|
<a href="/users">Users</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="/"></a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
<ul id="right-menu" class="nav navbar-nav pull-right">
|
<ul id="right-menu" class="nav navbar-nav pull-right">
|
||||||
<li class="notifications dropdown text-center">
|
<li class="notifications dropdown text-center">
|
||||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#" id="notif_dropdown"><i class="icon-circle-blank"></i></a>
|
<a class="dropdown-toggle" data-toggle="dropdown" href="#" id="notif_dropdown"><i class="icon-circle-blank"></i></a>
|
||||||
|
|||||||
@@ -234,6 +234,7 @@
|
|||||||
<input type="hidden" template-variable="deleted" value="{deleted}" />
|
<input type="hidden" template-variable="deleted" value="{deleted}" />
|
||||||
<input type="hidden" template-variable="pinned" value="{pinned}" />
|
<input type="hidden" template-variable="pinned" value="{pinned}" />
|
||||||
<input type="hidden" template-variable="topic_name" value="{topic_name}" />
|
<input type="hidden" template-variable="topic_name" value="{topic_name}" />
|
||||||
|
<input type="hidden" template-variable="postcount" value="{postcount}" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -379,6 +379,7 @@ marked.setOptions({
|
|||||||
'deleted': topicData.deleted,
|
'deleted': topicData.deleted,
|
||||||
'pinned': topicData.pinned,
|
'pinned': topicData.pinned,
|
||||||
'slug': topicData.slug,
|
'slug': topicData.slug,
|
||||||
|
'postcount' : topicData.postcount,
|
||||||
'topic_id': tid,
|
'topic_id': tid,
|
||||||
'expose_tools': privileges.editable ? 1 : 0,
|
'expose_tools': privileges.editable ? 1 : 0,
|
||||||
'posts': topicPosts,
|
'posts': topicPosts,
|
||||||
|
|||||||
Reference in New Issue
Block a user