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() { function addBlockQuoteHandler() {
$('#post-container').on('click', 'blockquote .toggle', function() { components.get('topic').on('click', 'blockquote .toggle', function() {
var blockQuote = $(this).parent('blockquote'); var blockQuote = $(this).parent('blockquote');
var toggle = $(this); var toggle = $(this);
blockQuote.toggleClass('uncollapsed'); blockQuote.toggleClass('uncollapsed');
@ -124,7 +124,7 @@ define('forum/topic', [
function enableInfiniteLoadingOrPagination() { function enableInfiniteLoadingOrPagination() {
if(!config.usePagination) { 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 { } else {
navigator.hide(); navigator.hide();

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

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

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

@ -57,7 +57,7 @@ define('forum/topic/posts', [
function removeAlreadyAddedPosts() { function removeAlreadyAddedPosts() {
data.posts = data.posts.filter(function(post) { 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)); $(document).scrollTop(scrollTop + ($(document).height() - height));
} }
} else { } else {
$('#post-container').append(html); components.get('topic').append(html);
} }
html.hide().fadeIn('slow'); html.hide().fadeIn('slow');
@ -178,20 +178,20 @@ define('forum/topic/posts', [
} }
Posts.loadMorePosts = function(direction) { Posts.loadMorePosts = function(direction) {
if (!$('#post-container').length || navigator.scrollActive) { if (!components.get('topic').length || navigator.scrollActive) {
return; return;
} }
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"]: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); loadPostsAfter(after);
}); });
}; };
function loadPostsAfter(after) { function loadPostsAfter(after) {
var tid = ajaxify.variables.get('topic_id'); 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; return;
} }
@ -238,7 +238,7 @@ define('forum/topic/posts', [
}; };
function showBottomPostBar() { 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'); $('.bottom-post-bar').removeClass('hide');
} }
} }

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

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

Loading…
Cancel
Save