social_stream 0.19.2 → 0.19.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/.travis.yml +1 -1
  2. data/README.rdoc +1 -1
  3. data/base/app/assets/stylesheets/cheesecake.css.scss +43 -12
  4. data/base/app/controllers/contacts_controller.rb +1 -1
  5. data/base/app/models/activity.rb +4 -1
  6. data/base/app/models/actor.rb +2 -14
  7. data/base/app/models/relation.rb +2 -4
  8. data/base/app/models/relation/single.rb +2 -7
  9. data/base/app/models/tie.rb +2 -1
  10. data/base/app/views/activities/_new.html.erb +1 -1
  11. data/base/app/views/cheesecake/_cheesecake.html.erb +170 -105
  12. data/base/app/views/cheesecake/_index.html.erb +45 -47
  13. data/base/app/views/cheesecake/_sector_form.html.erb +1 -0
  14. data/base/app/views/toolbar/_home.html.erb +1 -1
  15. data/base/config/locales/en.yml +2 -0
  16. data/base/config/locales/es.yml +2 -0
  17. data/base/config/locales/rails.es.yml +192 -0
  18. data/base/db/migrate/20110912074426_add_reject_relation.rb +2 -2
  19. data/base/db/migrate/20120201185454_singleton_single_relations.rb +46 -0
  20. data/base/lib/social_stream/base/version.rb +1 -1
  21. data/base/lib/tasks/db/populate.rake +1 -1
  22. data/base/spec/controllers/posts_controller_spec.rb +2 -2
  23. data/base/spec/factories/activity.rb +1 -1
  24. data/base/spec/factories/post.rb +1 -1
  25. data/base/spec/factories/tie.rb +3 -3
  26. data/base/spec/models/activity_authorization_spec.rb +3 -3
  27. data/base/spec/support/db.rb +3 -1
  28. data/documents/app/assets/images/48/{word.png → doc.png} +0 -0
  29. data/documents/app/assets/images/48/{excel.png → xls.png} +0 -0
  30. data/documents/lib/social_stream/documents/version.rb +1 -1
  31. data/documents/social_stream-documents.gemspec +1 -1
  32. data/documents/spec/factories/document.rb +1 -1
  33. data/documents/spec/factories/picture.rb +1 -1
  34. data/documents/spec/support/db.rb +3 -3
  35. data/events/app/views/events/_sidebar_calendar.html.erb +5 -5
  36. data/events/lib/social_stream/events/version.rb +1 -1
  37. data/events/social_stream-events.gemspec +1 -1
  38. data/lib/social_stream/version.rb +1 -1
  39. data/linkser/db/migrate/20120202104549_add_links_foreign_key.rb +9 -0
  40. data/presence/app/assets/javascripts/chat_interface_manager.js.erb +167 -177
  41. data/presence/app/assets/javascripts/chat_persistence.js +194 -0
  42. data/presence/app/assets/javascripts/chat_utilities.js +15 -0
  43. data/presence/app/assets/javascripts/chat_window_manager.js +57 -1
  44. data/presence/app/assets/javascripts/xmpp_client_management.js.erb +191 -143
  45. data/presence/app/assets/stylesheets/chat.css.scss +4 -5
  46. data/presence/app/views/chat/_contacts.html.erb +2 -5
  47. data/presence/app/views/chat/_index.html.erb +46 -32
  48. data/presence/app/views/chat/_off.html.erb +2 -2
  49. data/presence/config/routes.rb +1 -1
  50. data/presence/lib/social_stream/presence/version.rb +1 -1
  51. data/presence/vendor/assets/javascripts/jquery.ui.chatbox.js +14 -11
  52. data/social_stream.gemspec +4 -4
  53. data/spec/support/db.rb +4 -4
  54. metadata +37 -32
@@ -35,7 +35,7 @@ Factory.define :self_activity, :parent => :activity do |a|
35
35
  end
36
36
 
37
37
  Factory.define :public_activity, :parent => :activity do |a|
