Commit 0505a73e86760f214c9f964c9a2703c0ded19e81

Authored by Francisco Marcelo de Araújo Lima Júnior
1 parent fe641774
Exists in master

#community dashboard - fixes

lib/community_hub_plugin/hub.rb
... ... @@ -18,6 +18,10 @@ class CommunityHubPlugin::Hub < Folder
18 18 hub.mediators = [hub.author.id]
19 19 end
20 20  
  21 + def notify_comments
  22 + false
  23 + end
  24 +
21 25 def self.icon_name(article = nil)
22 26 'community-hub'
23 27 end
... ...
public/javascripts/community_hub.js
... ... @@ -2,39 +2,66 @@ var latest_post_id = 0;
2 2 var oldest_post_id = 0;
3 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 20 function toogle_mediation_comments(mediation) {
6 21 jQuery("#mediation-comment-list-" + mediation ).toggle();
7 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 49 function new_message(button) {
30 50 var form = jQuery(button).parents("form");
31 51  
32   - //hub_open_loading();
  52 + jQuery("#loading-message").addClass("loading-signal-processing");
  53 +
33 54 jQuery.post(form.attr("action"), form.serialize(), function(data) {
  55 + jQuery("#loading-message").removeClass("loading-signal-processing");
34 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 65 }, 'json');
39 66  
40 67 }
... ... @@ -43,23 +70,25 @@ function new_message(button) {
43 70 function new_mediation(button) {
44 71 var form = jQuery(button).parents("form");
45 72  
46   - //hub_open_loading();
  73 + jQuery("#loading-mediation").addClass("loading-signal-processing");
  74 +
47 75 tinymce.triggerSave();
48 76 jQuery.post(form.attr("action"), form.serialize(), function(data) {
  77 + jQuery("#loading-mediation").removeClass("loading-signal-processing");
49 78 if (data.ok) {
  79 + jQuery("#loading-mediation").addClass("loading-signal-done");
50 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 87 }, 'json');
54 88  
55 89 }
56 90  
57 91  
58   -function toogleAutoScrolling() {
59   - alert(jQuery("#auto_scrolling").attr('checked'));
60   -}
61   -
62   -
63 92 function promote_user(user_id) {
64 93  
65 94 var hub_id = jQuery(".hub").attr('id');
... ... @@ -201,4 +230,4 @@ jQuery(document).ready(function() {
201 230  
202 231 setTimeout(update_live_stream, 5000);
203 232 setTimeout(update_mediations, 7000);
204   -});
205 233 \ No newline at end of file
  234 +});
... ...
public/style.css
... ... @@ -367,3 +367,33 @@ textarea#message_body {
367 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 +}
... ...
views/community_hub_plugin_public/_mediation_comment_form.rhtml
... ... @@ -8,5 +8,6 @@
8 8 <%= f.text_area(:body,
9 9 :rows => 4,
10 10 :placeholder => _('Type your comment here')) %>
11   - <%= submit_button('add', _('Post'), :onclick => 'new_message(this); return false;') %>
12   -<% end %>
13 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 %>
... ...
views/content_viewer/hub.rhtml
... ... @@ -43,6 +43,7 @@
43 43 <br />
44 44 <%= f.text_area :body, :style => "width: 99%;", :cols => "38", :rows => "10", :placeholder => _("Type your message here") %>
45 45 <%= submit_button('add', _('Post'), :onclick => 'new_message(this); return false;') %>
  46 + <span id="loading-message"></span>
46 47 <% end %>
47 48  
48 49 <% else %>
... ... @@ -59,6 +60,7 @@
59 60 <%= f.hidden_field :parent_id, :value => @page.id %>
60 61 <%= f.text_area :body, :style => "width: 100%;", :class => "mceEditor" %>
61 62 <%= submit_button('add', _('Post'), :onclick => 'new_mediation(this); return false;') %>
  63 + <span id="loading-mediation"></span>
62 64 <% end %>
63 65  
64 66 <% end %>
... ...