|
|
@ -26,7 +26,11 @@ define('forum/topic/posts', [
|
|
|
|
postcount.html(parseInt(postcount.html(), 10) + 1);
|
|
|
|
postcount.html(parseInt(postcount.html(), 10) + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
createNewPosts(data);
|
|
|
|
createNewPosts(data, function(html) {
|
|
|
|
|
|
|
|
if (html) {
|
|
|
|
|
|
|
|
html.addClass('new');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function onNewPostPagination(data) {
|
|
|
|
function onNewPostPagination(data) {
|
|
|
@ -48,7 +52,7 @@ define('forum/topic/posts', [
|
|
|
|
function createNewPosts(data, callback) {
|
|
|
|
function createNewPosts(data, callback) {
|
|
|
|
callback = callback || function() {};
|
|
|
|
callback = callback || function() {};
|
|
|
|
if(!data || (data.posts && !data.posts.length)) {
|
|
|
|
if(!data || (data.posts && !data.posts.length)) {
|
|
|
|
return callback(false);
|
|
|
|
return callback();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function removeAlreadyAddedPosts() {
|
|
|
|
function removeAlreadyAddedPosts() {
|
|
|
@ -64,9 +68,9 @@ define('forum/topic/posts', [
|
|
|
|
var firstPostTimestamp = parseInt(data.posts[0].timestamp, 10);
|
|
|
|
var firstPostTimestamp = parseInt(data.posts[0].timestamp, 10);
|
|
|
|
var firstPostVotes = parseInt(data.posts[0].votes, 10);
|
|
|
|
var firstPostVotes = parseInt(data.posts[0].votes, 10);
|
|
|
|
var firstPostIndex = parseInt(data.posts[0].index, 10);
|
|
|
|
var firstPostIndex = parseInt(data.posts[0].index, 10);
|
|
|
|
|
|
|
|
var replies = $('#post-container .post-row[data-index!="0"]:not(.new)');
|
|
|
|
var firstReply = $('#post-container .post-row[data-index!="0"]').first();
|
|
|
|
var firstReply = replies.first();
|
|
|
|
var lastReply = $('#post-container .post-row[data-index!="0"]').last();
|
|
|
|
var lastReply = replies.last();
|
|
|
|
|
|
|
|
|
|
|
|
if (config.topicPostSort === 'oldest_to_newest') {
|
|
|
|
if (config.topicPostSort === 'oldest_to_newest') {
|
|
|
|
if (firstPostTimestamp < parseInt(firstReply.attr('data-timestamp'), 10)) {
|
|
|
|
if (firstPostTimestamp < parseInt(firstReply.attr('data-timestamp'), 10)) {
|
|
|
@ -96,8 +100,8 @@ define('forum/topic/posts', [
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
removeAlreadyAddedPosts();
|
|
|
|
removeAlreadyAddedPosts();
|
|
|
|
if(!data.posts.length) {
|
|
|
|
if (!data.posts.length) {
|
|
|
|
return callback(false);
|
|
|
|
return callback();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
findInsertionPoint();
|
|
|
|
findInsertionPoint();
|
|
|
@ -106,9 +110,9 @@ define('forum/topic/posts', [
|
|
|
|
data.viewcount = ajaxify.variables.get('viewcount');
|
|
|
|
data.viewcount = ajaxify.variables.get('viewcount');
|
|
|
|
|
|
|
|
|
|
|
|
infinitescroll.parseAndTranslate('topic', 'posts', data, function(html) {
|
|
|
|
infinitescroll.parseAndTranslate('topic', 'posts', data, function(html) {
|
|
|
|
if(after) {
|
|
|
|
if (after) {
|
|
|
|
html.insertAfter(after);
|
|
|
|
html.insertAfter(after);
|
|
|
|
} else if(before) {
|
|
|
|
} else if (before) {
|
|
|
|
// Save document height and position for future reference (about 5 lines down)
|
|
|
|
// Save document height and position for future reference (about 5 lines down)
|
|
|
|
var height = $(document).height(),
|
|
|
|
var height = $(document).height(),
|
|
|
|
scrollTop = $(document).scrollTop(),
|
|
|
|
scrollTop = $(document).scrollTop(),
|
|
|
@ -135,7 +139,7 @@ define('forum/topic/posts', [
|
|
|
|
|
|
|
|
|
|
|
|
$(window).trigger('action:posts.loaded', {posts: data.posts});
|
|
|
|
$(window).trigger('action:posts.loaded', {posts: data.posts});
|
|
|
|
onNewPostsLoaded(html, pids);
|
|
|
|
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';
|
|
|
|
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);
|
|
|
|
loadPostsAfter(after);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -204,9 +208,7 @@ define('forum/topic/posts', [
|
|
|
|
indicatorEl.fadeOut();
|
|
|
|
indicatorEl.fadeOut();
|
|
|
|
|
|
|
|
|
|
|
|
if (data && data.posts && data.posts.length) {
|
|
|
|
if (data && data.posts && data.posts.length) {
|
|
|
|
createNewPosts(data, function(postsCreated) {
|
|
|
|
createNewPosts(data, done);
|
|
|
|
done();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (app.user.uid) {
|
|
|
|
if (app.user.uid) {
|
|
|
|
socket.emit('topics.markAsRead', [tid]);
|
|
|
|
socket.emit('topics.markAsRead', [tid]);
|
|
|
|