38
- a.relation_ids { |b| Array(b.sender.relation_public.id) }
38
+ a.relation_ids { |b| Array(Relation::Public.instance.id) }
39
39
  end
40
40
 
41
41
  Factory.define :like_activity, :class => 'Activity' do |a|
@@ -7,5 +7,5 @@ end
7
7
 
8
8
  Factory.define :public_post, :parent => :post do |p|
9
9
  p.owner_id { |q| q.author_id }
10
- p._relation_ids { |q| Array(q.author.relation_public.id) }
10
+ p._relation_ids { |q| Array(Relation::Public.instance.id) }
11
11
  end
@@ -13,11 +13,11 @@ Factory.define :acquaintance, :parent => :tie do |t|
13
13
  end
14
14
 
15
15
  Factory.define :public, :parent => :tie do |t|
16
- t.after_build { |u| u.relation = u.sender.relation_public }
16
+ t.after_build { |u| u.relation = Relation::Public.instance }
17
17
  end
18
18
 
19
19
  Factory.define :reject, :parent => :tie do |t|
20
- t.after_build { |u| u.relation = u.sender.relation_reject }
20
+ t.after_build { |u| u.relation = Relation::Reject.instance }
21
21
  end
22
22
 
23
23
  # Group ties
@@ -38,6 +38,6 @@ Factory.define :partner, :parent => :g2g_tie do |t|
38
38
  end
39
39
 
40
40
  Factory.define :group_public, :parent => :g2g_tie do |t|
41
- t.after_build { |u| u.relation = u.sender.relation_public }
41
+ t.after_build { |u| u.relation = Relation::Public.instance }
42
42
  end
43
43
 
@@ -89,7 +89,7 @@ describe Activity do
89
89
  context "with public activity" do
90
90
  before do
91
91
  contact = @user.contact_to!(@user)
92
- create_activity(contact, @user.relation_public)
92
+ create_activity(contact, Relation::Public.instance)
93
93
  end
94
94
 
95
95
  describe "sender home" do
@@ -219,7 +219,7 @@ describe Activity do
219
219
  describe "belonging to user's public relation" do
220
220
 
221
221
  before do
222
- create_activity(@user.contact_to!(@user), @user.relation_public)
222
+ create_activity(@user.contact_to!(@user), Relation::Public.instance)
223
223
  end
224
224
 
225
225
  describe "accessed by the sender" do
@@ -271,7 +271,7 @@ describe Activity do
271
271
 
272
272
  before do
273
273
  @tie = Factory(:public)
274
- create_activity @tie.contact, @tie.sender.relation_public
274
+ create_activity @tie.contact, Relation::Public.instance
275
275
  create_ability_accessed_by @tie.receiver_subject
276
276
  end
277
277
 
@@ -1,6 +1,8 @@
1
1
  require 'social_stream/migrations/base'
2
2
 
3
- SocialStream::Migrations::Base.new.down
3
+ ActiveRecord::Base.connection.tables.each do |t|
4
+ ActiveRecord::Base.connection.drop_table t
5
+ end
4
6
 
5
7
  SocialStream::Migrations::Base.new.up
6
8
 
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Documents
3
- VERSION = "0.9.0".freeze
3
+ VERSION = "0.9.1".freeze
4
4
  end
5
5
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.files = `git ls-files`.split("\n")
13
13
 
14
14
  # Gem dependencies
15
- s.add_runtime_dependency('social_stream-base', '~> 0.14.0')
15
+ s.add_runtime_dependency('social_stream-base', '~> 0.14.3')
16
16
  s.add_runtime_dependency('paperclip-ffmpeg', '~> 0.7.0')
17
17
  s.add_runtime_dependency('paperclip','= 2.4.5')
18
18
  s.add_runtime_dependency('delayed_paperclip','2.4.5.1')
@@ -9,7 +9,7 @@ end
9
9
 
10
10
  Factory.define :public_document, :parent => :document do |d|
11
11
  d.owner_id { |q| q.author_id }
