Commit 4999ea989410acb78c405d823765c6fbab6e84a2

Authored by Francisco Marcelo de Araújo Lima Júnior
1 parent 3d405423

#community dashboard - fixes

plugins/community_hub/public/javascripts/community_hub.js
... ... @@ -89,144 +89,181 @@ function new_mediation(button) {
89 89 }
90 90  
91 91  
92   -function promote_user(user_id) {
93   -
94   - var hub_id = jQuery(".hub").attr('id');
95   -
96   - jQuery.ajax({
97   - url: '/plugin/community_hub/public/promote_user',
98   - type: 'get',
99   - dataType: 'json',
100   - data: { user: user_id, hub: hub_id },
101   - success: function(data) {
102   - },
103   - error: function(ajax, stat, errorThrown) {
104   - console.log(stat);
105   - }
106   - });
  92 +function promote_user(mediation, user_id) {
  93 +
  94 + if (confirm(DEFAULT_PROMOTE_QUESTION)) {
  95 +
  96 + var hub_id = jQuery(".hub").attr('id');
  97 +
  98 + jQuery.ajax({
  99 + url: '/plugin/community_hub/public/promote_user',
  100 + type: 'get',
  101 + dataType: 'json',
  102 + data: { user: user_id, hub: hub_id },
  103 + success: function(data) {
  104 + jQuery(".promote a").filter("#" + mediation).replaceWith( '<img class="promoted" src="/plugins/community_hub/icons/hub-not-promote-icon.png" title="User promoted">' );
  105 + },
  106 + error: function(ajax, stat, errorThrown) {
  107 + console.log(stat);
  108 + }
  109 + });
  110 +
  111 + }
107 112  
108 113 }
109 114  
110 115  
111 116 function pin_message(post_id) {
112 117  
113   - var hub_id = jQuery(".hub").attr('id');
114   -
115   - jQuery.ajax({
116   - url: '/plugin/community_hub/public/pin_message',
117   - type: 'get',
118   - dataType: 'json',
119   - data: { message: post_id, hub: hub_id },
120   - success: function(data) {
121   - },
122   - error: function(ajax, stat, errorThrown) {
123   - console.log(stat);
124   - }
125   - });
  118 + if (confirm(DEFAULT_PIN_QUESTION)) {
  119 +
  120 + var hub_id = jQuery(".hub").attr('id');
  121 +
  122 + jQuery.ajax({
  123 + url: '/plugin/community_hub/public/pin_message',
  124 + type: 'get',
  125 + dataType: 'json',
  126 + data: { message: post_id, hub: hub_id },
  127 + success: function(data) {
  128 + jQuery(".pin a").filter("#" + post_id).replaceWith( '<img class="pinned" src="/plugins/community_hub/icons/hub-not-pinned-icon.png" title="Message pinned">' );
  129 + },
  130 + error: function(ajax, stat, errorThrown) {
  131 + console.log(stat);
  132 + }
  133 + });
  134 +
  135 + }
126 136  
127 137 }
128 138  
129 139  
130 140 function update_mediation_comments(mediation) {
131   - var hub_id = jQuery(".hub").attr('id');
132 141  
133   - if (jQuery("#mediation-comment-list-" + mediation + " li").first().length == 0) {
134   - var latest_post_id = 0;
135   - }
136   - else {
137   - var latest_post_id = jQuery("#mediation-comment-list-" + mediation + " li.mediation-comment").last().attr('id');
138   - }
  142 + if (jQuery("#mediation-section.show").size() != 0) {
139 143  
140   - jQuery.ajax({
141   - url: '/plugin/community_hub/public/newer_mediation_comment',
142   - type: 'get',
143   - data: { latest_post: latest_post_id, mediation: mediation },
144   - success: function(data) {
145   - if (data.trim().length > 0) {
146   - jQuery("#mediation-comment-list-" + mediation + "").append(data);
147   - jQuery("#mediation-comment-total-" + mediation).html(jQuery("#mediation-comment-list-" + mediation + " li.mediation-comment").size());
148   - }
149   - },
150   - error: function(ajax, stat, errorThrown) {
151   - console.log(stat);
  144 + var hub_id = jQuery(".hub").attr('id');
  145 +
  146 + if (jQuery("#mediation-comment-list-" + mediation + " li").first().length == 0) {
  147 + var latest_post_id = 0;
  148 + }
  149 + else {
  150 + var latest_post_id = jQuery("#mediation-comment-list-" + mediation + " li.mediation-comment").last().attr('id');
152 151 }
153   - });
  152 +
  153 + jQuery.ajax({
  154 + url: '/plugin/community_hub/public/newer_mediation_comment',
  155 + type: 'get',
  156 + data: { latest_post: latest_post_id, mediation: mediation },
  157 + success: function(data) {
  158 + if (data.trim().length > 0) {
  159 + jQuery("#mediation-comment-list-" + mediation + "").append(data);
  160 + jQuery("#mediation-comment-total-" + mediation).html(jQuery("#mediation-comment-list-" + mediation + " li.mediation-comment").size());
  161 + }
  162 + },
  163 + error: function(ajax, stat, errorThrown) {
  164 + console.log(stat);
  165 + }
  166 + });
  167 +
  168 + }
154 169  
155 170 setTimeout(function() { update_mediation_comments(mediation); }, 5000);
156 171 }
157 172  
158 173  
159 174 function update_mediations() {
160   - var hub_id = jQuery(".hub").attr('id');
161 175  
162   - if (jQuery("#mediation-posts li").first().length == 0) {
163   - var latest_post_id = 0;
164   - }
165   - else {
166   - var latest_post_id = jQuery("#mediation-posts li").first().attr('id');
167   - }
  176 + if (jQuery("#mediation-section.show").size() != 0) {
168 177  
169   - //console.log(latest_post_id);
  178 + var hub_id = jQuery(".hub").attr('id');
170 179  
171   - jQuery.ajax({
172   - url: '/plugin/community_hub/public/newer_articles',
173   - type: 'get',
174   - data: { latest_post: latest_post_id, hub: hub_id },
175   - success: function(data) {
176   - if (data.trim().length > 0) {
177   - jQuery("#mediation-posts").prepend(data);
178   - }
179   - },
180   - error: function(ajax, stat, errorThrown) {
181   - console.log(stat);
  180 + if (jQuery("#mediation-posts li").first().length == 0) {
  181 + var latest_post_id = 0;
182 182 }
183   - });
  183 + else {
  184 + var latest_post_id = jQuery("#mediation-posts li").first().attr('id');
  185 + }
  186 +
  187 + jQuery.ajax({
  188 + url: '/plugin/community_hub/public/newer_articles',
  189 + type: 'get',
  190 + data: { latest_post: latest_post_id, hub: hub_id },
  191 + success: function(data) {
  192 + if (data.trim().length > 0) {
  193 + jQuery("#mediation-posts").prepend(data);
  194 + }
  195 + },
  196 + error: function(ajax, stat, errorThrown) {
  197 + console.log(stat);
  198 + }
  199 + });
184 200  
185   - setTimeout(update_mediations, 7000);
  201 + }
  202 +
  203 + setTimeout(update_mediations, 7000);
186 204 }
187 205  
188 206  
189 207 function update_live_stream() {
190   - var hub_id = jQuery(".hub").attr('id');
191 208  
192   - if (jQuery("#live-posts li").first().length == 0) {
193   - var latest_post_id = 0;
194   - }
195   - else {
196   - var latest_post_id = jQuery("#live-posts li").first().attr('id');
197   - }
  209 + if (jQuery("#live-section.show").size() != 0) {
198 210  
199   - //console.log(latest_post_id);
200   -
201   - jQuery.ajax({
202   - url: '/plugin/community_hub/public/newer_comments',
203   - type: 'get',
204   - data: { latest_post: latest_post_id, hub: hub_id },
205   - success: function(data) {
206   - if (data.trim().length > 0) {
207   - jQuery("#live-posts").prepend(data);
208   - if (jQuery("#auto_scrolling").attr('checked')) {
209   - jQuery("#live-posts").scrollTop(0);
210   - }
211   - else {
212   - jQuery("#live-posts").scrollTop(live_scroll_position);
  211 + var hub_id = jQuery(".hub").attr('id');
  212 +
  213 + if (jQuery("#live-posts li").first().length == 0) {
  214 + var latest_post_id = 0;
  215 + }
  216 + else {
  217 + var latest_post_id = jQuery("#live-posts li").first().attr('id');
  218 + }
  219 +
  220 + jQuery.ajax({
  221 + url: '/plugin/community_hub/public/newer_comments',
  222 + type: 'get',
  223 + data: { latest_post: latest_post_id, hub: hub_id },
  224 + success: function(data) {
  225 + if (data.trim().length > 0) {
  226 + jQuery("#live-posts").prepend(data);
  227 + if (jQuery("#auto_scrolling").attr('checked')) {
  228 + jQuery("#live-posts").scrollTop(0);
  229 + }
  230 + else {
  231 + jQuery("#live-posts").scrollTop(live_scroll_position);
  232 + }
213 233 }
  234 + },
  235 + error: function(ajax, stat, errorThrown) {
  236 + console.log(stat);
214 237 }
215   - },
216   - error: function(ajax, stat, errorThrown) {
217   - console.log(stat);
218   - }
219   - });
  238 + });
220 239  
221   - setTimeout(update_live_stream, 5000);
  240 + }
  241 +
  242 + //setTimeout(update_live_stream, 5000);
  243 +}
  244 +
  245 +function hub_left_tab_click() {
  246 + jQuery("#mediation-section").removeClass('show');
  247 + jQuery("#mediation-section").addClass('hide');
  248 + jQuery("#live-section").removeClass('hide');
  249 + jQuery("#live-section").addClass('show');
222 250 }
223 251  
  252 +function hub_right_tab_click() {
  253 + jQuery("#live-section").removeClass('show');
  254 + jQuery("#live-section").addClass('hide');
  255 + jQuery("#mediation-section").removeClass('hide');
  256 + jQuery("#mediation-section").addClass('show');
  257 +}
224 258  
225 259 jQuery(document).ready(function() {
226 260 jQuery("#live-posts").scroll(function() {
227 261 live_scroll_position = jQuery("#live-posts").scrollTop();
228 262 });
229 263  
  264 + jQuery(".hub #left-tab").click(hub_left_tab_click);
  265 + jQuery(".hub #right-tab").click(hub_right_tab_click);
  266 +
230 267 setTimeout(update_live_stream, 5000);
231 268 setTimeout(update_mediations, 7000);
232 269 });
... ...
plugins/community_hub/public/style.css
  1 +div.content-tab.show {
  2 + display: block;
  3 +}
  4 +
  5 +div.content-tab.hide {
  6 + display: none;
  7 +}
  8 +
  9 +#banner-embed-container {
  10 + width: 49%;
  11 + float: right;
  12 +}
  13 +
  14 +#input-panel {
  15 + height: 350px;
  16 + padding-top: 10px;
  17 + height: 350px;
  18 +}
  19 +
  20 +.hub #left-tab {
  21 + /*border: 0px solid lightGray;*/
  22 + border: 1px solid red;
  23 + display: inline-block;
  24 + float: left;
  25 + width: 49%;
  26 + margin-bottom: 2em;
  27 + cursor: pointer;
  28 +}
  29 +
  30 +.hub #right-tab {
  31 + border: 1px solid green;
  32 + display: inline-block;
  33 + clear: right;
  34 + float: none;
  35 + margin-left: 1%;
  36 + width: 50%;
  37 + margin-bottom: 2em;
  38 + cursor: pointer;
  39 +}
  40 +
  41 +.hub #content-tab {
  42 +}
  43 +
  44 +.hub #left-tab .on-air {
  45 + background-color: #d40000;
  46 + border-radius: 10px 10px 10px 10px;
  47 + color: white;
  48 + display: inline-block;
  49 + font-size: 16px;
  50 + font-weight: bold;
  51 + padding: 0 0.5em;
  52 + text-align: center;
  53 + text-transform: uppercase;
  54 + vertical-align: top;
  55 + width: 20%;
  56 +
  57 +}
  58 +
  59 +.hub #left-tab .off-air {
  60 + background-color: gray;
  61 + border-radius: 10px 10px 10px 10px;
  62 + color: black;
  63 + display: inline-block;
  64 + font-size: 16px;
  65 + font-weight: bold;
  66 + padding: 0 0.5em;
  67 + text-align: center;
  68 + text-transform: uppercase;
  69 + vertical-align: top;
  70 + width: 20%;
  71 +}
  72 +
  73 +
