Commit 08eef8853a478d3a351001bc1d1d0ca738659706

Authored by Victor Costa
1 parent c2c4d9c2

comment_paragraph: fix some js and css

plugins/comment_paragraph/public/comment_paragraph_macro.js
... ... @@ -10,26 +10,19 @@ function setPlusIfZeroComments($){
10 10 });
11 11 }
12 12  
13   -function hideUndesiredStuff($){
14   - $('.comment-created-at').hide();
15   - $('#comment_title').hide();
16   - $('.formlabel').attr('for', 'comment_title').hide();
17   - if($.browser.mozilla){
18   - $('#fancybox-loading').hide();
19   - }
20   -}
21   -
22   -function removeUndesiredStuff($){
23   - $('#comments_list').last().remove();
24   - $('.formlabel').attr('for', 'comment_title').remove();
25   -}
26   -
27 13 jQuery(document).ready(function($) {
28 14 //Quit if does not detect a comment for that plugin
29 15 if($('.comment_paragraph').size() < 1)
30 16 return;
31   -
32   - removeUndesiredStuff($);
  17 +
  18 + $(document).keyup(function(e) {
  19 + // on press ESC key...
  20 + if (e.which == 27) {
  21 + // closing side comment box
  22 + $("div.side-comment").hide();
  23 + }
  24 + });
  25 +
33 26 setPlusIfZeroComments($);
34 27 $('.display-comment-form').unbind();
35 28 $('.display-comment-form').click(function(){
... ... @@ -41,15 +34,8 @@ jQuery(document).ready(function($) {
41 34 });
42 35  
43 36 $('#cancel-comment').die();
44   - $('#cancel-comment').live("click", function(){
45   - var $button = $(this);
46   - showBox($button.parents('.post_comment_box'));
47   - show_display_comment_button();
48   - var page_comment_form = $button.parents('.page-comment-form');
49   - page_comment_form.find('.errorExplanation').remove();
50   - $(this).closest("textarea[name^='comment'").text("");
51   - $(this).closest("div[class^='side-comment']").hide();
52   - return false;
  37 + $(document.body).on("click", '#cancel-comment', function(){
  38 + $("div.side-comment").hide();
53 39 });
54 40  
55 41 function showBox(div){
... ... @@ -69,7 +55,6 @@ jQuery(document).ready(function($) {
69 55 <div align="center" class="triangle-right" >Comentar</div>\
70 56 </a>');
71 57  
72   -
73 58  
74 59 $('.side-comments-counter').click(function(){
75 60 var paragraphId = $(this).data('paragraph');
... ... @@ -86,8 +71,6 @@ jQuery(document).ready(function($) {
86 71 }).done(function() {
87 72 var button = $('#page-comment-form-' + paragraphId + ' a').get(0);
88 73 button.click();
89   - alignSideComments(paragraphId);
90   - hideUndesiredStuff($);
91 74 });
92 75 });
93 76  
... ... @@ -105,21 +88,9 @@ jQuery(document).ready(function($) {
105 88 }).done(function() {
106 89 var button = $('#page-comment-form-' + paragraphId + ' a').get(0);
107 90 button.click();
108   -
109   - alignSideComments(paragraphId);
110   - hideUndesiredStuff($);
111 91 });
112 92 });
113 93  
114   - function alignSideComments(paragraphId){
115   - $('.comments_list_toggle_paragraph_' + paragraphId).css('background','#FFFFFF');
116   - $('label[for|=comment_title]').hide();
117   - $('label[for|=comment_body]').css({top: -30, left: +20, position:'relative'});
118   - $('.comment_form p').hide();
119   - $('.comments_list_toggle_paragraph_' + paragraphId).width('250px');
120   - $('.required-field').removeClass("required-field");
121   - }
122   -
123 94 function hideAllCommentsExcept(clickedParagraph){
124 95 $(".side-comment").each(function(){
125 96 paragraph = $(this).data('paragraph');
... ... @@ -152,7 +123,7 @@ jQuery(document).ready(function($) {
152 123 rootElement.innerHTML = lastParagraph[paragraphId];
153 124 }
154 125 });
155   -
  126 +
156 127 function getSelectionText() {
157 128 var text = "";
158 129 if (window.getSelection) {
... ... @@ -199,7 +170,7 @@ jQuery(document).ready(function($) {
199 170 lastSelectedArea[paragraphId] = selected_area;
200 171 form = $('#page-comment-form-' + paragraphId).find('form');
201 172 if (form.find('input.selected_area').length === 0){
202   - jQuery('<input>').attr({
  173 + $('<input>').attr({
203 174 class: 'selected_area',
204 175 type: 'hidden',
205 176 name: 'comment[comment_paragraph_selected_area]',
... ... @@ -231,8 +202,6 @@ jQuery(document).ready(function($) {
231 202 }).done(function() {
232 203 var button = $('#page-comment-form-' + comment_id + ' a').get(0)
233 204 button.click();
234   - hideUndesiredStuff($);
235   - //alignSideComments(paragraphId);
236 205 });
237 206 }
238 207  
... ... @@ -271,31 +240,21 @@ jQuery(document).ready(function($) {
271 240 sel.removeAllRanges();
272 241 }
273 242 });
274   -}); // End of jQuery(document).ready(function($)
275   -
276   -//Seens that this code is not beeing used anymore
277 243  
278   -function toggleParagraph(paragraph) {
279   - var div = jQuery('div.comments_list_toggle_paragraph_'+paragraph);
280   - var visible = div.is(':visible');
281   - if(!visible)
282   - jQuery('div.comment-paragraph-loading-' + paragraph).addClass('comment-button-loading');
283   - div.toggle('fast');
284   - return visible;
285   -}
286   -
287   -function loadCompleted(paragraph) {
288   - jQuery('div.comment-paragraph-loading-'+paragraph).removeClass('comment-button-loading')
289   - if(comment_paragraph_anchor) {
290   - jQuery.scrollTo(jQuery(comment_paragraph_anchor));
291   - comment_paragraph_anchor = null;
  244 + function toggleParagraph(paragraph) {
  245 + var div = $('div.comments_list_toggle_paragraph_'+paragraph);
  246 + var visible = div.is(':visible');
  247 + if(!visible)
  248 + $('div.comment-paragraph-loading-' + paragraph).addClass('comment-button-loading');
  249 + div.toggle('fast');
  250 + return visible;
292 251 }
293   -}
294 252  
295   -jQuery(document).keyup(function(e) {
296   - // on press ESC key...
297   - if (e.which == 27) {
298   - // closing side comment box
299   - side_comment_box_opened = jQuery("div.side-comment").hide();
  253 + function loadCompleted(paragraph) {
  254 + $('div.comment-paragraph-loading-'+paragraph).removeClass('comment-button-loading')
  255 + if(comment_paragraph_anchor) {
  256 + $.scrollTo($(comment_paragraph_anchor));
  257 + comment_paragraph_anchor = null;
  258 + }
300 259 }
301 260 });
... ...
plugins/comment_paragraph/public/style.css
... ... @@ -191,3 +191,15 @@ div[class^=&#39;comment-paragraph-loading-&#39;] {
191 191 width: 75%;
192 192 height: auto;
193 193 }
  194 +#article .side-comment .article-comment .comment-details > h4 {
  195 + display: none;
  196 +}
  197 +.side-comment .formlabel[for='comment_body'] {
  198 + display: none;
  199 +}
  200 +.side-comment > div > div {
  201 + background: #FFFFFF;
  202 +}
  203 +.side-comment .comment_form p {
  204 + display: none;
  205 +}
... ...