12
- d._relation_ids { |q| Array(q.author.relation_public.id) }
12
+ d._relation_ids { |q| Array(Relation::Public.instance.id) }
13
13
  end
14
14
 
15
15
  Factory.define :private_document, :parent => :document do |d|
@@ -9,7 +9,7 @@ end
9
9
 
10
10
  Factory.define :public_picture, :parent => :picture do |p|
11
11
  p.owner_id { |q| q.author_id }
12
- p._relation_ids { |q| Array(q.author.relation_public.id) }
12
+ p._relation_ids { |q| Array(Relation::Public.instance.id) }
13
13
  end
14
14
 
15
15
  Factory.define :private_picture, :parent => :picture do |p|
@@ -1,8 +1,8 @@
1
1
  require 'social_stream/migrations/documents'
2
2
 
3
-
4
- SocialStream::Migrations::Documents.new.down
5
- SocialStream::Migrations::Base.new.down
3
+ ActiveRecord::Base.connection.tables.each do |t|
4
+ ActiveRecord::Base.connection.drop_table t
5
+ end
6
6
 
7
7
  SocialStream::Migrations::Base.new.up
8
8
  SocialStream::Migrations::Documents.new.up
@@ -3,7 +3,7 @@
3
3
  <div class="block">
4
4
  <div class="content">
5
5
 
6
- <% bow = (Time.now - 1.days).beginning_of_week %>
6
+ <% bow = (Time.now - 6.days).beginning_of_week %>
7
7
 
8
8
  <%= render :partial => 'events/calendar_month',