1 74 #hub-loading {
2 75 /*margin-top: 18px;*/
3 76 float: right;
... ... @@ -85,7 +158,7 @@ clear: both;
85 158 .hub .mediation-bar {
86 159 display: inline-block;
87 160 margin: 10px 0 10px 104px;
88   - width: 70%;
  161 + width: 83%;
89 162 }
90 163  
91 164 .hub .mediation-bar ul {}
... ... @@ -107,7 +180,7 @@ clear: both;
107 180  
108 181 .hub .mediation-bar ul li.pin{
109 182 height: 25px;
110   - margin-right: 10px;
  183 + /*margin-right: 10px;*/
111 184 }
112 185  
113 186 .hub .remove{}
... ... @@ -185,6 +258,7 @@ clear: both;
185 258 border-style: solid;
186 259 border-color: lightGray;
187 260 padding-top: 10px;
  261 +/*border: 1px solid red;*/
188 262 }
189 263  
190 264  
... ... @@ -268,9 +342,13 @@ clear: both;
268 342 padding-right: 1em;
269 343 }
270 344 .hub .form {
271   - clear: left;
272   - float: left;
273   - width: 49%;
  345 + /*clear: left;*/
  346 + /*float: left;*/
  347 + width: 47%;
  348 + display: inline-block;
  349 + height: 323px;
  350 + padding: 10px;
  351 + border: 1px solid #c0c0c0;
274 352 }
275 353  
276 354 .hub div.settings {
... ... @@ -292,11 +370,12 @@ clear: both;
292 370 }
293 371  
294 372 .hub div.banner {
295   - width: 50%;
296   - height: 100px;
  373 + /*width: 50%;*/
  374 + height: 70px;
297 375 background-color: #6d6d6d;
298   - float: right;
  376 + /*float: right;*/
299 377 text-align: center;
  378 + padding-top: 30px;
300 379 }
301 380  
302 381 .hub div.banner span {
... ... @@ -304,17 +383,17 @@ clear: both;
304 383 font-family: Arial Black, arial, sans-serif;
305 384 font-size: large;
306 385 font-weight: normal;
307   - margin-top: 35px;
  386 + /*margin-top: 35px;*/
308 387 display: block;
309 388 }
310 389  
311 390 .hub div.embed {
312 391 margin-top: 10px;
313 392 padding: 8px;
314   - width: 48%;
315   - height: 216px;
  393 + /*width: 48%;*/
  394 + /*height: 216px;*/
316 395 border: 1px solid #c0c0c0;
317   - float: right;
  396 + /*float: right;*/
318 397 }
319 398  
320 399 .hub div.embed textarea.code {
... ... @@ -387,8 +466,8 @@ textarea#message_body {
387 466 height: 16px;
388 467 display: inline-block;
389 468 float: right;
390   - margin-top: 17px;
391   - margin-right: 270px;
  469 + margin-top: -24px;
  470 + margin-right: 260px;
392 471 }
393 472  
394 473 .hub .loading-mediation-comment {
... ... @@ -396,8 +475,8 @@ textarea#message_body {
396 475 height: 16px;
397 476 display: inline-block;
398 477 float: right;
399   - margin-top: 16px;
400   - margin-right: 260px;
  478 + margin-top: -25px;
  479 + margin-right: 555px;
401 480 }
402 481  
403 482 .loading-signal-done {
... ...
plugins/community_hub/views/community_hub_plugin_public/_mediation.rhtml
... ... @@ -13,12 +13,12 @@
13 13 <ul>
14 14  
15 15 <li class="promote">
16   - <% if promoted?(hub, mediation.author.id) %>
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" title="<%= _("User promoted") %>" />
  16 + <% if !promoted?(hub, mediation.author.id) %>
  17 + <a id="<%= mediation.id %>" href="#" onclick="promote_user(<%= mediation.id %>,<%= mediation.author.id %>); return false;">
  18 + <img class="not-promoted" src="/plugins/community_hub/icons/hub-not-promote-icon.png" title="<%= _("User not promoted") %>" />
19 19 </a>
20 20 <% else %>
21   - <img class="not-promoted" src="/plugins/community_hub/icons/hub-not-promote-icon.png" title="<%= _("User not promoted") %>" />
  21 + <img class="promoted" src="/plugins/community_hub/icons/hub-not-promote-icon.png" title="<%= _("User promoted") %>" />
22 22 <% end %>
23 23 </li>
24 24  
... ...
plugins/community_hub/views/community_hub_plugin_public/_post.rhtml
... ... @@ -20,10 +20,10 @@
20 20 <li class="pin">
21 21 <% if !pinned_message?(hub, post.id) %>
22 22 <a id="<%= post.id %>" href="#" onclick="pin_message(<%= post.id %>); return false;">
23   - <img class="not-pinned" src="/plugins/community_hub/icons/hub-pinned-icon.png" />
  23 + <img class="not-pinned" src="/plugins/community_hub/icons/hub-pinned-icon.png" title="<%= _("Pin message")%>" />
24 24 </a>
25 25 <% else %>
26   - <img class="pinned" src="/plugins/community_hub/icons/hub-not-pinned-icon.png" />
  26 + <img class="pinned" src="/plugins/community_hub/icons/hub-not-pinned-icon.png" title="<%= _("Message pinned")%>" />
27 27 <% end %>
28 28 </li>
29 29 </ul>
... ...
plugins/community_hub/views/community_hub_plugin_public/_settings.rhtml
1 1 <div class="settings">
2 2 <ul class="settings">
3   - <li class="twitter">
4   - <%= link_to _("Twitter settings") + '<span class="collapse">&#9658;</span>', :controller => 'cms', :action => 'edit', :id => @page.id %>
5   - </li>
6   - <li class="facebook">
7   - <%= link_to _("Facebook settings") + '<span class="collapse">&#9658;</span>', :controller => 'cms', :action => 'edit', :id => @page.id %>
8   - </li>
9 3 <li class="general">
10 4 <%= link_to _("General settings") + '<span class="collapse">&#9658;</span>', :controller => 'cms', :action => 'edit', :id => @page.id %>
11 5 </li>
... ...
plugins/community_hub/views/content_viewer/hub.rhtml
... ... @@ -8,54 +8,33 @@
8 8  
9 9 <br />
10 10  
11   - <div class="live">
12   - <h1>
13   - <span class="title"><%= @page.title %></span><span class="on-air"><%= _("Live") %></span>
14   - </h1>
  11 + <span id="left-tab"><%= @page.title %><span class="on-air"><%= _("Live") %></span></span>
  12 + <span id="right-tab"><%= _("Mediation") %><span class="expand">&#9660;</span></span>
  13 + <div id="live-section" class="content-tab show">
15 14 <ul id="live-posts">
16 15 </ul>
17 16 <span><%= check_box_tag 'auto_scrolling', 'yes', true %><%= _("Auto scrolling") %></span>
18 17 </div>
19 18  
20   - <div class="mediation">
21   - <h1>
22   - <span class="title"><%= _("Mediation") %><span class="expand">&#9660;</span></span>
23   - </h1>
  19 + <div id="mediation-section" class="content-tab hide">
24 20 <ul id="mediation-posts">
25 21 </ul>
26 22 </div>
27 23  
  24 + <% if mediator?(@page) %>
28 25  
29   - <% if logged_in? %>
30   -
31   - <div class="form">
32   -
33   - <% if !mediator?(@page) %>
  26 + <% if logged_in? %>
34 27  
35   - <% form_for :message,
36   - :method => 'post',
37   - :url => {
38   - :controller => 'community_hub_plugin_public',
39   - :action => 'new_message',
40   - :article_id => @page.id
41   - } do |f| %>
42   - <span><%= _("Streaming") %></span>
43   - <br />
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;') %>
46   - <span id="loading-message"></span>
47   - <% end %>
48   -
49   - <% else %>
  28 + <div class="form">
50 29  
51 30 <%= render :file => 'shared/tiny_mce' %>
52 31  
53   - <% form_for :article,
  32 + <% form_for :article,
54 33 :method => 'post',
55 34 :url => {
56   - :controller => 'community_hub_plugin_public',
57   - :action => 'new_mediation',
58   - :profile_id => profile.id
  35 + :controller => 'community_hub_plugin_public',
  36 + :action => 'new_mediation',
  37 + :profile_id => profile.id
59 38 } do |f| %>
60 39 <%= f.hidden_field :parent_id, :value => @page.id %>
61 40 <%= f.text_area :body, :style => "width: 100%;", :class => "mceEditor" %>
... ... @@ -63,19 +42,52 @@
63 42 <span id="loading-mediation"></span>
64 43 <% end %>
65 44  
66   - <% end %>
67   -
68   - </div>
  45 + </div>
69 46  
70   - <% end %>
  47 + <% end %>
71 48  
72   - <% if mediator?(@page) %>
73 49 <%= render :partial => "community_hub_plugin_public/settings" %>
  50 +
74 51 <% else %>
75   - <%= render :partial => "community_hub_plugin_public/banner" %>
76   - <%= render :partial => "community_hub_plugin_public/embed" %>
77   - <% end %>
  52 +
  53 + <div id="input-panel">
  54 +
  55 + <% if logged_in? %>
  56 +
  57 + <div class="form">
  58 +
  59 + <% form_for :message,
  60 + :method => 'post',
  61 + :url => {
  62 + :controller => 'community_hub_plugin_public',
  63 + :action => 'new_message',
  64 + :article_id => @page.id
  65 + } do |f| %>
  66 + <span><%= _("Streaming") %></span>
  67 + <br />
  68 + <%= f.text_area :body, :style => "width: 99%;", :cols => "38", :rows => "10", :placeholder => _("Type your message here") %>
  69 + <%= submit_button('add', _('Post'), :onclick => 'new_message(this); return false;') %>
  70 + <span id="loading-message"></span>
  71 + <% end %>
  72 +
  73 + </div>
  74 +
  75 + <% end %>
  76 +
  77 + <div id="banner-embed-container">
  78 + <%= render :partial => "community_hub_plugin_public/banner" %>
  79 + <%= render :partial => "community_hub_plugin_public/embed" %>
  80 + </div>
  81 +
  82 + </div>
  83 +
  84 + <% end %>
78 85  
79 86 </div>
80 87  
  88 +<script type="text/javascript">
  89 + DEFAULT_PIN_QUESTION = '<%= _("Are you sure that you want to pin this message?") %>';
  90 + DEFAULT_PROMOTE_QUESTION = '<%= _("Are you sure that you want to promote this user?") %>';
  91 +</script>
  92 +
81 93 <%= javascript_include_tag '/plugins/community_hub/javascripts/community_hub.js' %>
... ...