|
|
|
@ -346,10 +346,8 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
|
|
|
|
|
|
|
|
|
|
function enableInfiniteLoading() {
|
|
|
|
|
if(!config.usePagination) {
|
|
|
|
|
$(window).off('scroll').on('scroll', function() {
|
|
|
|
|
var bottom = ($(document).height() - $(window).height()) * 0.9;
|
|
|
|
|
|
|
|
|
|
if ($(window).scrollTop() > bottom && !infiniteLoaderActive && $('#post-container').children().length) {
|
|
|
|
|
app.enableInfiniteLoading(function() {
|
|
|
|
|
if (!infiniteLoaderActive && $('#post-container').children().length) {
|
|
|
|
|
loadMorePosts(tid, function(posts) {
|
|
|
|
|
fixDeleteStateForPosts();
|
|
|
|
|
});
|
|
|
|
@ -396,7 +394,7 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
|
|
|
|
|
|
|
|
|
|
socket.emit('posts.getRawPost', pid, function(err, post) {
|
|
|
|
|
if(err) {
|
|
|
|
|
return app.alert(err.message);
|
|
|
|
|
return app.alertError(err.message);
|
|
|
|
|
}
|
|
|
|
|
var quoted = '';
|
|
|
|
|
if(post) {
|
|
|
|
@ -895,47 +893,34 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggle_post_delete_state(pid) {
|
|
|
|
|
var postEl = $(document.querySelector('#post-container li[data-pid="' + pid + '"]'));
|
|
|
|
|
|
|
|
|
|
if (postEl[0]) {
|
|
|
|
|
quoteEl = postEl.find('.quote'),
|
|
|
|
|
favEl = postEl.find('.favourite'),
|
|
|
|
|
replyEl = postEl.find('.post_reply');
|
|
|
|
|
var postEl = $('#post-container li[data-pid="' + pid + '"]');
|
|
|
|
|
|
|
|
|
|
socket.emit('posts.getPrivileges', pid, function(err, privileges) {
|
|
|
|
|
if(err) {
|
|
|
|
|
return app.alert(err.message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (privileges.editable) {
|
|
|
|
|
if (!postEl.hasClass('deleted')) {
|
|
|
|
|
toggle_post_tools(pid, false);
|
|
|
|
|
} else {
|
|
|
|
|
toggle_post_tools(pid, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (postEl.length) {
|
|
|
|
|
postEl.toggleClass('deleted');
|
|
|
|
|
|
|
|
|
|
postEl.toggleClass('deleted');
|
|
|
|
|
toggle_post_tools(pid, postEl.hasClass('deleted'));
|
|
|
|
|
|
|
|
|
|
updatePostCount();
|
|
|
|
|
});
|
|
|
|
|
updatePostCount();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggle_post_tools(pid, state) {
|
|
|
|
|
var postEl = $(document.querySelector('#post-container li[data-pid="' + pid + '"]')),
|
|
|
|
|
function toggle_post_tools(pid, isDeleted) {
|
|
|
|
|
var postEl = $('#post-container li[data-pid="' + pid + '"]'),
|
|
|
|
|
quoteEl = $(postEl[0].querySelector('.quote')),
|
|
|
|
|
favEl = $(postEl[0].querySelector('.favourite')),
|
|
|
|
|
replyEl = $(postEl[0].querySelector('.post_reply'));
|
|
|
|
|
replyEl = $(postEl[0].querySelector('.post_reply')),
|
|
|
|
|
chatEl = $(postEl[0].querySelector('.chat'));
|
|
|
|
|
|
|
|
|
|
if (state) {
|
|
|
|
|
quoteEl.removeClass('none');
|
|
|
|
|
favEl.removeClass('none');
|
|
|
|
|
replyEl.removeClass('none');
|
|
|
|
|
} else {
|
|
|
|
|
if (isDeleted) {
|
|
|
|
|
quoteEl.addClass('none');
|
|
|
|
|
favEl.addClass('none');
|
|
|
|
|
replyEl.addClass('none');
|
|
|
|
|
chatEl.addClass('none');
|
|
|
|
|
} else {
|
|
|
|
|
quoteEl.removeClass('none');
|
|
|
|
|
favEl.removeClass('none');
|
|
|
|
|
replyEl.removeClass('none');
|
|
|
|
|
chatEl.removeClass('none');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1065,9 +1050,9 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
|
|
|
|
|
|
|
|
|
|
function onNewPostPagination(data) {
|
|
|
|
|
var posts = data.posts;
|
|
|
|
|
socket.emit('topics.getPageCount', tid, function(err, newPageCount) {
|
|
|
|
|
socket.emit('topics.getPageCount', templates.get('topic_id'), function(err, newPageCount) {
|
|
|
|
|
|
|
|
|
|
pagination.recreatePaginationLinks('topic', newPageCount);
|
|
|
|
|
pagination.recreatePaginationLinks(newPageCount);
|
|
|
|
|
|
|
|
|
|
if(pagination.currentPage === pagination.pageCount) {
|
|
|
|
|
createNewPosts(data);
|
|
|
|
|