9
9
  :locals => {
@@ -17,8 +17,8 @@
17
17
  <% day = bow + i.days %>
18
18
 
19
19
  <%= raw cycle(*(Array.wrap("<tr>") + 6.times.map{""}) + Array.wrap(:name => "tr_start")) %>
20
- <td id="sidebar_day_<%= day.day %>_<%= day.month %>_<%= day.year %>" class="sidebar_day">
21
- <%= link_to day.day, polymorphic_path([profile_or_current_subject, Event.new], :date => day.to_i, :view => "agendaDay") %>
20
+ <td id="sidebar_day_<%= day.day %>_<%= day.month %>_<%= day.year %>">
21
+ <%= link_to day.day, polymorphic_path([profile_or_current_subject, Event.new], :date => day.to_i, :view => "agendaWeek") %>
22
22
  </td>
23
23
 
24
24
  <%= raw cycle(*(6.times.map{""} + Array.wrap('</tr>') + Array.wrap(:name => "tr_end"))) %>
@@ -29,12 +29,12 @@
29
29
  var now = new Date();
30
30
  $('#sidebar_day_' + now.getDate() + '_' + (now.getMonth()+1) + '_' + now.getFullYear()).addClass('today');
31
31
  var re = new RegExp('sidebar_day_(..?)_(..?)_(..?.?.?)');
32
- $('.sidebar_day').each(function(index, domEl){
32
+ $('#sidebar_calendar td').each(function(index, domEl){
33
33
  var m = re.exec(domEl.id);
34
34
  if(m == null) return;
35
35
  var d = new Date(m[3], (m[2]-1), m[1], 23, 59, 59);
36
36
  if(d < now) $(domEl).addClass('past');
37
- if(m[2] != (now.getMonth()+1)) $(domEl).addClass('next_month');
37
+ if(m[2] != (now.getMonth()+1) && d > now) $(domEl).addClass('next_month');
38
38
  });
39
39
  $.ajax({
40
40
  dataType: 'json',
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Events
3
- VERSION = "0.6.1".freeze
3
+ VERSION = "0.6.2".freeze
4
4
  end
5
5
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.files = `git ls-files`.split("\n")
13
13
 
14
14
  # Gem dependencies
15
- s.add_runtime_dependency('social_stream-base', '~> 0.14.1')
15
+ s.add_runtime_dependency('social_stream-base', '~> 0.14.3')
16
16
  s.add_runtime_dependency('rails-scheduler', '~> 0.0.6')
17
17
  s.add_runtime_dependency('coffee-rails', '>= 3.1.0')
18
18
 
@@ -1,3 +1,3 @@
1
1
  module SocialStream
2
- VERSION = "0.19.2".freeze
2
+ VERSION = "0.19.3".freeze
3
3
  end
@@ -0,0 +1,9 @@
1
+ class AddLinksForeignKey < ActiveRecord::Migration
2
+ def up
3
+ add_foreign_key "links", "activity_objects", :name => "links_on_activity_object_id"
4
+ end
5
+
6
+ def down
7
+ remove_foreign_key "links", :name => "links_on_activity_object_id"
8
+ end
9
+ end
@@ -1,17 +1,3 @@
1
- ////////////////////
2
- //Hash table
3
- ////////////////////
4
-
5
- //Keys: Xmpp status
6
- //Value: Social Stream Status
7
- var statusIcons = new Array();
8
- statusIcons[''] = "available";
9
- statusIcons['chat'] = "available";
10
- statusIcons['away'] = "away";
11
- statusIcons['xa'] = "away";
12
- statusIcons['dnd'] = "dnd";
13
-
14
-
15
1
  ////////////////////
16
2
  //Reconnect button interface functions
17
3
  ////////////////////
@@ -21,18 +7,18 @@ var periodBetweenAttempts=15; //(seg)
21
7
  var connectButtonTimerCounter=periodBetweenAttempts+1;
22
8
 
23
9
  function connectButtonTimerFunction(){
24
- connectButtonTimerCounter++;
25
- if (connectButtonTimerCounter > (periodBetweenAttempts-1)) {
26
- clearTimeout(connectButtonTimer);
27
- $("#chat_header_title").html(I18n.t('chat.disconnected'))
28
- }
10
+ connectButtonTimerCounter++;
11
+ if (connectButtonTimerCounter > (periodBetweenAttempts-1)) {
12
+ clearTimeout(connectButtonTimer);
13
+ $("#chat_header_title").html('<%=I18n.t('chat.disconnected')%>')
14
+ }
29
15
  }
30
16
 
31
17
  function requestConnectToChat(){
32
18
  if (connectButtonTimerCounter > (periodBetweenAttempts-1)) {
33
19
  connectButtonTimerCounter=0;
34
- connectButtonTimer = setInterval("connectButtonTimerFunction()", 1000)
35
- $("#chat_header_title").html(I18n.t('chat.connecting'))
20
+ connectButtonTimer = setInterval("connectButtonTimerFunction()", 1000)
21
+ $("#chat_header_title").html('<%=I18n.t('chat.connecting')%>')
36
22
  return true
37
23
  } else {
38
24
  return false
@@ -45,48 +31,48 @@ function requestConnectToChat(){
45
31
  ////////////////////
46
32
 
47
33
  function setUserFunctions(){
48
-
49
- $("div.user_presence").click(function(event, ui){
50
- var guest_name = $(this).attr("name");
51
- var guest_slug = $(this).attr("slug");
52
- var guest_jid = guest_slug + "@" + domain;
53
-
54
- if (createChatBox(guest_slug, guest_name, guest_jid, user_name, user_jid)) {
55
- } else {
56
- window[getChatVariableFromSlug(guest_slug)].chatbox("option", "boxManager").toggleBox(true);
57
- };
58
- });
59
-
60
-
34
+
35
+ $("div.user_presence").click(function(event, ui){
36
+ var guest_name = $(this).attr("name");
37
+ var guest_slug = $(this).attr("slug");
38
+ var guest_jid = guest_slug + "@" + domain;
39
+
40
+ if (createChatBox(guest_slug, guest_name, guest_jid, user_name, user_jid)) {
41
+ } else {
42
+ window[getChatVariableFromSlug(guest_slug)].chatbox("option", "boxManager").toggleBox(true);
43
+ };
44
+ });
45
+
46
+
61
47
  ////////////////////
62
48
  //Chat interface: Status selector
63
49
  ////////////////////
64
50
 
65
- //JQuery DropdwanStatus
66
-
67
- $(".dropdown dt a").click(function(event) {
68
- event.preventDefault();
51
+ //JQuery DropdwanStatus
52
+
53
+ $(".dropdown dt a").click(function(event) {
54
+ event.preventDefault();
69
55
  $(".dropdown dd ul").toggle();
70
-
71
- if($(".dropdown dd ul").is(":visible")){
72
- setStatusWidgetTitle("default");
73
- } else {
74
- setStatusWidgetTitle(userStatus);
75
- }
76
-
77
- restartAwayTimer(false);
78
-
56
+
57
+ if($(".dropdown dd ul").is(":visible")){
58
+ setStatusWidgetTitle("default");
59
+ } else {
60
+ setStatusWidgetTitle(userStatus);
61
+ }
62
+
63
+ restartAwayTimer();
64
+
79
65
  });
80
66
 
81
67
  $(".dropdown dd ul li a.option").click(function(event) {
82
- event.preventDefault();
83
- userStatus = $(this).find("span.value").html();
84
- if(userStatus == "offline"){
85
- disconnectStrophe();
86
- } else {
87
- sendStatus(userStatus);
88
- }
89
- $(".dropdown dd ul").hide();
68
+ event.preventDefault();
69
+ userStatus = $(this).find("span.value").html();
70
+ if(userStatus == "offline"){
71
+ disconnectStrophe();
72
+ } else {
73
+ sendStatus(userStatus);
74
+ }
75
+ $(".dropdown dd ul").hide();
90
76
  });
91
77
 
92
78
 
@@ -95,35 +81,40 @@ function setUserFunctions(){
95
81
  if (! $clicked.parents().hasClass("dropdown")){
96
82
  //Click outside the select...
97
83
  $(".dropdown dd ul").hide();
98
- setStatusWidgetTitle(userStatus);
84
+ setStatusWidgetTitle(userStatus);
99
85
  }
100
86
  });
101
-
87
+
102
88
  }
103
89
 
104
90
  function setStatusWidgetTitle(status){
105
-
106
- if ($(".dropdown dt a span").length == 0){
107
- return;
91
+
92
+ if((status in sstreamChatStatus)){
93
+ status = sstreamChatStatus[status];
108
94
  }
109
95
 
110
- if(status=="default"){
111
- var defaultTitle = I18n.t('chat.status.choose');
96
+
97
+ if ($(".dropdown dt a span").length == 0){
98
+ return;
99
+ }
100
+
101
+ if(status=="default"){
102
+ var defaultTitle = '<%=I18n.t('chat.status.choose')%>'
112
103
  $(".dropdown dt a span").html(defaultTitle);
113
- return;
104
+ return;
114
105
  }
115
-
116
- if(status=="offline"){
117
- var text = $("#" + status).html();
106
+
107
+ if(status=="offline"){
108
+ var text = $("#" + status).html();
118
109
  $(".dropdown dt a span").html(text);
119
- return;
120
- }
121
-
122
- if ((status in statusIcons)&&($("#" + statusIcons[status]).length > 0)) {
123
- var text = $("#" + statusIcons[status]).html();
110
+ return;
111
+ }
112
+
113
+ if ((status in statusIcons)&&($("#" + statusIcons[status]).length > 0)) {
114
+ var text = $("#" + statusIcons[status]).html();
124
115
  $(".dropdown dt a span").html(text);
125
116
  }
126
-
117
+
127
118
  }
128
119
 
129
120
 
@@ -132,34 +123,29 @@ function setStatusWidgetTitle(status){
132
123
  ////////////////////
133
124
 
134
125
  function awayTimerFunction(){
135
- awayCounter++;
136
- if (awayCounter > (awayTime/awayTimerPeriod)){
137
- if (userStatus != "dnd") {
138
- userStatus = "away";
139
- sendStatus(userStatus);
140
- }
141
- clearTimeout(awayTimer);
142
- }
126
+ awayCounter++;
127
+ if (awayCounter > (awayTime/awayTimerPeriod)){
128
+ if ((userStatus != "dnd")&&(userStatus != "away")) {
129
+ userStatus = "autoaway";
130
+ sendStatus(userStatus);
131
+ }
132
+ clearTimeout(awayTimer);
133
+ }
143
134
  }
144
135
 
145
- function autochangeStatusOnUserAway(){
146
- if (userStatus == "away"){
147
- userStatus = "chat";
136
+ function autochangeStatusIfAutoAway(){
137
+ if (userStatus == "autoaway"){
138
+ userStatus = "available";
148
139
  sendStatus(userStatus);
149
140
  }
150
141
  }
151
142
 
152
- function restartAwayTimer(autochangeStatus){
153
-
154
- if (awayCounter > (awayTime/awayTimerPeriod)){
155
- awayTimer = setInterval("awayTimerFunction()", awayTimerPeriod);
156
-
157
- if(autochangeStatus){
158
- autochangeStatusOnUserAway();
159
- }
160
- }
161
-
162
- awayCounter = 0;
143
+ function restartAwayTimer(){
144
+ if (awayCounter > (awayTime/awayTimerPeriod)){
145
+ awayTimer = setInterval("awayTimerFunction()", awayTimerPeriod);
146
+ autochangeStatusIfAutoAway();
147
+ }
148
+ awayCounter = 0;
163
149
  }
164
150
 
165
151
 
@@ -168,82 +154,86 @@ function restartAwayTimer(autochangeStatus){
168
154
  ////////////////////
169
155
 
170
156
  function timerFunction(){
171
- timerCounter++;
172
-
157
+ timerCounter++;
158
+
173
159
  if((timerCounter > cyclesToRefresh)&&(requestContacts)) {
174
160
  requestContacts = false;
175
161
  updateChatWindow();
176
- }
162
+ }
177
163
  }
178
164
 
179
165
 
180
166
  function refreshChatWindow(){
181
- if(timerCounter > cyclesToRefresh){
182
- updateChatWindow();
183
- } else {
184
- requestContacts = true;
185
- }
167
+ if(timerCounter > cyclesToRefresh){
168
+ updateChatWindow();
169
+ } else {
170
+ requestContacts = true;
171
+ }
186
172
  }
187
173
 
188
174
 
189
175
  function updateChatWindow(){
190
- timerCounter=0;
191
- log("updateChatWindow()");
192
- var stropheConnectedAndOnlineStatus = ((isStropheConnected()) && (userStatus!="offline") && (!disconnectionFlag));
176
+ timerCounter=0;
177
+ log("updateChatWindow()");
178
+ var stropheConnectedAndOnlineStatus = ((isStropheConnected()) && (userStatus!="offline") && (!disconnectionFlag));
193
179
  $.post("/chatWindow", { userConnected: stropheConnectedAndOnlineStatus }, function(data){
194
- $(".tooltip").hide() //Prevent tooltips
180
+ $(".tooltip").hide() //Prevent tooltips
195
181
  $("#chat_partial").html(data);
196
182
  if (isStropheConnected()) {
197
- setStatusWidgetTitle(userStatus);
183
+ setStatusWidgetTitle(userStatus);
198
184
  $(".user_presence a[title]").tooltip();
199
185
  setUserFunctions();
186
+ if (afterNewConnectionFlag){
187
+ afterNewConnectionFlag = false;
188
+ restoreChatData();
189
+ }
200
190
  }
201
191
  });
202
192
  }
203
193
 
204
194
  function getConnectionBoxFromSlug(slug){
205
- if ($('div.user_presence[slug=' + slug + ']').length > 0){
206
- return ($('div.user_presence[slug=' + slug + ']'))[0];
207
- } else {
208
- return null;
209
- }
195
+ if ($('div.user_presence[slug=' + slug + ']').length > 0){
196
+ return ($('div.user_presence[slug=' + slug + ']'))[0];
197
+ } else {
198
+ return null;
199
+ }
210
200
  }
211
201
 
212
202
  var cacheConnectedUsers = [];
213
203
  function hideConnectionBoxFromSlug(slug){
214
204
  if ($('div.user_presence[slug=' + slug + ']').length > 0){
215
205
  $('div.user_presence[slug=' + slug + ']').hide();
216
- if(cacheConnectedUsers.indexOf(slug)==-1){
217
- cacheConnectedUsers.push(slug);
218
- }
206
+ if(cacheConnectedUsers.indexOf(slug)==-1){
207
+ cacheConnectedUsers.push(slug);
208
+ }
219
209
  }
220
210
  }
221
211
 
222
212
  function showConnectionBoxFromSlug(slug){
223
213
  if ($('div.user_presence[slug=' + slug + ']').length > 0){
224
- if (!($('div.user_presence[slug=' + slug + ']').is(":visible"))){
225
- $('div.user_presence[slug=' + slug + ']').show();
226
- }
214
+ if (!($('div.user_presence[slug=' + slug + ']').is(":visible"))){
215
+ $('div.user_presence[slug=' + slug + ']').show();
216
+ }
227
217
  }
228
218
  }
229
219
 
230
220
  function setUserIconStatus(slug, status){
231
- if (status in statusIcons) {
232
- iconName = statusIcons[status];
233
- var $img_status = $('img.presence_status');
234
- connectionBox = getConnectionBoxFromSlug(slug);
221
+ if (status in statusIcons) {
222
+ iconName = statusIcons[status];
223
+ var $img_status = $('img.presence_status');
224
+ connectionBox = getConnectionBoxFromSlug(slug);
235
225
  $(connectionBox).find($img_status).attr("src", "/assets/status/" + iconName + ".png")
236
226
  }
237
227
  }
238
228
 
239
229
  function getAllConnectedSlugs(){
240
- connectedSlugs=[];
230
+ connectedSlugs=[];
241
231
  connectionBoxes = $('div.user_presence[slug]');
242
- $.each(connectionBoxes, function(index, value) {
243
- if($(value).is(":visible")){
244
- connectedSlugs.push($(value).attr("slug"))
245
- }
246
- });
232
+ $.each(connectionBoxes, function(index, value) {
233
+ if($(value).is(":visible")){
234
+ connectedSlugs.push($(value).attr("slug"))
235
+ }
236
+ });
247
237
  return connectedSlugs
248
238
  }
249
239
 
@@ -253,47 +243,47 @@ function getAllConnectedSlugs(){
253
243
  ////////////////////
254
244
 
255
245
  function putReceivedMessageOnChatWindow(from_jid,from_slug,body,msgID){
256
-
257
- //Antiflood control
258
- if (antifloodControl(from_jid,from_slug,body,msgID)){
259
- return;
260
- }
261
-
262
- //Check for from_slug name and connectionBox visibility
263
- if (typeof($('div.user_presence[slug=' + from_slug + ']').attr('name')) == 'undefined') {
264
- //No connectionBox for this user!
265
- var from_name = from_slug;
266
- refreshChatWindow();
267
- } else {
268
- showConnectionBoxFromSlug(from_slug);
269
- var from_name = $('div.user_presence[slug=' + from_slug + ']').attr('name');
270
- }
271
-
272
-
273
- //Create or toggle from_slug's chatBox.
274
- if (createChatBox(from_slug, from_name, from_jid, user_name, user_jid)) {
275
- } else {
276
- window[getChatVariableFromSlug(from_slug)].chatbox("option", "boxManager").toggleBox(true);
277
- }
278
-
279
- //Parse content before show it.
280
- var content = getParsedContent(Strophe.getText(body), false)
281
- var headerMessage = getParsedName(from_name,false);
282
-
283
- //Show message to chatBox.
284
- $("#" + from_slug).chatbox("option", "boxManager").addMsg(headerMessage, content);
285
-
286
- //Rotate chatBoxes priority.
287
- rotatePriority(from_slug);
288
-
289
- //Check for start blinkTitle.
290
- blinkTitleOnMessage(from_name);
291
-
292
- //Check for play sound
293
- if (mustPlaySoundForChatWindow(window[getChatVariableFromSlug(from_slug)])) {
294
- playSound("onMessageAudio");
295
- }
296
-
246
+
247
+ //Antiflood control
248
+ if (antifloodControl(from_jid,from_slug,body,msgID)){
249
+ return;
250
+ }
251
+
252
+ //Check for from_slug name and connectionBox visibility
253
+ if (typeof($('div.user_presence[slug=' + from_slug + ']').attr('name')) == 'undefined') {
254
+ //No connectionBox for this user!
255
+ var from_name = from_slug;
256
+ refreshChatWindow();
257
+ } else {
258
+ showConnectionBoxFromSlug(from_slug);
259
+ var from_name = $('div.user_presence[slug=' + from_slug + ']').attr('name');
260
+ }
261
+
262
+
263
+ //Create or toggle from_slug's chatBox.
264
+ if (createChatBox(from_slug, from_name, from_jid, user_name, user_jid)) {
265
+ } else {
266
+ window[getChatVariableFromSlug(from_slug)].chatbox("option", "boxManager").toggleBox(true);
267
+ }
268
+
269
+ //Parse content before show it.
270
+ var content = getParsedContent(Strophe.getText(body), false)
271
+ var headerMessage = getParsedName(from_name,false);
272
+
273
+ //Show message to chatBox.
274
+ $("#" + from_slug).chatbox("option", "boxManager").addMsg(headerMessage, content);
275
+
276
+ //Rotate chatBoxes priority.
277
+ rotatePriority(from_slug);
278
+
279
+ //Check for start blinkTitle.
280
+ blinkTitleOnMessage(from_name);
281
+
282
+ //Check for play sound
283
+ if (mustPlaySoundForChatWindow(window[getChatVariableFromSlug(from_slug)])) {
284
+ playSound("onMessageAudio");
285
+ }
286
+
297
287
  }
298
288
 
299
289
 
@@ -302,8 +292,8 @@ function putReceivedMessageOnChatWindow(from_jid,from_slug,body,msgID){
302
292
  ////////////////////
303
293
 
304
294
  function showChatNotificationForSlug(slug,msg){
305
- var notification = $("#" + slug).parent().find("div.ui-chatbox-notify");
306
- showChatNotification(notification,msg);
295
+ var notification = $("#" + slug).parent().find("div.ui-chatbox-notify");
296
+ showChatNotification(notification,msg);
307
297
  }
308
298
 
309
299
  function showChatNotification(notification,msg){
@@ -314,7 +304,7 @@ function showChatNotification(notification,msg){
314
304
 
315
305
  function hideChatNotificationForSlug(slug){
316
306
  var notification = $("#" + slug).parent().find("div.ui-chatbox-notify");
317
- hideChatNotification(notification);
307
+ hideChatNotification(notification);
318
308
  }
319
309
 
320
310
  function hideChatNotification(notification){
@@ -323,12 +313,12 @@ function hideChatNotification(notification){
323
313
  }
324
314
 
325
315
  function notifyWhenUsersDisconnect(){
326
- var notification = $("div.ui-chatbox-notify");
327
- var msg = I18n.t('chat.notify.offline');
328
- showChatNotification(notification,msg);
316
+ var notification = $("div.ui-chatbox-notify");
317
+ var msg = '<%=I18n.t('chat.notify.offline')%>';
318
+ showChatNotification(notification,msg);
329
319
  }
330
320
 
331
321
  function hideAllNotifications(){
332
- var notification = $("div.ui-chatbox-notify");
322
+ var notification = $("div.ui-chatbox-notify");
333
323
  hideChatNotification(notification);
334
- }
324
+ }