Commit 04d21bc24bddf81d4c6ec2b6d0dbfc65429ed371
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge branch 'AI3074-community_dashboard' of gitlab.com:participa/noosfero into …
…AI3074-community_dashboard
Showing
7 changed files
with
125 additions
and
55 deletions
Show diff stats
plugins/community_hub/lib/community_hub_plugin/hub.rb
plugins/community_hub/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("#mediation-comment-form-" + mediation + " textarea").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'); |
... | ... | @@ -88,7 +117,7 @@ function pin_message(post_id) { |
88 | 117 | type: 'get', |
89 | 118 | dataType: 'json', |
90 | 119 | data: { message: post_id, hub: hub_id }, |
91 | - success: function(data) { | |
120 | + success: function(data) { | |
92 | 121 | }, |
93 | 122 | error: function(ajax, stat, errorThrown) { |
94 | 123 | console.log(stat); |
... | ... | @@ -108,8 +137,6 @@ function update_mediation_comments(mediation) { |
108 | 137 | var latest_post_id = jQuery("#mediation-comment-list-" + mediation + " li.mediation-comment").last().attr('id'); |
109 | 138 | } |
110 | 139 | |
111 | - //console.log(latest_post_id); | |
112 | - | |
113 | 140 | jQuery.ajax({ |
114 | 141 | url: '/plugin/community_hub/public/newer_mediation_comment', |
115 | 142 | type: 'get', |
... | ... | @@ -117,6 +144,7 @@ function update_mediation_comments(mediation) { |
117 | 144 | success: function(data) { |
118 | 145 | if (data.trim().length > 0) { |
119 | 146 | jQuery("#mediation-comment-list-" + mediation + "").append(data); |
147 | + jQuery("#mediation-comment-total-" + mediation).html(jQuery("#mediation-comment-list-" + mediation + " li.mediation-comment").size()); | |
120 | 148 | } |
121 | 149 | }, |
122 | 150 | error: function(ajax, stat, errorThrown) { |
... | ... | @@ -201,4 +229,4 @@ jQuery(document).ready(function() { |
201 | 229 | |
202 | 230 | setTimeout(update_live_stream, 5000); |
203 | 231 | setTimeout(update_mediations, 7000); |
204 | -}); | |
205 | 232 | \ No newline at end of file |
233 | +}); | ... | ... |
plugins/community_hub/public/style.css
... | ... | @@ -78,7 +78,7 @@ clear: both; |
78 | 78 | font-weight: bold; |
79 | 79 | float: left; |
80 | 80 | display: inline-block; |
81 | - line-height: 20px; | |
81 | + line-height: 16px; | |
82 | 82 | margin-right: 5px; |
83 | 83 | } |
84 | 84 | |
... | ... | @@ -107,6 +107,7 @@ clear: both; |
107 | 107 | |
108 | 108 | .hub .mediation-bar ul li.pin{ |
109 | 109 | height: 25px; |
110 | + margin-right: 10px; | |
110 | 111 | } |
111 | 112 | |
112 | 113 | .hub .remove{} |
... | ... | @@ -153,6 +154,19 @@ clear: both; |
153 | 154 | margin-bottom: 2px; |
154 | 155 | } |
155 | 156 | |
157 | +.hub .mediation-comment-form { | |
158 | + margin-left: 70px; | |
159 | + margin-top: 10px; | |
160 | +} | |
161 | + | |
162 | +.hub input.button.with-text.icon-add.submit{ | |
163 | + display: block; | |
164 | +} | |
165 | + | |
166 | +.hub ul#mediation-posts .post { | |
167 | + padding-bottom: 10px; | |
168 | +} | |
169 | + | |
156 | 170 | /**/ |
157 | 171 | |
158 | 172 | .hub .live { |
... | ... | @@ -367,3 +381,35 @@ textarea#message_body { |
367 | 381 | width: 80%; |
368 | 382 | } |
369 | 383 | |
384 | +.hub #loading-message, | |
385 | +.hub #loading-mediation { | |
386 | + width: 16px; | |
387 | + height: 16px; | |
388 | + display: inline-block; | |
389 | + float: right; | |
390 | + margin-top: 17px; | |
391 | + margin-right: 270px; | |
392 | +} | |
393 | + | |
394 | +.hub .loading-mediation-comment { | |
395 | + width: 16px; | |
396 | + height: 16px; | |
397 | + display: inline-block; | |
398 | + float: right; | |
399 | + margin-top: 16px; | |
400 | + margin-right: 260px; | |
401 | +} | |
402 | + | |
403 | +.loading-signal-done { | |
404 | + background-image: url(/plugins/community_hub/icons/hub-sverde-a.png); | |
405 | +} | |
406 | + | |
407 | +.loading-signal-error { | |
408 | + background-image: url(/plugins/community_hub/icons/hub-svermelho-a.png); | |
409 | +} | |
410 | + | |
411 | +.loading-signal-processing { | |
412 | + background-image: url(/plugins/community_hub/icons/hub-samarelo.gif); | |
413 | +} | |
414 | + | |
415 | + | ... | ... |
plugins/community_hub/views/community_hub_plugin_public/_mediation.rhtml
... | ... | @@ -6,25 +6,25 @@ |
6 | 6 | <li class="time"><%= post_time(mediation.created_at) %></li> |
7 | 7 | <li class="avatar"><%= image_tag(profile_icon(mediation.author, :minor)) %></li> |
8 | 8 | <li class="message"><span class="author"><%= mediation.author_name %>:</span> <%= mediation.body %></li> |
9 | - | |
9 | + | |
10 | 10 | <% if mediator?(hub) %> |
11 | 11 | <li class="mediation-bar"> |
12 | 12 | |
13 | 13 | <ul> |
14 | - | |
14 | + | |
15 | 15 | <li class="promote"> |
16 | - <% if !promoted?(hub, mediation.author.id) %> | |
16 | + <% if promoted?(hub, mediation.author.id) %> | |
17 | 17 | <a id="<%= mediation.id %>" href="#" onclick="promote_user(<%= mediation.author.id %>); return false;"> |
18 | - <img class="promoted" src="/plugins/community_hub/icons/hub-promote-icon.png" /> | |
18 | + <img class="promoted" src="/plugins/community_hub/icons/hub-promote-icon.png" title="<%= _("User promoted") %>" /> | |
19 | 19 | </a> |
20 | 20 | <% else %> |
21 | - <img class="not-promoted" src="/plugins/community_hub/icons/hub-not-promote-icon.png" /> | |
21 | + <img class="not-promoted" src="/plugins/community_hub/icons/hub-not-promote-icon.png" title="<%= _("User not promoted") %>" /> | |
22 | 22 | <% end %> |
23 | 23 | </li> |
24 | 24 | |
25 | 25 | <% if pinned_mediation?(hub, mediation.id) %> |
26 | 26 | <li class="pin"> |
27 | - <img class="pinned" src="/plugins/community_hub/icons/hub-not-pinned-icon.png" /> | |
27 | + <img class="pinned" src="/plugins/community_hub/icons/hub-not-pinned-icon.png" title="<%= _("Message pinned")%>" /> | |
28 | 28 | </li> |
29 | 29 | <% end %> |
30 | 30 | |
... | ... | @@ -38,16 +38,16 @@ |
38 | 38 | <% total_mediation_comments = mediation.comments.count %> |
39 | 39 | |
40 | 40 | <span class="comment-count"> |
41 | - <%= link_to(_( "#{total_mediation_comments} Comments" ) , '#', | |
42 | - :class => 'display-comment-form', | |
43 | - :id => 'top-post-comment-button', | |
41 | + <%= link_to(_( "<span id='mediation-comment-total-#{mediation.id}'>#{total_mediation_comments}</span> Comments" ) , '#', | |
42 | + :class => 'display-comment-form', | |
43 | + :id => 'top-post-comment-button', | |
44 | 44 | :onclick => "toogle_mediation_comments(#{mediation.id}); return false;") %> |
45 | 45 | </span> |
46 | 46 | |
47 | 47 | <script type="text/javascript"> |
48 | 48 | setTimeout(function() { update_mediation_comments('<%= mediation.id %>')}, 5000); |
49 | 49 | </script> |
50 | - | |
50 | + | |
51 | 51 | <ul id="mediation-comment-list-<%=mediation.id%>" class="mediation-comment-list" style="display:none;"> |
52 | 52 | <% if mediation.accept_comments? && mediation.comments.count > 0 %> |
53 | 53 | <%= render :partial => 'community_hub_plugin_public/mediation_comment', :collection => mediation.comments %> |
... | ... | @@ -60,15 +60,15 @@ |
60 | 60 | :locals => { |
61 | 61 | :hub => hub, |
62 | 62 | :mediation => mediation, |
63 | - :comment => Comment.new, | |
63 | + :comment => Comment.new, | |
64 | 64 | :url => { |
65 | - :controller => :comment, | |
65 | + :controller => :comment, | |
66 | 66 | :action => :create |
67 | - }, | |
68 | - :display_link => true, | |
67 | + }, | |
68 | + :display_link => true, | |
69 | 69 | :cancel_triggers_hide => true |
70 | 70 | } %> |
71 | 71 | </div> |
72 | 72 | <% end %> |
73 | 73 | |
74 | -</li> | |
75 | 74 | \ No newline at end of file |
75 | +</li> | ... | ... |
plugins/community_hub/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 %> | ... | ... |
plugins/community_hub/views/community_hub_plugin_public/_post.rhtml
... | ... | @@ -16,17 +16,7 @@ |
16 | 16 | |
17 | 17 | <% if mediator?(hub) && post.title != 'hub-message-twitter' && post.title != 'hub-message-facebook' %> |
18 | 18 | <li class="mediation-bar"> |
19 | - | |
20 | 19 | <ul> |
21 | - <li class="promote"> | |
22 | - <% if promoted?(hub, post.author.id) == 'promoted' %> | |
23 | - <a id="<%= post.id %>" href="#" onclick="pin_message(<%= post.id %>); return false;"> | |
24 | - <img class="promoted" src="/plugins/community_hub/icons/hub-promote-icon.png" /> | |
25 | - </a> | |
26 | - <% else %> | |
27 | - <img class="not-promoted" src="/plugins/community_hub/icons/hub-not-promote-icon.png" /> | |
28 | - <% end %> | |
29 | - </li> | |
30 | 20 | <li class="pin"> |
31 | 21 | <% if !pinned_message?(hub, post.id) %> |
32 | 22 | <a id="<%= post.id %>" href="#" onclick="pin_message(<%= post.id %>); return false;"> |
... | ... | @@ -37,7 +27,6 @@ |
37 | 27 | <% end %> |
38 | 28 | </li> |
39 | 29 | </ul> |
40 | - | |
41 | 30 | </li> |
42 | 31 | <% end %> |
43 | 32 | ... | ... |
plugins/community_hub/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 %> | ... | ... |