Commit b0b542b41fad46a5fdb698d5f48bb97445be86f2

Authored by Evandro Jr
1 parent dd4246ea

fix post bugs and removes ballon text underline

plugins/comment_paragraph/public/comment_paragraph.js
1 function makeCommentable() { 1 function makeCommentable() {
2 - paragraphsTxt=""  
3 - 2 + paragraphsTxt="";
  3 + //Add p tag, when opening the editor. For some season it comes without p tag
4 foundCommentableParagraph = false; 4 foundCommentableParagraph = false;
5 jQuery('#article_body_ifr').contents().find('body').children('div.article_comments').each(function( index ) { 5 jQuery('#article_body_ifr').contents().find('body').children('div.article_comments').each(function( index ) {
6 paragraphsTxt+="<p>" + jQuery(this).html() + "</p>"; 6 paragraphsTxt+="<p>" + jQuery(this).html() + "</p>";
7 foundCommentableParagraph = true; 7 foundCommentableParagraph = true;
8 }); 8 });
9 9
  10 + //undo the paragraph comment tags
10 if(foundCommentableParagraph === true){ 11 if(foundCommentableParagraph === true){
11 - tinyMCE.activeEditor.setContent(paragraphsTxt) 12 + tinyMCE.activeEditor.setContent(paragraphsTxt);
12 return; 13 return;
13 } 14 }
14 15
  16 + //Wraps the paragraph using the chosen class
15 jQuery('#article_body_ifr').contents().find('body').children('p').each(function( index ) { 17 jQuery('#article_body_ifr').contents().find('body').children('p').each(function( index ) {
16 - paragraphsTxt+='<p><div class="macro article_comments" data-macro="comment_paragraph_plugin/allow_comment" data-macro-paragraph_id="' + index + '">' + jQuery(this).html() + '</div></p><br>' 18 + text = jQuery(this).html().trim();
  19 + if(text!="" && text!="<br>"){
  20 + paragraphsTxt+='<p><div class="macro article_comments" data-macro="comment_paragraph_plugin/allow_comment" data-macro-paragraph_id="' + index + '">' + text + '</div></p><br>'
  21 + }
17 }); 22 });
18 - tinyMCE.activeEditor.setContent(paragraphsTxt) 23 + tinyMCE.activeEditor.setContent(paragraphsTxt);
  24 +
  25 + //Workaround necessary to post the body of the article
  26 + tinymce.activeEditor.execCommand('mceInsertContent', false, " ");
19 } 27 }
20 28
plugins/comment_paragraph/public/comment_paragraph_macro.js
@@ -13,7 +13,7 @@ jQuery(document).ready(function($) { @@ -13,7 +13,7 @@ jQuery(document).ready(function($) {
13 13
14 //Add marked text bubble 14 //Add marked text bubble
15 $("body").append('\ 15 $("body").append('\
16 - <a href="#" id="comment-bubble" style="width:120px;height:105px;">\ 16 + <a href="#" id="comment-bubble" style="width:120px;height:105px;text-decoration: none">\
17 <div align="center" class="triangle-right" >Comentar<br>+</div>\ 17 <div align="center" class="triangle-right" >Comentar<br>+</div>\
18 </a>'); 18 </a>');
19 $("#comment-bubble").hide(); 19 $("#comment-bubble").hide();
@@ -32,7 +32,6 @@ jQuery(document).ready(function($) { @@ -32,7 +32,6 @@ jQuery(document).ready(function($) {
32 $('#comment-bubble').mouseleave(function(){ 32 $('#comment-bubble').mouseleave(function(){
33 this.hide(); 33 this.hide();
34 $("#comment-bubble").css({top: 0, left: 0, position:'absolute'}); 34 $("#comment-bubble").css({top: 0, left: 0, position:'absolute'});
35 -// $("#comment-bubble").css({top: 0, left: 0, position:'absolute', 'background-color': 'yellow'});  
36 }); 35 });
37 36
38 //highlight area from the paragraph 37 //highlight area from the paragraph
@@ -45,10 +44,7 @@ jQuery(document).ready(function($) { @@ -45,10 +44,7 @@ jQuery(document).ready(function($) {
45 $("#comment-bubble").data("paragraphId", paragraphId) 44 $("#comment-bubble").data("paragraphId", paragraphId)
46 var url = $('#link_to_ajax_comments_' + paragraphId).data('url'); 45 var url = $('#link_to_ajax_comments_' + paragraphId).data('url');
47 $("#comment-bubble").data("url", url) 46 $("#comment-bubble").data("url", url)
48 -// $("#comment-bubble").css({top: event.pageY-100, left: event.pageX-70, position:'absolute', 'background-color': 'yellow'});  
49 $("#comment-bubble").show(); 47 $("#comment-bubble").show();
50 - // var onclickContent = $('#link_to_ajax_comments_' + paragraphId).attr('onclick');  
51 - // $("#comment-bubble").attr('onclick', onclickContent);  
52 var rootElement = $(this).get(0); 48 var rootElement = $(this).get(0);
53 lastParagraph[paragraphId] = rootElement.innerHTML; 49 lastParagraph[paragraphId] = rootElement.innerHTML;
54 var selObj = rangy.getSelection(); 50 var selObj = rangy.getSelection();
@@ -81,11 +77,11 @@ jQuery(document).ready(function($) { @@ -81,11 +77,11 @@ jQuery(document).ready(function($) {
81 url: url 77 url: url
82 }).done(function() { 78 }).done(function() {
83 var button = jQuery('#page-comment-form-' + paragraphId + ' a')[0]; 79 var button = jQuery('#page-comment-form-' + paragraphId + ' a')[0];
84 - //console.log(button);  
85 button.click(); 80 button.click();
86 - //$('body').scrollTo('#page-comment-form-' + paragraphId + ' a'); 81 + window.location="#page-comment-form-" + paragraphId;
87 }); 82 });
88 }); 83 });
  84 +
89 85
90 function processAnchor(){ 86 function processAnchor(){
91 var anchor = window.location.hash; 87 var anchor = window.location.hash;
@@ -149,7 +145,6 @@ function toggleParagraph(paragraph) { @@ -149,7 +145,6 @@ function toggleParagraph(paragraph) {
149 var visible = div.is(':visible'); 145 var visible = div.is(':visible');
150 if(!visible) 146 if(!visible)
151 jQuery('div.comment-paragraph-loading-'+paragraph).addClass('comment-button-loading'); 147 jQuery('div.comment-paragraph-loading-'+paragraph).addClass('comment-button-loading');
152 -  
153 div.toggle('fast'); 148 div.toggle('fast');
154 return visible; 149 return visible;
155 } 150 }