Commit 91bebb91b0eb4b677e486bfd041ea5d9032ae462

Authored by Francisco Marcelo de Araújo Lima Júnior
1 parent 4a11447a

#community dashboard - fixes

plugins/community_hub/lib/community_hub_plugin/hub.rb
@@ -18,6 +18,10 @@ class CommunityHubPlugin::Hub < Folder @@ -18,6 +18,10 @@ class CommunityHubPlugin::Hub < Folder
18 hub.mediators = [hub.author.id] 18 hub.mediators = [hub.author.id]
19 end 19 end
20 20
  21 + def notify_comments
  22 + false
  23 + end
  24 +
21 def self.icon_name(article = nil) 25 def self.icon_name(article = nil)
22 'community-hub' 26 'community-hub'
23 end 27 end
plugins/community_hub/public/javascripts/community_hub.js
@@ -2,39 +2,66 @@ var latest_post_id = 0; @@ -2,39 +2,66 @@ var latest_post_id = 0;
2 var oldest_post_id = 0; 2 var oldest_post_id = 0;
3 live_scroll_position = 0; 3 live_scroll_position = 0;
4 4
  5 +function clearLoadingMediationCommentSignal(mediation) {
  6 + jQuery(".loading-mediation-comment").filter("#" + mediation).removeClass("loading-signal-error");
  7 + jQuery(".loading-mediation-comment").filter("#" + mediation).removeClass("loading-signal-done");
  8 +}
  9 +
  10 +function clearLoadingMessageSignal() {
  11 + jQuery("#loading-message").removeClass("loading-signal-error");
  12 + jQuery("#loading-message").removeClass("loading-signal-done");
  13 +}
  14 +
  15 +function clearLoadingMediationSignal() {
  16 + jQuery("#loading-mediation").removeClass("loading-signal-error");
  17 + jQuery("#loading-mediation").removeClass("loading-signal-done");
  18 +}
  19 +
