Skip to content

Node.js based forum software built for the modern web

closes #2271

barisusakli2c2586b578d5
diff --git a/public/src/client/infinitescroll.js b/public/src/client/infinitescroll.js
index e600d16fbe..ba3385d92f 100644
--- a/public/src/client/infinitescroll.js
+++ b/public/src/client/infinitescroll.js
@@ -14,10 +14,6 @@ define('forum/infinitescroll', function() {
callback = cb;
topOffset = _topOffest || 0;
$(window).off('scroll', onScroll).on('scroll', onScroll);
-
- // if ($(document).height() === $(window).height()) {
- // callback(1);
- // }
};
function onScroll() {
diff --git a/public/src/client/topic/posts.js b/public/src/client/topic/posts.js
index 89e08ae9dd..1a9a71e7ca 100644
--- a/public/src/client/topic/posts.js
+++ b/public/src/client/topic/posts.js
@@ -26,7 +26,11 @@ define('forum/topic/posts', [
postcount.html(parseInt(postcount.html(), 10) + 1);
}
- createNewPosts(data);
+ createNewPosts(data, function(html) {
+ if (html) {
+ html.addClass('new');
+ }
+ });
};
function onNewPostPagination(data) {
@@ -48,7 +52,7 @@ define('forum/topic/posts', [
function createNewPosts(data, callback) {
callback = callback || function() {};
if(!data || (data.posts && !data.posts.length)) {
- return callback(false);
+ return callback();
}
function removeAlreadyAddedPosts() {
@@ -64,9 +68,9 @@ define('forum/topic/posts', [
var firstPostTimestamp = parseInt(data.posts[0].timestamp, 10);
var firstPostVotes = parseInt(data.posts[0].votes, 10);
var firstPostIndex = parseInt(data.posts[0].index, 10);
-
- var firstReply = $('#post-container .post-row[data-index!="0"]').first();
- var lastReply = $('#post-container .post-row[data-index!="0"]').last();
+ var replies = $('#post-container .post-row[data-index!="0"]:not(.new)');
+ var firstReply = replies.first();
+ var lastReply = replies.last();
if (config.topicPostSort === 'oldest_to_newest') {
if (firstPostTimestamp < parseInt(firstReply.attr('data-timestamp'), 10)) {
@@ -96,8 +100,8 @@ define('forum/topic/posts', [
}
removeAlreadyAddedPosts();
- if(!data.posts.length) {
- return callback(false);
+ if (!data.posts.length) {
+ return callback();
}
findInsertionPoint();
@@ -106,9 +110,9 @@ define('forum/topic/posts', [
data.viewcount = ajaxify.variables.get('viewcount');
infinitescroll.parseAndTranslate('topic', 'posts', data, function(html) {
- if(after) {
+ if (after) {
html.insertAfter(after);
- } else if(before) {
+ } else if (before) {
// Save document height and position for future reference (about 5 lines down)
var height = $(document).height(),
scrollTop = $(document).scrollTop(),
@@ -135,7 +139,7 @@ define('forum/topic/posts', [
$(window).trigger('action:posts.loaded', {posts: data.posts});
onNewPostsLoaded(html, pids);
- callback(true);
+ callback(html);
});
}
@@ -180,7 +184,7 @@ define('forum/topic/posts', [
var reverse = config.topicPostSort === 'newest_to_oldest' || config.topicPostSort === 'most_votes';
- infinitescroll.calculateAfter(direction, '#post-container .post-row[data-index!="0"]', config.postsPerPage, reverse, function(after, offset, el) {
+ infinitescroll.calculateAfter(direction, '#post-container .post-row[data-index!="0"]:not(.new)', config.postsPerPage, reverse, function(after, offset, el) {
loadPostsAfter(after);
});
};
@@ -204,9 +208,7 @@ define('forum/topic/posts', [
indicatorEl.fadeOut();
if (data && data.posts && data.posts.length) {
- createNewPosts(data, function(postsCreated) {
- done();
- });
+ createNewPosts(data, done);
} else {
if (app.user.uid) {
socket.emit('topics.markAsRead', [tid]);