fix edit/vote/bookmark icons for nested replies

v1.18.x
barisusakli 8 years ago
parent 2185d8eb99
commit c90f082c77

@ -63,7 +63,7 @@
"nodebb-plugin-spam-be-gone": "0.4.10", "nodebb-plugin-spam-be-gone": "0.4.10",
"nodebb-rewards-essentials": "0.0.9", "nodebb-rewards-essentials": "0.0.9",
"nodebb-theme-lavender": "3.0.15", "nodebb-theme-lavender": "3.0.15",
"nodebb-theme-persona": "4.1.78", "nodebb-theme-persona": "4.1.79",
"nodebb-theme-vanilla": "5.1.52", "nodebb-theme-vanilla": "5.1.52",
"nodebb-widget-essentials": "2.0.13", "nodebb-widget-essentials": "2.0.13",
"nodemailer": "2.6.4", "nodemailer": "2.6.4",

@ -69,15 +69,14 @@ define('forum/topic/events', [
} }
function updatePostVotesAndUserReputation(data) { function updatePostVotesAndUserReputation(data) {
var votes = components.get('post/vote-count', data.post.pid); var votes = $('[data-pid="' + data.post.pid + '"] [component="post/vote-count"]').first();
var reputationElements = $('.reputation[data-uid="' + data.post.uid + '"]'); var reputationElements = $('.reputation[data-uid="' + data.post.uid + '"]');
votes.html(data.post.votes).attr('data-votes', data.post.votes); votes.html(data.post.votes).attr('data-votes', data.post.votes);
reputationElements.html(data.user.reputation).attr('data-reputation', data.user.reputation); reputationElements.html(data.user.reputation).attr('data-reputation', data.user.reputation);
} }
function updateBookmarkCount(data) { function updateBookmarkCount(data) {
$('[data-pid="' + data.post.pid + '"] .bookmarkCount').html(data.post.bookmarks).attr('data-bookmarks', data.post.bookmarks); $('[data-pid="' + data.post.pid + '"] .bookmarkCount').first().html(data.post.bookmarks).attr('data-bookmarks', data.post.bookmarks);
} }
function onTopicPurged() { function onTopicPurged() {
@ -96,8 +95,13 @@ define('forum/topic/events', [
if (!data || !data.post) { if (!data || !data.post) {
return; return;
} }
var editedPostEl = components.get('post/content', data.post.pid); var editedPostEl = components.get('post/content', data.post.pid).filter(function (index, el) {
var editorEl = $('[data-pid="' + data.post.pid + '"] [component="post/editor"]'); return parseInt($(el).closest('[data-pid]').attr('data-pid'), 10) === parseInt(data.post.pid, 10);
});
var editorEl = $('[data-pid="' + data.post.pid + '"] [component="post/editor"]').filter(function (index, el) {
return parseInt($(el).closest('[data-pid]').attr('data-pid'), 10) === parseInt(data.post.pid, 10);
});
var topicTitle = components.get('topic/title'); var topicTitle = components.get('topic/title');
var navbarTitle = components.get('navbar/title').find('span'); var navbarTitle = components.get('navbar/title').find('span');
var breadCrumb = components.get('breadcrumb/current'); var breadCrumb = components.get('breadcrumb/current');
@ -136,7 +140,7 @@ define('forum/topic/events', [
translator.translate(html, function (translated) { translator.translate(html, function (translated) {
html = $(translated); html = $(translated);
editorEl.replaceWith(html); editorEl.replaceWith(html);
html.find('.timeago').timeago(); $('[data-pid="' + data.post.pid + '"] [component="post/editor"] .timeago').timeago();
$(window).trigger('action:posts.edited', data); $(window).trigger('action:posts.edited', data);
}); });
}); });
@ -200,7 +204,7 @@ define('forum/topic/events', [
} }
function togglePostBookmark(data) { function togglePostBookmark(data) {
var el = $('[data-pid="' + data.post.pid + '"] [component="post/bookmark"]'); var el = $('[data-pid="' + data.post.pid + '"] [component="post/bookmark"]').first();
if (!el.length) { if (!el.length) {
return; return;
@ -214,8 +218,8 @@ define('forum/topic/events', [
function togglePostVote(data) { function togglePostVote(data) {
var post = $('[data-pid="' + data.post.pid + '"]'); var post = $('[data-pid="' + data.post.pid + '"]');
post.find('[component="post/upvote"]').toggleClass('upvoted', data.upvote); post.find('[component="post/upvote"]').first().toggleClass('upvoted', data.upvote);
post.find('[component="post/downvote"]').toggleClass('downvoted', data.downvote); post.find('[component="post/downvote"]').first().toggleClass('downvoted', data.downvote);
} }
function onNewNotification(data) { function onNewNotification(data) {

@ -50,6 +50,7 @@ define('forum/topic/replies', ['navigator', 'components', 'forum/topic/posts'],
app.parseAndTranslate('topic', 'posts', tplData, function (html) { app.parseAndTranslate('topic', 'posts', tplData, function (html) {
$('<div>', {component: 'post/replies'}).html(html).hide().insertAfter(button).slideDown('fast'); $('<div>', {component: 'post/replies'}).html(html).hide().insertAfter(button).slideDown('fast');
posts.processPage(html); posts.processPage(html);
$(window).trigger('action:posts.loaded', {posts: data});
}); });
}); });
} else if (close.is(':not(.hidden)')) { } else if (close.is(':not(.hidden)')) {

Loading…
Cancel
Save