5 function toogle_mediation_comments(mediation) { 20 function toogle_mediation_comments(mediation) {
6 jQuery("#mediation-comment-list-" + mediation ).toggle(); 21 jQuery("#mediation-comment-list-" + mediation ).toggle();
7 jQuery("#mediation-comment-form-" + mediation ).toggle(); 22 jQuery("#mediation-comment-form-" + mediation ).toggle();
8 } 23 }
9 24
10 25
11 -function hub_open_loading(button) {  
12 - var html = '<div id="hub-loading">' +  
13 - '<img src="/images/loading-small.gif" />' +  
14 - '</div>'; 26 +function new_mediation_comment(button, mediation) {
  27 + var form = jQuery(button).parents("form");
15 28
16 - //$('.hub .form .submit').after(html);  
17 - jQuery(button).after(html);  
18 - jQuery('#hub-loading').fadeIn('slow');  
19 -} 29 + jQuery(".loading-mediation-comment").filter("#" + mediation).addClass("loading-signal-processing");
20 30
  31 + jQuery.post(form.attr("action"), form.serialize(), function(data) {
  32 + jQuery(".loading-mediation-comment").filter("#" + mediation).removeClass("loading-signal-processing");
  33 + if (data.ok) {
  34 + jQuery(".hub .form #message_body").val('');
  35 + jQuery(".loading-mediation-comment").filter("#" + mediation).addClass("loading-signal-done");
  36 + setTimeout(function(){
  37 + clearLoadingMediationCommentSignal(mediation);
  38 + }, 3000);
  39 + }
  40 + else {
  41 + jQuery(".loading-mediation-comment").filter("#" + mediation).addClass("loading-signal-error");
  42 + setTimeout(clearLoadingMessageSignal, 3000);
  43 + }
  44 + }, 'json');
21 45
22 -function hub_close_loading() {  
23 - jQuery('#hub-loading').fadeOut('slow', function() {  
24 - jQuery('#hub-loading').remove();  
25 - });  
26 } 46 }
27 47
28 48
29 function new_message(button) { 49 function new_message(button) {
30 var form = jQuery(button).parents("form"); 50 var form = jQuery(button).parents("form");
31 51
32 - //hub_open_loading(); 52 + jQuery("#loading-message").addClass("loading-signal-processing");
  53 +
33 jQuery.post(form.attr("action"), form.serialize(), function(data) { 54 jQuery.post(form.attr("action"), form.serialize(), function(data) {
  55 + jQuery("#loading-message").removeClass("loading-signal-processing");
34 if (data.ok) { 56 if (data.ok) {
35 - jQuery("#message_body").val(''); 57 + jQuery(".hub .form #message_body").val('');
  58 + jQuery("#loading-message").addClass("loading-signal-done");
  59 + setTimeout(clearLoadingMessageSignal, 3000);
  60 + }
  61 + else {
  62 + jQuery("#loading-message").addClass("loading-signal-error");
  63 + setTimeout(clearLoadingMessageSignal, 3000);
36 } 64 }
37 - //hub_close_loading();  
38 }, 'json'); 65 }, 'json');
39 66
40 } 67 }
@@ -43,23 +70,25 @@ function new_message(button) { @@ -43,23 +70,25 @@ function new_message(button) {
43 function new_mediation(button) { 70 function new_mediation(button) {
44 var form = jQuery(button).parents("form"); 71 var form = jQuery(button).parents("form");
45 72
46 - //hub_open_loading(); 73 + jQuery("#loading-mediation").addClass("loading-signal-processing");
  74 +
47 tinymce.triggerSave(); 75 tinymce.triggerSave();
48 jQuery.post(form.attr("action"), form.serialize(), function(data) { 76 jQuery.post(form.attr("action"), form.serialize(), function(data) {
  77 + jQuery("#loading-mediation").removeClass("loading-signal-processing");
49 if (data.ok) { 78 if (data.ok) {
  79 + jQuery("#loading-mediation").addClass("loading-signal-done");
50 tinymce.get('article_body').setContent(''); 80 tinymce.get('article_body').setContent('');
  81 + setTimeout(clearLoadingMediationSignal, 3000);
  82 + }
  83 + else {
  84 + jQuery("#loading-mediation").addClass("loading-signal-error");
  85 + setTimeout(clearLoadingMediationSignal, 3000);
51 } 86 }
52 - //hub_close_loading();  
53 }, 'json'); 87 }, 'json');
54 88
55 } 89 }
56 90
57 91
58 -function toogleAutoScrolling() {  
59 - alert(jQuery("#auto_scrolling").attr('checked'));  
60 -}  
61 -  
62 -  
63 function promote_user(user_id) { 92 function promote_user(user_id) {
64 93
65 var hub_id = jQuery(".hub").attr('id'); 94 var hub_id = jQuery(".hub").attr('id');
@@ -201,4 +230,4 @@ jQuery(document).ready(function() { @@ -201,4 +230,4 @@ jQuery(document).ready(function() {
201 230
202 setTimeout(update_live_stream, 5000); 231 setTimeout(update_live_stream, 5000);
203 setTimeout(update_mediations, 7000); 232 setTimeout(update_mediations, 7000);
204 -});  
205 \ No newline at end of file 233 \ No newline at end of file
  234 +});
plugins/community_hub/public/style.css
@@ -367,3 +367,33 @@ textarea#message_body { @@ -367,3 +367,33 @@ textarea#message_body {
367 width: 80%; 367 width: 80%;
368 } 368 }
369 369
  370 +.hub #loading-message,
  371 +.hub #loading-mediation {
  372 + width: 16px;
  373 + height: 16px;
  374 + display: inline-block;
  375 + float: right;
  376 + margin-top: 17px;
  377 + margin-right: 270px;
  378 +}
  379 +
  380 +.hub .loading-mediation-comment {
  381 + width: 16px;
  382 + height: 16px;
  383 + display: inline-block;
  384 + float: right;
  385 + margin-top: 16px;
  386 + margin-right: 260px;
  387 +}
  388 +
  389 +.loading-signal-done {
  390 + background-image: url(/plugins/community_hub/icons/hub-sverde-a.png);
  391 +}
  392 +
  393 +.loading-signal-error {
  394 + background-image: url(/plugins/community_hub/icons/hub-svermelho-a.png);
  395 +}
  396 +
  397 +.loading-signal-processing {
  398 + background-image: url(/plugins/community_hub/icons/hub-samarelo.gif);
  399 +}
plugins/community_hub/views/community_hub_plugin_public/_mediation_comment_form.rhtml
@@ -8,5 +8,6 @@ @@ -8,5 +8,6 @@
8 <%= f.text_area(:body, 8 <%= f.text_area(:body,
9 :rows => 4, 9 :rows => 4,
10 :placeholder => _('Type your comment here')) %> 10 :placeholder => _('Type your comment here')) %>
11 - <%= submit_button('add', _('Post'), :onclick => 'new_message(this); return false;') %>  
12 -<% end %>  
13 \ No newline at end of file 11 \ No newline at end of file
  12 + <%= submit_button('add', _('Post'), :onclick => "new_mediation_comment(this,#{mediation.id}); return false;") %>
  13 + <span id="<%=mediation.id%>" class="loading-mediation-comment"></span>
  14 +<% end %>
plugins/community_hub/views/content_viewer/hub.rhtml
@@ -43,6 +43,7 @@ @@ -43,6 +43,7 @@
43 <br /> 43 <br />
44 <%= f.text_area :body, :style => "width: 99%;", :cols => "38", :rows => "10", :placeholder => _("Type your message here") %> 44 <%= f.text_area :body, :style => "width: 99%;", :cols => "38", :rows => "10", :placeholder => _("Type your message here") %>
45 <%= submit_button('add', _('Post'), :onclick => 'new_message(this); return false;') %> 45 <%= submit_button('add', _('Post'), :onclick => 'new_message(this); return false;') %>
  46 + <span id="loading-message"></span>
46 <% end %> 47 <% end %>
47 48
48 <% else %> 49 <% else %>
@@ -59,6 +60,7 @@ @@ -59,6 +60,7 @@
59 <%= f.hidden_field :parent_id, :value => @page.id %> 60 <%= f.hidden_field :parent_id, :value => @page.id %>
60 <%= f.text_area :body, :style => "width: 100%;", :class => "mceEditor" %> 61 <%= f.text_area :body, :style => "width: 100%;", :class => "mceEditor" %>
61 <%= submit_button('add', _('Post'), :onclick => 'new_mediation(this); return false;') %> 62 <%= submit_button('add', _('Post'), :onclick => 'new_mediation(this); return false;') %>
  63 + <span id="loading-mediation"></span>
62 <% end %> 64 <% end %>
63 65
64 <% end %> 66 <% end %>