Commit e8f8ec182a193be29a136c89a2dfb6da1d125518

Authored by Victor Costa
1 parent 3d04994e

comment_paragraph: improve layout and usability

Conflicts:

	plugins/comment_paragraph/views/comment_paragraph_plugin_profile/_comment_paragraph.html.erb
plugins/comment_paragraph/public/comment_paragraph_macro.js
@@ -29,7 +29,7 @@ jQuery(document).ready(function($) { @@ -29,7 +29,7 @@ jQuery(document).ready(function($) {
29 // on press ESC key... 29 // on press ESC key...
30 if (e.which == 27) { 30 if (e.which == 27) {
31 // closing side comment box 31 // closing side comment box
32 - $("div.side-comment").hide(); 32 + hideCommentBox();
33 } 33 }
34 }); 34 });
35 35
@@ -51,9 +51,15 @@ jQuery(document).ready(function($) { @@ -51,9 +51,15 @@ jQuery(document).ready(function($) {
51 51
52 $('#cancel-comment').die(); 52 $('#cancel-comment').die();
53 $(document.body).on("click", '#cancel-comment', function(){ 53 $(document.body).on("click", '#cancel-comment', function(){
54 - $("div.side-comment").hide(); 54 + hideCommentBox();
  55 + return false;
55 }); 56 });
56 57
  58 + function hideCommentBox() {
  59 + $("div.side-comment").hide();
  60 + $('.article-body').removeClass('comment-paragraph-slide-left');
  61 + }
  62 +
57 function showBox(div){ 63 function showBox(div){
58 if(div.hasClass('closed')) { 64 if(div.hasClass('closed')) {
59 div.removeClass('closed'); 65 div.removeClass('closed');
@@ -65,7 +71,7 @@ jQuery(document).ready(function($) { @@ -65,7 +71,7 @@ jQuery(document).ready(function($) {
65 cssApplier = rangy.createCssClassApplier("commented-area", {normalize: false}); 71 cssApplier = rangy.createCssClassApplier("commented-area", {normalize: false});
66 //Add marked text bubble 72 //Add marked text bubble
67 $("body").append('\ 73 $("body").append('\
68 - <a id="comment-bubble" style="width:90px;text-decoration: none">\ 74 + <a id="comment-bubble">\
69 <div align="center" class="triangle-right" >Comentar</div>\ 75 <div align="center" class="triangle-right" >Comentar</div>\
70 </a>'); 76 </a>');
71 77
@@ -82,14 +88,10 @@ jQuery(document).ready(function($) { @@ -82,14 +88,10 @@ jQuery(document).ready(function($) {
82 var paragraphId = $(this).data('paragraph'); 88 var paragraphId = $(this).data('paragraph');
83 hideAllCommentsExcept(paragraphId); 89 hideAllCommentsExcept(paragraphId);
84 hideAllSelectedAreasExcept(paragraphId); 90 hideAllSelectedAreasExcept(paragraphId);
85 - if($('.comment-paragraph-slide-left').size()==0){  
86 - $('.article-body').addClass('comment-paragraph-slide-left');  
87 - $('#side_comment_' + paragraphId).show();  
88 - }else{  
89 - $('.article-body').removeClass('comment-paragraph-slide-left');  
90 - $('.side-comment').hide();  
91 - }  
92 - $('#comment-bubble').hide(); 91 + hideCommentBox();
  92 + $('.article-body').addClass('comment-paragraph-slide-left');
  93 + $('#side_comment_' + paragraphId).show();
  94 + $('#comment-bubble').removeClass('visible');
93 //Loads the comments 95 //Loads the comments
94 var url = $('#link_to_ajax_comments_' + paragraphId).data('url'); 96 var url = $('#link_to_ajax_comments_' + paragraphId).data('url');
95 $.ajax({ 97 $.ajax({
@@ -108,7 +110,6 @@ jQuery(document).ready(function($) { @@ -108,7 +110,6 @@ jQuery(document).ready(function($) {
108 if($('.comment-paragraph-slide-left').size()==0){ 110 if($('.comment-paragraph-slide-left').size()==0){
109 $('.article-body').addClass('comment-paragraph-slide-left'); 111 $('.article-body').addClass('comment-paragraph-slide-left');
110 } 112 }
111 - $("#comment-bubble").css({top: 0, left: 0, position:'absolute'});  
112 var url = $("#comment-bubble").data('url'); 113 var url = $("#comment-bubble").data('url');
113 var paragraphId = $("#comment-bubble").data("paragraphId"); 114 var paragraphId = $("#comment-bubble").data("paragraphId");
114 hideAllCommentsExcept(paragraphId); 115 hideAllCommentsExcept(paragraphId);
@@ -142,8 +143,6 @@ jQuery(document).ready(function($) { @@ -142,8 +143,6 @@ jQuery(document).ready(function($) {
142 }); 143 });
143 } 144 }
144 145
145 - $("#comment-bubble").hide();  
146 -  
147 function getSelectionText() { 146 function getSelectionText() {
148 var text = ""; 147 var text = "";
149 if (window.getSelection) { 148 if (window.getSelection) {
@@ -157,19 +156,15 @@ jQuery(document).ready(function($) { @@ -157,19 +156,15 @@ jQuery(document).ready(function($) {
157 function setCommentBubblePosition(posX, posY) { 156 function setCommentBubblePosition(posX, posY) {
158 $("#comment-bubble").css({ 157 $("#comment-bubble").css({
159 top: (posY - 80), 158 top: (posY - 80),
160 - left: (posX - 70),  
161 - position:'absolute' 159 + left: (posX - 70)
162 }); 160 });
163 } 161 }
164 162
165 //highlight area from the paragraph 163 //highlight area from the paragraph
166 $('.comment_paragraph').mouseup(function(event) { 164 $('.comment_paragraph').mouseup(function(event) {
167 165
168 - $('#comment-bubble').hide();  
169 if($('.comment-paragraph-slide-left').size() > 0){ 166 if($('.comment-paragraph-slide-left').size() > 0){
170 - $('.article-body').removeClass('comment-paragraph-slide-left');  
171 - $('.side-comment').hide();  
172 - //$('.side-comment').find().hide(); 167 + hideCommentBox();
173 } 168 }
174 169
175 //Don't do anything if there is no selected text 170 //Don't do anything if there is no selected text
@@ -185,7 +180,7 @@ jQuery(document).ready(function($) { @@ -185,7 +180,7 @@ jQuery(document).ready(function($) {
185 var url = $('#link_to_ajax_comments_' + paragraphId).data('url'); 180 var url = $('#link_to_ajax_comments_' + paragraphId).data('url');
186 $("#comment-bubble").data("url", url); 181 $("#comment-bubble").data("url", url);
187 $("#comment-bubble").data("paragraphId", paragraphId); 182 $("#comment-bubble").data("paragraphId", paragraphId);
188 - $("#comment-bubble").show(); 183 + $("#comment-bubble").addClass('visible');
189 184
190 var rootElement = $(this).get(0); 185 var rootElement = $(this).get(0);
191 186
plugins/comment_paragraph/public/style.css
  1 +#comment-bubble.visible {
  2 + visibility: visible;
  3 +}
  4 +#comment-bubble {
  5 + transition: top 0.15s ease-in-out;
  6 + top: 0;
  7 + left: 0;
  8 + position: absolute;
  9 + width: 90px;
  10 + text-decoration: none;
  11 + visibility: hidden;
  12 +}
  13 +
1 div.article-comments-list-more{ 14 div.article-comments-list-more{
2 width: 100%; 15 width: 100%;
3 - height: 30px;  
4 text-align: center; 16 text-align: center;
5 font-size: 20px; 17 font-size: 20px;
6 margin-bottom: 5px; 18 margin-bottom: 5px;
7 } 19 }
8 20
9 .popBox_comment_paragraph { 21 .popBox_comment_paragraph {
10 -/* position: absolute;*/  
11 z-index: 2; 22 z-index: 2;
12 background: #cccccc; 23 background: #cccccc;
13 width: 60px; 24 width: 60px;
@@ -33,9 +44,8 @@ div.article-comments-list-more{ @@ -33,9 +44,8 @@ div.article-comments-list-more{
33 } 44 }
34 45
35 .comment_paragraph{ 46 .comment_paragraph{
36 - padding: 0px;  
37 - font-weight: bold;  
38 - text-align: justify; 47 + display: table-cell;
  48 + width: 97%;
39 } 49 }
40 50
41 .triangle-right { 51 .triangle-right {
@@ -45,13 +55,14 @@ div.article-comments-list-more{ @@ -45,13 +55,14 @@ div.article-comments-list-more{
45 color:#fff; 55 color:#fff;
46 background:#075698; /* default background for browsers without gradient support */ 56 background:#075698; /* default background for browsers without gradient support */
47 /* css3 */ 57 /* css3 */
48 - background:-webkit-gradient(linear, 0 0, 0 100%, from(#2e88c4), to(#075698));  
49 - background:-moz-linear-gradient(#2e88c4, #075698);  
50 - background:-o-linear-gradient(#2e88c4, #075698);  
51 - background:linear-gradient(#2e88c4, #075698); 58 + background:-webkit-gradient(linear, 0 0, 0 100%, from(#ababab), to(#424242));
  59 + background:-moz-linear-gradient(#ABABAB, #424242);
  60 + background:-o-linear-gradient(#ABABAB, #424242);
  61 + background: linear-gradient(#ABABAB, #424242);
52 -webkit-border-radius:10px; 62 -webkit-border-radius:10px;
53 -moz-border-radius:10px; 63 -moz-border-radius:10px;
54 border-radius:10px; 64 border-radius:10px;
  65 + font-weight: bold;
55 } 66 }
56 67
57 .triangle-right:after { 68 .triangle-right:after {
@@ -61,7 +72,7 @@ div.article-comments-list-more{ @@ -61,7 +72,7 @@ div.article-comments-list-more{
61 left: 50px; 72 left: 50px;
62 border-width: 20px 0 0 20px; 73 border-width: 20px 0 0 20px;
63 border-style: solid; 74 border-style: solid;
64 - border-color: #075698 transparent; 75 + border-color: #424242 transparent;
65 display: block; 76 display: block;
66 width: 0; 77 width: 0;
67 } 78 }
@@ -93,10 +104,10 @@ div.article-comments-list-more{ @@ -93,10 +104,10 @@ div.article-comments-list-more{
93 div[class^='comments_list_toggle_paragraph_'] { 104 div[class^='comments_list_toggle_paragraph_'] {
94 border-style: solid; 105 border-style: solid;
95 border-width: 1px; 106 border-width: 1px;
96 - border-color: #ccc; 107 + border-color: #e7e7e7;
97 padding: 5px; 108 padding: 5px;
98 background-color: whitesmoke; 109 background-color: whitesmoke;
99 - width: 300px; 110 + width: 280px;
100 } 111 }
101 112
102 div[class^='comment-paragraph-loading-'] { 113 div[class^='comment-paragraph-loading-'] {
@@ -109,6 +120,13 @@ div[class^=&#39;comment-paragraph-loading-&#39;] { @@ -109,6 +120,13 @@ div[class^=&#39;comment-paragraph-loading-&#39;] {
109 120
110 .side-comment{ 121 .side-comment{
111 z-index: 199; 122 z-index: 199;
  123 + box-shadow: 0px 0px 20px #b8b8b8;
  124 +}
  125 +
  126 +.side-comments-counter-container {
  127 + display: table-cell;
  128 + vertical-align: middle;
  129 + padding-left: 10px;
112 } 130 }
113 131
114 .side-comments-counter { 132 .side-comments-counter {
@@ -116,26 +134,33 @@ div[class^=&#39;comment-paragraph-loading-&#39;] { @@ -116,26 +134,33 @@ div[class^=&#39;comment-paragraph-loading-&#39;] {
116 width: 20px; 134 width: 20px;
117 height: 19px; 135 height: 19px;
118 padding: 0px; 136 padding: 0px;
119 - background: #b3b2d4;  
120 - -webkit-border-radius: 5px;  
121 - -moz-border-radius: 5px;  
122 - border-radius: 5px; 137 + background: #b8b8b8;
  138 + -webkit-border-radius: 2px;
  139 + -moz-border-radius: 2px;
  140 + border-radius: 2px;
123 cursor: pointer; 141 cursor: pointer;
124 z-index: 1; 142 z-index: 1;
  143 + display: inline-block;
  144 + font-weight: bold;
  145 + color: white;
  146 + text-align: center;
125 } 147 }
126 148
127 .side-comments-counter:hover{ 149 .side-comments-counter:hover{
128 - color: white; 150 + background-color: rgb(117, 192, 117);
  151 +}
  152 +.side-comments-counter:hover:after{
  153 + border-color: rgb(117, 192, 117) transparent;
129 } 154 }
130 155
131 .side-comments-counter:after { 156 .side-comments-counter:after {
132 content: ""; 157 content: "";
133 position: absolute; 158 position: absolute;
134 bottom: -9px; 159 bottom: -9px;
135 - left: 8px; 160 + left: 5px;
136 border-style: solid; 161 border-style: solid;
137 border-width: 12px 5px 0; 162 border-width: 12px 5px 0;
138 - border-color: #b3b2d4 transparent; 163 + border-color: #bdbdbd transparent;
139 display: block; 164 display: block;
140 width: 0; 165 width: 0;
141 } 166 }
@@ -145,7 +170,7 @@ div[class^=&#39;comment-paragraph-loading-&#39;] { @@ -145,7 +170,7 @@ div[class^=&#39;comment-paragraph-loading-&#39;] {
145 top: 3px; 170 top: 3px;
146 } 171 }
147 172
148 -.article-comment-inner {border-bottom: 1px solid #ddd;} 173 +.article-comment-inner {border-bottom: 1px solid #ececec;}
149 174
150 #article .side-comment .comment-replies .article-comment{background: white; border: 0px; border-top: 1px solid #ddd;} 175 #article .side-comment .comment-replies .article-comment{background: white; border: 0px; border-top: 1px solid #ddd;}
151 176
@@ -170,6 +195,7 @@ div[class^=&#39;comment-paragraph-loading-&#39;] { @@ -170,6 +195,7 @@ div[class^=&#39;comment-paragraph-loading-&#39;] {
170 width: 98%; 195 width: 98%;
171 text-align: justify; 196 text-align: justify;
172 overflow: visible; 197 overflow: visible;
  198 + color: rgb(107, 107, 107);
173 } 199 }
174 .side-comment .comment-text p { 200 .side-comment .comment-text p {
175 margin: 0; 201 margin: 0;
@@ -183,6 +209,8 @@ div[class^=&#39;comment-paragraph-loading-&#39;] { @@ -183,6 +209,8 @@ div[class^=&#39;comment-paragraph-loading-&#39;] {
183 left: 36px; 209 left: 36px;
184 line-height: 0; 210 line-height: 0;
185 font-weight: bold; 211 font-weight: bold;
  212 + font-size: 12px;
  213 + color: rgb(80, 80, 80);
186 } 214 }
187 .side-comment .comment-wrapper-1 { 215 .side-comment .comment-wrapper-1 {
188 margin-left: 36px; 216 margin-left: 36px;
@@ -193,6 +221,8 @@ div[class^=&#39;comment-paragraph-loading-&#39;] { @@ -193,6 +221,8 @@ div[class^=&#39;comment-paragraph-loading-&#39;] {
193 #article .side-comment .comment-picture { 221 #article .side-comment .comment-picture {
194 width: 100%; 222 width: 100%;
195 height: auto; 223 height: auto;
  224 + margin-top: 8px;
  225 + max-width: none;
196 } 226 }
197 #article .side-comment .article-comment .comment-details > h4 { 227 #article .side-comment .article-comment .comment-details > h4 {
198 display: none; 228 display: none;
@@ -215,21 +245,9 @@ div[class^=&#39;comment-paragraph-loading-&#39;] { @@ -215,21 +245,9 @@ div[class^=&#39;comment-paragraph-loading-&#39;] {
215 bg-color: #b3b2d4; 245 bg-color: #b3b2d4;
216 } 246 }
217 247
218 -/*  
219 -.comment-paragraph-rowset{  
220 - padding: 0;  
221 - margin: 0;  
222 - list-style: none;  
223 -  
224 - display: -webkit-box;  
225 - display: -moz-box;  
226 - display: -ms-flexbox;  
227 - display: -webkit-flex;  
228 - display: flex;  
229 -  
230 - -webkit-flex-flow: row wrap;  
231 - justify-content: space-around;  
232 -}*/ 248 +.side-comment textarea {
  249 + height: 50px;
  250 +}
233 251
234 .comment-paragraph-comments{ 252 .comment-paragraph-comments{
235 background: lightblue; 253 background: lightblue;
@@ -246,14 +264,24 @@ div[class^=&#39;comment-paragraph-loading-&#39;] { @@ -246,14 +264,24 @@ div[class^=&#39;comment-paragraph-loading-&#39;] {
246 border-width: 2px; 264 border-width: 2px;
247 } 265 }
248 266
  267 +.comment-paragraph-slide-left .comments {
  268 + position: relative;
  269 + display: table;
  270 +}
  271 +
249 .comment-paragraph-group-comments{ 272 .comment-paragraph-group-comments{
250 position: absolute; 273 position: absolute;
  274 + right: -296px;
  275 + top: 12px;
251 background-color: white; 276 background-color: white;
252 z-index: 9999; 277 z-index: 9999;
253 } 278 }
254 279
255 -.comment-paragraph-slide-left{ 280 +.article-body.comment-paragraph-slide-left {
256 position: relative; 281 position: relative;
257 width: 80%; 282 width: 80%;
258 - transition: 0.6s; 283 +}
  284 +.article-body {
  285 + width: 100%;
  286 + transition: width 0.3s ease-in-out;
259 } 287 }
plugins/comment_paragraph/views/comment_paragraph_plugin_profile/_comment_paragraph.html.erb
1 -<table class="comments">  
2 - <tr>  
3 - <td>  
4 - <div class="comment_paragraph" id="comment_paragraph_<%= paragraph_id %>" data-paragraph="<%= paragraph_id %>">  
5 - <%= inner_html %>  
6 - </div>  
7 - </td>  
8 - <td>  
9 - <div align="center" class="side-comments-counter" id="side_comments_counter_<%= paragraph_id %>" data-paragraph="<%= paragraph_id %>" style="vertical-align: middle; padding-left: 3px; padding-right: 5px;">  
10 - <span id="comment-count-<%= paragraph_id %>" class='comment-count'>  
11 - <%= count %>  
12 - </span>  
13 - </div>  
14 - </td>  
15 - <td> 1 +<div class="comments">
  2 + <div class="comment_paragraph" id="comment_paragraph_<%= paragraph_id %>" data-paragraph="<%= paragraph_id %>">
  3 + <%= inner_html %>
  4 + </div>
  5 + <div class="side-comments-counter-container">
  6 + <div class="side-comments-counter" id="side_comments_counter_<%= paragraph_id %>" data-paragraph="<%= paragraph_id %>">
  7 + <span id="comment-count-<%= paragraph_id %>" class='comment-count'>
  8 + <%= count %>
  9 + </span>
  10 + </div>
  11 + </div>
16 <div class="comment-paragraph-group-comments"> 12 <div class="comment-paragraph-group-comments">
17 <%= 13 <%=
18 url = { :profile => profile_identifier, :controller => 'comment_paragraph_plugin_profile', :action => 'view_comments', :paragraph_id => paragraph_id, :article_id => article_id} 14 url = { :profile => profile_identifier, :controller => 'comment_paragraph_plugin_profile', :action => 'view_comments', :paragraph_id => paragraph_id, :article_id => article_id}
@@ -42,9 +38,7 @@ @@ -42,9 +38,7 @@
42 </div> 38 </div>
43 </div> 39 </div>
44 </div> 40 </div>
45 - </td>  
46 - </tr>  
47 -</table> 41 +</div>
48 42
49 43
50 44