From 91bebb91b0eb4b677e486bfd041ea5d9032ae462 Mon Sep 17 00:00:00 2001 From: Francisco Marcelo de Araújo Lima Júnior Date: Wed, 16 Apr 2014 09:46:43 -0300 Subject: [PATCH] #community dashboard - fixes --- plugins/community_hub/lib/community_hub_plugin/hub.rb | 4 ++++ plugins/community_hub/public/javascripts/community_hub.js | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------- plugins/community_hub/public/style.css | 30 ++++++++++++++++++++++++++++++ plugins/community_hub/views/community_hub_plugin_public/_mediation_comment_form.rhtml | 5 +++-- plugins/community_hub/views/content_viewer/hub.rhtml | 2 ++ 5 files changed, 91 insertions(+), 25 deletions(-) diff --git a/plugins/community_hub/lib/community_hub_plugin/hub.rb b/plugins/community_hub/lib/community_hub_plugin/hub.rb index 5d5c30d..f768107 100644 --- a/plugins/community_hub/lib/community_hub_plugin/hub.rb +++ b/plugins/community_hub/lib/community_hub_plugin/hub.rb @@ -18,6 +18,10 @@ class CommunityHubPlugin::Hub < Folder hub.mediators = [hub.author.id] end + def notify_comments + false + end + def self.icon_name(article = nil) 'community-hub' end diff --git a/plugins/community_hub/public/javascripts/community_hub.js b/plugins/community_hub/public/javascripts/community_hub.js index be4c696..b748d1c 100644 --- a/plugins/community_hub/public/javascripts/community_hub.js +++ b/plugins/community_hub/public/javascripts/community_hub.js @@ -2,39 +2,66 @@ var latest_post_id = 0; var oldest_post_id = 0; live_scroll_position = 0; +function clearLoadingMediationCommentSignal(mediation) { + jQuery(".loading-mediation-comment").filter("#" + mediation).removeClass("loading-signal-error"); + jQuery(".loading-mediation-comment").filter("#" + mediation).removeClass("loading-signal-done"); +} + +function clearLoadingMessageSignal() { + jQuery("#loading-message").removeClass("loading-signal-error"); + jQuery("#loading-message").removeClass("loading-signal-done"); +} + +function clearLoadingMediationSignal() { + jQuery("#loading-mediation").removeClass("loading-signal-error"); + jQuery("#loading-mediation").removeClass("loading-signal-done"); +} + function toogle_mediation_comments(mediation) { jQuery("#mediation-comment-list-" + mediation ).toggle(); jQuery("#mediation-comment-form-" + mediation ).toggle(); } -function hub_open_loading(button) { - var html = '
' + - '' + - '
'; +function new_mediation_comment(button, mediation) { + var form = jQuery(button).parents("form"); - //$('.hub .form .submit').after(html); - jQuery(button).after(html); - jQuery('#hub-loading').fadeIn('slow'); -} + jQuery(".loading-mediation-comment").filter("#" + mediation).addClass("loading-signal-processing"); + jQuery.post(form.attr("action"), form.serialize(), function(data) { + jQuery(".loading-mediation-comment").filter("#" + mediation).removeClass("loading-signal-processing"); + if (data.ok) { + jQuery(".hub .form #message_body").val(''); + jQuery(".loading-mediation-comment").filter("#" + mediation).addClass("loading-signal-done"); + setTimeout(function(){ + clearLoadingMediationCommentSignal(mediation); + }, 3000); + } + else { + jQuery(".loading-mediation-comment").filter("#" + mediation).addClass("loading-signal-error"); + setTimeout(clearLoadingMessageSignal, 3000); + } + }, 'json'); -function hub_close_loading() { - jQuery('#hub-loading').fadeOut('slow', function() { - jQuery('#hub-loading').remove(); - }); } function new_message(button) { var form = jQuery(button).parents("form"); - //hub_open_loading(); + jQuery("#loading-message").addClass("loading-signal-processing"); + jQuery.post(form.attr("action"), form.serialize(), function(data) { + jQuery("#loading-message").removeClass("loading-signal-processing"); if (data.ok) { - jQuery("#message_body").val(''); + jQuery(".hub .form #message_body").val(''); + jQuery("#loading-message").addClass("loading-signal-done"); + setTimeout(clearLoadingMessageSignal, 3000); + } + else { + jQuery("#loading-message").addClass("loading-signal-error"); + setTimeout(clearLoadingMessageSignal, 3000); } - //hub_close_loading(); }, 'json'); } @@ -43,23 +70,25 @@ function new_message(button) { function new_mediation(button) { var form = jQuery(button).parents("form"); - //hub_open_loading(); + jQuery("#loading-mediation").addClass("loading-signal-processing"); + tinymce.triggerSave(); jQuery.post(form.attr("action"), form.serialize(), function(data) { + jQuery("#loading-mediation").removeClass("loading-signal-processing"); if (data.ok) { + jQuery("#loading-mediation").addClass("loading-signal-done"); tinymce.get('article_body').setContent(''); + setTimeout(clearLoadingMediationSignal, 3000); + } + else { + jQuery("#loading-mediation").addClass("loading-signal-error"); + setTimeout(clearLoadingMediationSignal, 3000); } - //hub_close_loading(); }, 'json'); } -function toogleAutoScrolling() { - alert(jQuery("#auto_scrolling").attr('checked')); -} - - function promote_user(user_id) { var hub_id = jQuery(".hub").attr('id'); @@ -201,4 +230,4 @@ jQuery(document).ready(function() { setTimeout(update_live_stream, 5000); setTimeout(update_mediations, 7000); -}); \ No newline at end of file +}); diff --git a/plugins/community_hub/public/style.css b/plugins/community_hub/public/style.css index 74e330a..405499a 100644 --- a/plugins/community_hub/public/style.css +++ b/plugins/community_hub/public/style.css @@ -367,3 +367,33 @@ textarea#message_body { width: 80%; } +.hub #loading-message, +.hub #loading-mediation { + width: 16px; + height: 16px; + display: inline-block; + float: right; + margin-top: 17px; + margin-right: 270px; +} + +.hub .loading-mediation-comment { + width: 16px; + height: 16px; + display: inline-block; + float: right; + margin-top: 16px; + margin-right: 260px; +} + +.loading-signal-done { + background-image: url(/plugins/community_hub/icons/hub-sverde-a.png); +} + +.loading-signal-error { + background-image: url(/plugins/community_hub/icons/hub-svermelho-a.png); +} + +.loading-signal-processing { + background-image: url(/plugins/community_hub/icons/hub-samarelo.gif); +} diff --git a/plugins/community_hub/views/community_hub_plugin_public/_mediation_comment_form.rhtml b/plugins/community_hub/views/community_hub_plugin_public/_mediation_comment_form.rhtml index f8da03b..fc98a4d 100644 --- a/plugins/community_hub/views/community_hub_plugin_public/_mediation_comment_form.rhtml +++ b/plugins/community_hub/views/community_hub_plugin_public/_mediation_comment_form.rhtml @@ -8,5 +8,6 @@ <%= f.text_area(:body, :rows => 4, :placeholder => _('Type your comment here')) %> - <%= submit_button('add', _('Post'), :onclick => 'new_message(this); return false;') %> -<% end %> \ No newline at end of file + <%= submit_button('add', _('Post'), :onclick => "new_mediation_comment(this,#{mediation.id}); return false;") %> + +<% end %> diff --git a/plugins/community_hub/views/content_viewer/hub.rhtml b/plugins/community_hub/views/content_viewer/hub.rhtml index bf2667b..32d3d43 100644 --- a/plugins/community_hub/views/content_viewer/hub.rhtml +++ b/plugins/community_hub/views/content_viewer/hub.rhtml @@ -43,6 +43,7 @@
<%= f.text_area :body, :style => "width: 99%;", :cols => "38", :rows => "10", :placeholder => _("Type your message here") %> <%= submit_button('add', _('Post'), :onclick => 'new_message(this); return false;') %> + <% end %> <% else %> @@ -59,6 +60,7 @@ <%= f.hidden_field :parent_id, :value => @page.id %> <%= f.text_area :body, :style => "width: 100%;", :class => "mceEditor" %> <%= submit_button('add', _('Post'), :onclick => 'new_mediation(this); return false;') %> + <% end %> <% end %> -- libgit2 0.21.2