updated core to point #post_container and .post-row to its respective components

v1.18.x
psychobunny 10 years ago
parent 8fcdae7f17
commit 6439147586

@ -112,7 +112,7 @@ define('forum/topic', [
}
function addBlockQuoteHandler() {
$('#post-container').on('click', 'blockquote .toggle', function() {
components.get('topic').on('click', 'blockquote .toggle', function() {
var blockQuote = $(this).parent('blockquote');
var toggle = $(this);
blockQuote.toggleClass('uncollapsed');
@ -124,7 +124,7 @@ define('forum/topic', [
function enableInfiniteLoadingOrPagination() {
if(!config.usePagination) {
infinitescroll.init(posts.loadMorePosts, $('#post-container .post-row[data-index="0"]').height());
infinitescroll.init(posts.loadMorePosts, components.get('topic').find('.post-row[data-index="0"]').height());
} else {
navigator.hide();

@ -139,14 +139,15 @@ define('forum/topic/events', [
}
function onPostPurged(pid) {
$('#post-container [data-pid="' + pid + '"]').fadeOut(500, function() {
components.get('post', 'pid', pid).fadeOut(500, function() {
$(this).remove();
});
postTools.updatePostCount();
}
function togglePostDeleteState(data) {
var postEl = $('#post-container [data-pid="' + data.pid + '"]');
var postEl = components.get('post', 'pid', data.pid);
if (!postEl.length) {
return;

@ -35,7 +35,7 @@ define('forum/topic/fork', function() {
forkModal.find('.close,#fork_thread_cancel').on('click', closeForkModal);
forkModal.find('#fork-title').on('change', checkForkButtonEnable);
$('#post-container').on('click', '[data-pid]', function() {
components.get('topic').on('click', '[data-pid]', function() {
togglePostSelection($(this));
});
@ -58,7 +58,7 @@ define('forum/topic/fork', function() {
pids: pids
}, function(err, newTopic) {
function fadeOutAndRemove(pid) {
$('#post-container [data-pid="' + pid + '"]').fadeOut(500, function() {
components.get('post', 'pid', pid).fadeOut(500, function() {
$(this).remove();
});
}
@ -125,10 +125,11 @@ define('forum/topic/fork', function() {
function closeForkModal() {
for(var i=0; i<pids.length; ++i) {
$('#post-container [data-pid="' + pids[i] + '"]').css('opacity', 1);
components.get('post', 'pid', pids[i]).css('opacity', 1);
}
forkModal.addClass('hide');
$('#post-container').off('click', '[data-pid]');
components.get('topic').off('click', '[data-pid]');
enableClicksOnPosts();
}

@ -18,7 +18,7 @@ define('forum/topic/postTools', ['composer', 'share', 'navigator'], function(com
};
PostTools.toggle = function(pid, isDeleted) {
var postEl = $('#post-container li[data-pid="' + pid + '"]');
var postEl = components.get('post', 'pid', pid);
postEl.find('.quote, .favourite, .post_reply, .chat, .flag').toggleClass('hidden', isDeleted);
postEl.find('.purge').toggleClass('hidden', !isDeleted);
@ -38,7 +38,7 @@ define('forum/topic/postTools', ['composer', 'share', 'navigator'], function(com
};
function addVoteHandler() {
$('#post-container').on('mouseenter', '.post-row .votes', function() {
components.get('topic').on('mouseenter', '.post-row .votes', function() {
loadDataAndCreateTooltip($(this));
});
}
@ -76,7 +76,7 @@ define('forum/topic/postTools', ['composer', 'share', 'navigator'], function(com
}
});
var postContainer = $('#post-container');
var postContainer = components.get('topic');
postContainer.on('click', '.quote', function() {
if (!threadState.locked) {
@ -241,7 +241,7 @@ define('forum/topic/postTools', ['composer', 'share', 'navigator'], function(com
function deletePost(button, tid) {
var pid = getData(button, 'data-pid'),
postEl = $('#post-container li[data-pid="' + pid + '"]'),
postEl = components.get('post', 'pid', pid),
action = !postEl.hasClass('deleted') ? 'delete' : 'restore';
postAction(action, pid, tid);

@ -57,7 +57,7 @@ define('forum/topic/posts', [
function removeAlreadyAddedPosts() {
data.posts = data.posts.filter(function(post) {
return $('#post-container [data-pid="' + post.pid +'"]').length === 0;
return components.get('post', 'pid', post.pid).length === 0;
});
}
@ -127,7 +127,7 @@ define('forum/topic/posts', [
$(document).scrollTop(scrollTop + ($(document).height() - height));
}
} else {
$('#post-container').append(html);
components.get('topic').append(html);
}
html.hide().fadeIn('slow');
@ -178,20 +178,20 @@ define('forum/topic/posts', [
}
Posts.loadMorePosts = function(direction) {
if (!$('#post-container').length || navigator.scrollActive) {
if (!components.get('topic').length || navigator.scrollActive) {
return;
}
var reverse = config.topicPostSort === 'newest_to_oldest' || config.topicPostSort === 'most_votes';
infinitescroll.calculateAfter(direction, '#post-container .post-row[data-index!="0"]:not(.new)', config.postsPerPage, reverse, function(after, offset, el) {
infinitescroll.calculateAfter(direction, components.get('topic').find('[data-index][data-index!="0"]:not(.new)'), config.postsPerPage, reverse, function(after, offset, el) {
loadPostsAfter(after);
});
};
function loadPostsAfter(after) {
var tid = ajaxify.variables.get('topic_id');
if (!utils.isNumber(tid) || !utils.isNumber(after) || (after === 0 && $('#post-container .post-row[data-index="1"]').length)) {
if (!utils.isNumber(tid) || !utils.isNumber(after) || (after === 0 && components.get('post', 'index', 1).length)) {
return;
}
@ -238,7 +238,7 @@ define('forum/topic/posts', [
};
function showBottomPostBar() {
if($('#post-container .post-row').length > 1 || !$('#post-container [data-index="0"]').length) {
if(components.get('post', 'index').length > 1 || !components.get('post', 'index', 0).length) {
$('.bottom-post-bar').removeClass('hide');
}
}

@ -97,7 +97,7 @@ define('forum/topic/threadTools', ['forum/topic/fork', 'forum/topic/move'], func
}
ThreadTools.setLockedState = function(data) {
var threadEl = $('#post-container');
var threadEl = components.get('topic');
if (parseInt(data.tid, 10) === parseInt(threadEl.attr('data-tid'), 10)) {
var isLocked = data.isLocked && !app.user.isAdmin;
@ -116,7 +116,7 @@ define('forum/topic/threadTools', ['forum/topic/fork', 'forum/topic/move'], func
};
ThreadTools.setDeleteState = function(data) {
var threadEl = $('#post-container');
var threadEl = components.get('topic');
if (parseInt(data.tid, 10) !== parseInt(threadEl.attr('data-tid'), 10)) {
return;
}
@ -137,7 +137,7 @@ define('forum/topic/threadTools', ['forum/topic/fork', 'forum/topic/move'], func
};
ThreadTools.setPinnedState = function(data) {
var threadEl = $('#post-container');
var threadEl = components.get('topic');
if (parseInt(data.tid, 10) === parseInt(threadEl.attr('data-tid'), 10)) {
translator.translate('<i class="fa fa-fw fa-thumb-tack"></i> [[topic:thread_tools.' + (data.isPinned ? 'unpin' : 'pin') + ']]', function(translated) {
$('.pin_thread').html(translated);

@ -153,7 +153,7 @@ define('navigator', ['forum/pagination'], function(pagination) {
}
navigator.scrollToPost = function(postIndex, highlight, duration, offset) {
if (!utils.isNumber(postIndex) || !$('#post-container').length) {
if (!utils.isNumber(postIndex) || !components.get('topic').length) {
return;
}
@ -222,7 +222,7 @@ define('navigator', ['forum/pagination'], function(pagination) {
}
}
if ($('#post-container').length) {
if (components.get('topic').length) {
animateScroll();
}
}

Loading…
Cancel
Save