Commit f36e48437d77e70f03424ab9dada77a57d65d5b9

Authored by Rodrigo Souto
1 parent ef4cb47f

Fixing comments counter

Fixing the js method and also correcting the controller orders to
calculate the total count.
app/controllers/public/content_viewer_controller.rb
@@ -100,9 +100,9 @@ class ContentViewerController < ApplicationController @@ -100,9 +100,9 @@ class ContentViewerController < ApplicationController
100 end 100 end
101 101
102 @comments = @page.comments.without_spam 102 @comments = @page.comments.without_spam
  103 + @comments = @plugins.filter(:unavailable_comments, @comments)
103 @comments_count = @comments.count 104 @comments_count = @comments.count
104 - @comments = @plugins.filter(:unavailable_comments, @comments.without_reply)  
105 - @comments = @comments.paginate(:per_page => per_page, :page => params[:comment_page] ) 105 + @comments = @comments.without_reply.paginate(:per_page => per_page, :page => params[:comment_page] )
106 106
107 if params[:slideshow] 107 if params[:slideshow]
108 render :action => 'slideshow', :layout => 'slideshow' 108 render :action => 'slideshow', :layout => 'slideshow'
public/javascripts/comment_form.js
@@ -54,7 +54,7 @@ function save_comment(button) { @@ -54,7 +54,7 @@ function save_comment(button) {
54 $('#'+ data.render_target).replaceWith(data.html); 54 $('#'+ data.render_target).replaceWith(data.html);
55 $('#' + data.render_target).effect("highlight", {}, 3000); 55 $('#' + data.render_target).effect("highlight", {}, 3000);
56 $.colorbox.close(); 56 $.colorbox.close();
57 - update_comment_count(); 57 + increment_comment_count(comment_div);
58 } else { 58 } else {
59 //New comment of article 59 //New comment of article
60 comment_div.find('.article-comments-list').append(data.html); 60 comment_div.find('.article-comments-list').append(data.html);
@@ -65,9 +65,10 @@ function save_comment(button) { @@ -65,9 +65,10 @@ function save_comment(button) {
65 65
66 page_comment_form.find('.errorExplanation').remove(); 66 page_comment_form.find('.errorExplanation').remove();
67 $.colorbox.close(); 67 $.colorbox.close();
68 - update_comment_count(); 68 + increment_comment_count(comment_div);
69 } 69 }
70 70
  71 +
71 if(jQuery('#recaptcha_response_field').val()){ 72 if(jQuery('#recaptcha_response_field').val()){
72 Recaptcha.reload(); 73 Recaptcha.reload();
73 } 74 }
@@ -83,12 +84,11 @@ function save_comment(button) { @@ -83,12 +84,11 @@ function save_comment(button) {
83 }, 'json'); 84 }, 'json');
84 } 85 }
85 86
86 -function update_comment_count() { 87 +function increment_comment_count(comment_div) {
87 comment_div.find('.comment-count').add('#article-header .comment-count').each(function() { 88 comment_div.find('.comment-count').add('#article-header .comment-count').each(function() {
88 - var count = parseInt($(this).html());  
89 - update_comment_count($(this), count + 1); 89 + var count = parseInt(jQuery(this).html());
  90 + update_comment_count(jQuery(this), count + 1);
90 }); 91 });
91 -  
92 } 92 }
93 93
94 function show_display_comment_button() { 94 function show_display_comment_button() {