From ee1e174b5f208215462a9bf453fcf364ab10986f Mon Sep 17 00:00:00 2001 From: Evandro Jr Date: Thu, 17 Jul 2014 15:56:32 -0300 Subject: [PATCH] Comments being created with all the paragraphs selected --- public/comment_paragraph.js | 47 ++++------------------------------------------- 1 file changed, 4 insertions(+), 43 deletions(-) diff --git a/public/comment_paragraph.js b/public/comment_paragraph.js index 056c4f7..16eaa63 100644 --- a/public/comment_paragraph.js +++ b/public/comment_paragraph.js @@ -1,47 +1,8 @@ -function getNextParagraphId() { - max = -1; - paragraphs = jQuery('#article_body_ifr').contents().find('.article_comments'); - paragraphs.each(function(key, value) { - value = jQuery(value).attr('data-macro-paragraph_id'); - if(value>max) max = parseInt(value); - }); - return max+1; -} - function makeCommentable() { - tinyMCE.activeEditor.focus(); - start = jQuery(tinyMCE.activeEditor.selection.getStart()).closest('p'); - end = jQuery(tinyMCE.activeEditor.selection.getEnd()).closest('p'); - - //text = start.parent().children(); - text = jQuery('#article_body_ifr').contents().find('*'); - selection = text.slice(text.index(start), text.index(end)+1); - - hasTag = false; - selection.each(function(key, value) { - commentTag = jQuery(value).closest('.article_comments'); - if(commentTag.length) { - commentTag.children().unwrap('
'); - hasTag = true; - } + paragraphsTxt="" + jQuery('#article_body_ifr').contents().find('body').children('p').each(function( index ) { + paragraphsTxt+='

' + jQuery(this).html() + '

' }); - - if(!hasTag) { - tags = start.siblings().add(start); - tags = tags.slice(tags.index(start), tags.index(end)>=0?tags.index(end)+1:tags.index(start)+1); - tags.wrapAll('
'); - - contents = jQuery('#article_body_ifr').contents(); - lastP = contents.find('p.article_comments_last_paragraph'); - if(lastP.text().trim().length > 0) { - lastP.removeClass('article_comments_last_paragraph'); - } else { - lastP.remove(); - } - lastDiv = contents.find('div.article_comments').last(); - if(lastDiv.next().length==0) { - lastDiv.after("

 

"); - } - } + tinyMCE.activeEditor.setContent(paragraphsTxt) } -- libgit2 0.21.2