diff --git a/app/helpers/content_viewer_helper.rb b/app/helpers/content_viewer_helper.rb index 38b81b3..41b2993 100644 --- a/app/helpers/content_viewer_helper.rb +++ b/app/helpers/content_viewer_helper.rb @@ -8,7 +8,7 @@ module ContentViewerHelper if n == 0 _('No comments yet') else - n_('One comment', '%{comments} comments', n) % { :comments => n } + n_('One comment', '%{comments} comments', n) % { :comments => n } end end diff --git a/app/views/content_viewer/_comment.rhtml b/app/views/content_viewer/_comment.rhtml index 8b1c996..c4e496f 100644 --- a/app/views/content_viewer/_comment.rhtml +++ b/app/views/content_viewer/_comment.rhtml @@ -65,7 +65,7 @@ <% if logged_in? && (user == profile || user == comment.author || user.has_permission?(:moderate_comments, profile)) %>   - <%= link_to_function(_('Remove'), 'remove_comment(this, %s, %s); return false ;' % [url_for(:profile => params[:profile], :remove_comment => comment.id, :view => params[:view]).to_json, _('Are you sure you want to remove this comment and all its replies?').to_json], :class => 'comment-footer comment-footer-link comment-footer-hide') %> + <%= link_to_function(_('Remove'), 'remove_comment(this, %s, %s); return false ;' % [url_for(:profile => params[:profile], :remove_comment => comment.id, :view => params[:view]).to_json, _('Are you sure you want to remove this comment and all its replies?').to_json], :class => 'comment-footer comment-footer-link comment-footer-hide remove-children') %> <% end %> <% unless comment.spam? %> diff --git a/public/javascripts/application.js b/public/javascripts/application.js index ca98339..a7764ba 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -693,7 +693,19 @@ function remove_comment(button, url, msg) { $button.addClass('comment-button-loading'); $.post(url, function(data) { if (data.ok) { - $button.closest('.article-comment').slideUp(); + var $comment = $button.closest('.article-comment'); + var $replies = $comment.find('.comment-replies .article-comment'); + $comment.slideUp(); + var comments_removed = 1; + if ($button.hasClass('remove-children')) { + comments_removed = 1 + $replies.size(); + } else { + $replies.appendTo('.article-comments-list'); + } + $('.comment-count').each(function() { + var count = parseInt($(this).html()); + $(this).html(count - comments_removed); + }); } }); } -- libgit2 0.21.2