Commit 8c0c822f454ca3332f46f5098ee486ea01270bfd
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge branch 'AI3205-comment-paragraph' into stable
Showing
2 changed files
with
28 additions
and
5 deletions
Show diff stats
plugins/comment_paragraph/public/comment_paragraph_macro.js
@@ -49,6 +49,8 @@ jQuery(document).ready(function($) { | @@ -49,6 +49,8 @@ jQuery(document).ready(function($) { | ||
49 | 49 | ||
50 | rangy.init(); | 50 | rangy.init(); |
51 | cssApplier = rangy.createCssClassApplier("commented-area", {normalize: false}); | 51 | cssApplier = rangy.createCssClassApplier("commented-area", {normalize: false}); |
52 | + cssApplierSelected = rangy.createCssClassApplier("commented-area-selected", {normalize: false}); | ||
53 | + | ||
52 | //Add marked text bubble | 54 | //Add marked text bubble |
53 | $("body").append('\ | 55 | $("body").append('\ |
54 | <a id="comment-bubble">\ | 56 | <a id="comment-bubble">\ |
@@ -83,11 +85,14 @@ jQuery(document).ready(function($) { | @@ -83,11 +85,14 @@ jQuery(document).ready(function($) { | ||
83 | $('#comment-paragraph-plugin_' + paragraph).find('.side-comments-counter').click(); | 85 | $('#comment-paragraph-plugin_' + paragraph).find('.side-comments-counter').click(); |
84 | }); | 86 | }); |
85 | 87 | ||
86 | - function hideAllSelectedAreasExcept(clickedParagraph){ | 88 | + function hideAllSelectedAreasExcept(clickedParagraph, areaClass) { |
89 | + if(!areaClass) { | ||
90 | + areaClass = '.commented-area'; | ||
91 | + } | ||
87 | $(".comment_paragraph").each(function(){ | 92 | $(".comment_paragraph").each(function(){ |
88 | paragraph = $(this).closest('.comment-paragraph-plugin').data('paragraph'); | 93 | paragraph = $(this).closest('.comment-paragraph-plugin').data('paragraph'); |
89 | if(paragraph != clickedParagraph){ | 94 | if(paragraph != clickedParagraph){ |
90 | - $(this).find(".commented-area").contents().unwrap(); | 95 | + $(this).find(areaClass).contents().unwrap(); |
91 | $(this).html($(this).html()); //XXX: workaround to prevent creation of text nodes | 96 | $(this).html($(this).html()); //XXX: workaround to prevent creation of text nodes |
92 | } | 97 | } |
93 | }); | 98 | }); |
@@ -103,6 +108,14 @@ jQuery(document).ready(function($) { | @@ -103,6 +108,14 @@ jQuery(document).ready(function($) { | ||
103 | return text; | 108 | return text; |
104 | } | 109 | } |
105 | 110 | ||
111 | + function clearSelection() { | ||
112 | + if ( document.selection ) { | ||
113 | + document.selection.empty(); | ||
114 | + } else if ( window.getSelection ) { | ||
115 | + window.getSelection().removeAllRanges(); | ||
116 | + } | ||
117 | + } | ||
118 | + | ||
106 | function setCommentBubblePosition(posX, posY) { | 119 | function setCommentBubblePosition(posX, posY) { |
107 | $("#comment-bubble").css({ | 120 | $("#comment-bubble").css({ |
108 | top: (posY - 80), | 121 | top: (posY - 80), |
@@ -164,10 +177,12 @@ jQuery(document).ready(function($) { | @@ -164,10 +177,12 @@ jQuery(document).ready(function($) { | ||
164 | form.find('input.selected_content').val(selected_content) | 177 | form.find('input.selected_content').val(selected_content) |
165 | } | 178 | } |
166 | rootElement.focus(); | 179 | rootElement.focus(); |
167 | - cssApplier.toggleSelection(); | 180 | + cssApplierSelected.toggleSelection(); |
181 | + clearSelection(); | ||
182 | + | ||
168 | //set a one time handler to prevent multiple selections | 183 | //set a one time handler to prevent multiple selections |
169 | var fn = function() { | 184 | var fn = function() { |
170 | - hideAllSelectedAreasExcept(); | 185 | + hideAllSelectedAreasExcept(null, '.commented-area-selected'); |
171 | $('.comment-paragraph-plugin').off('mousedown', '.comment_paragraph', fn); | 186 | $('.comment-paragraph-plugin').off('mousedown', '.comment_paragraph', fn); |
172 | } | 187 | } |
173 | $('.comment-paragraph-plugin').on('mousedown', '.comment_paragraph', fn); | 188 | $('.comment-paragraph-plugin').on('mousedown', '.comment_paragraph', fn); |
plugins/comment_paragraph/public/style.css
@@ -32,16 +32,24 @@ div.article-comments-list-more{ | @@ -32,16 +32,24 @@ div.article-comments-list-more{ | ||
32 | font-weight: bold; | 32 | font-weight: bold; |
33 | } | 33 | } |
34 | 34 | ||
35 | -.commented-area { | 35 | +.comment-paragraph-plugin .commented-area { |
36 | background-color: lightseagreen; | 36 | background-color: lightseagreen; |
37 | + color: white; | ||
38 | +} | ||
39 | + | ||
40 | +.comment-paragraph-plugin .commented-area-selected { | ||
41 | + background-color: rgb(255, 86, 86); | ||
42 | + color: white; | ||
37 | } | 43 | } |
38 | 44 | ||
39 | .comment_paragraph ::selection { | 45 | .comment_paragraph ::selection { |
40 | background: lightseagreen; /* WebKit/Blink Browsers */ | 46 | background: lightseagreen; /* WebKit/Blink Browsers */ |
47 | + color: white; | ||
41 | } | 48 | } |
42 | 49 | ||
43 | .comment_paragraph ::-moz-selection { | 50 | .comment_paragraph ::-moz-selection { |
44 | background: lightseagreen; /* Gecko Browsers */ | 51 | background: lightseagreen; /* Gecko Browsers */ |
52 | + color: white; | ||
45 | } | 53 | } |
46 | 54 | ||
47 | .comment_paragraph{ | 55 | .comment_paragraph{ |