Commit db70e0929c00248d2492f632b4caa34a4d0584f2

Authored by Victor Costa
2 parents 8c0c822f aa2c4349

Merge branch 'AI3205-comment-paragraph' into stable

Conflicts:
	plugins/comment_paragraph/public/style.css
plugins/comment_paragraph/lib/comment_paragraph_plugin/macros/allow_comment.rb
... ... @@ -12,8 +12,12 @@ class CommentParagraphPlugin::AllowComment < Noosfero::Plugin::Macro
12 12 count = article.paragraph_comments.without_spam.in_paragraph(paragraph_uuid).count
13 13  
14 14 proc {
15   - render :partial => 'comment_paragraph_plugin_profile/comment_paragraph',
16   - :locals => {:paragraph_uuid => paragraph_uuid, :article_id => article.id, :inner_html => inner_html, :count => count, :profile_identifier => article.profile.identifier }
  15 + if controller.kind_of?(ContentViewerController)
  16 + render :partial => 'comment_paragraph_plugin_profile/comment_paragraph',
  17 + :locals => {:paragraph_uuid => paragraph_uuid, :article_id => article.id, :inner_html => inner_html, :count => count, :profile_identifier => article.profile.identifier }
  18 + else
  19 + inner_html
  20 + end
17 21 }
18 22 end
19 23 end
... ...
plugins/comment_paragraph/public/comment_paragraph_macro.js
... ... @@ -208,6 +208,7 @@ jQuery(document).ready(function($) {
208 208 processAnchor();
209 209  
210 210 $(document).on('mouseenter', 'li.article-comment', function() {
  211 + hideAllSelectedAreasExcept(null, '.commented-area-selected');
211 212 var selected_area = $(this).find('input.paragraph_comment_area').val();
212 213 var container = $(this).closest('.comment-paragraph-plugin');
213 214 var rootElement = container.find('.comment_paragraph')[0];
... ... @@ -220,5 +221,14 @@ jQuery(document).ready(function($) {
220 221  
221 222 $(document).on('mouseleave', 'li.article-comment', function() {
222 223 hideAllSelectedAreasExcept();
  224 +
  225 + var container = $(this).closest('.comment-paragraph-plugin');
  226 + var selected_area = container.find('input.selected_area').val();
  227 + var rootElement = container.find('.comment_paragraph')[0];
  228 + if(selected_area != ""){
  229 + rangy.deserializeSelection(selected_area, rootElement);
  230 + cssApplierSelected.toggleSelection();
  231 + }
  232 + clearSelection();
223 233 });
224 234 });
... ...
plugins/comment_paragraph/public/style.css
... ... @@ -43,12 +43,12 @@ div.article-comments-list-more{
43 43 }
44 44  
45 45 .comment_paragraph ::selection {
46   - background: lightseagreen; /* WebKit/Blink Browsers */
  46 + background-color: lightseagreen; /* WebKit/Blink Browsers */
47 47 color: white;
48 48 }
49 49  
50 50 .comment_paragraph ::-moz-selection {
51   - background: lightseagreen; /* Gecko Browsers */
  51 + background-color: lightseagreen; /* Gecko Browsers */
52 52 color: white;
53 53 }
54 54  
... ...
plugins/comment_paragraph/test/unit/allow_comment_test.rb
... ... @@ -18,9 +18,21 @@ class AllowCommentTest < ActiveSupport::TestCase
18 18 comment = fast_create(Comment, :paragraph_uuid => 1, :source_id => article.id)
19 19 inner_html = 'inner'
20 20 content = macro.parse({:paragraph_uuid => comment.paragraph_uuid}, inner_html, article)
  21 + expects(:controller).returns(ContentViewerController.new)
21 22  
22 23 expects(:render).with({:partial => 'comment_paragraph_plugin_profile/comment_paragraph', :locals => {:paragraph_uuid => comment.paragraph_uuid, :article_id => article.id, :inner_html => inner_html, :count => 1, :profile_identifier => profile.identifier} })
23 24 instance_eval(&content)
24 25 end
25 26  
  27 + should 'not parse contents outside content viewer controller' do
  28 + profile = fast_create(Community)
  29 + article = fast_create(Article, :profile_id => profile.id)
  30 + comment = fast_create(Comment, :paragraph_uuid => 1, :source_id => article.id)
  31 + inner_html = 'inner'
  32 + content = macro.parse({:paragraph_uuid => comment.paragraph_uuid}, inner_html, article)
  33 + expects(:controller).returns(HomeController.new)
  34 +
  35 + assert_equal 'inner', instance_eval(&content)
  36 + end
  37 +
26 38 end
... ...