social_stream 0.22.1 → 0.23.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/base/app/assets/javascripts/activities.js.erb +0 -85
  2. data/base/app/assets/javascripts/social_stream.comments.js +63 -0
  3. data/base/app/assets/javascripts/social_stream.objects.js +23 -0
  4. data/base/app/assets/javascripts/social_stream.timeline.js +37 -10
  5. data/base/app/assets/javascripts/social_stream.wall.js.erb +135 -118
  6. data/base/app/assets/stylesheets/cheesecake.css.scss +6 -3
  7. data/base/app/models/activity_object.rb +18 -0
  8. data/base/app/models/activity_object_property.rb +5 -0
  9. data/base/app/views/activities/_new.html.erb +1 -1
  10. data/base/app/views/activities/_wall.html.erb +1 -1
  11. data/base/app/views/cheesecake/_cheesecake.html.erb +44 -10
  12. data/base/app/views/cheesecake/_index.html.erb +18 -130
  13. data/base/app/views/cheesecake/_sector_form.html.erb +176 -17
  14. data/base/app/views/comments/_new.html.erb +0 -14
  15. data/base/app/views/objects/_show.html.erb +6 -0
  16. data/base/app/views/toolbar/_home.html.erb +1 -1
  17. data/base/app/views/toolbar/_messages.html.erb +1 -1
  18. data/base/app/views/toolbar/_profile.html.erb +1 -1
  19. data/base/config/locales/es.yml +7 -0
  20. data/base/db/migrate/20120302215722_activity_object_properties.rb +24 -0
  21. data/base/lib/social_stream/ability/base.rb +2 -2
  22. data/base/lib/social_stream/base/version.rb +1 -1
  23. data/documents/app/assets/javascripts/social_stream-documents.js +5 -1
  24. data/documents/app/models/document.rb +4 -3
  25. data/documents/app/models/picture.rb +4 -0
  26. data/documents/lib/social_stream/documents/version.rb +1 -1
  27. data/documents/social_stream-documents.gemspec +1 -1
  28. data/events/app/assets/images/poster.png +0 -0
  29. data/events/app/assets/javascripts/social_stream-events.js +7 -0
  30. data/events/app/assets/javascripts/social_stream.events.poster.js +21 -0
  31. data/events/app/assets/stylesheets/events.css.scss +25 -0
  32. data/events/app/helpers/events_helper.rb +9 -0
  33. data/events/app/models/activity_object_property/poster.rb +2 -0
  34. data/events/app/models/event.rb +18 -0
  35. data/events/app/views/events/_event.html.erb +39 -27
  36. data/events/app/views/events/_form_poster.html.erb +8 -0
  37. data/events/app/views/events/edit.js.erb +5 -0
  38. data/events/config/locales/en.yml +2 -0
  39. data/events/config/locales/es.yml +2 -0
  40. data/events/lib/social_stream-events.rb +2 -1
  41. data/events/lib/social_stream/events/engine.rb +6 -0
  42. data/events/lib/social_stream/events/models/document.rb +26 -0
  43. data/events/lib/social_stream/events/version.rb +1 -1
  44. data/events/social_stream-events.gemspec +1 -1
  45. data/lib/social_stream/version.rb +1 -1
  46. data/linkser/lib/social_stream/linkser/version.rb +1 -1
  47. data/linkser/social_stream-linkser.gemspec +1 -1
  48. data/presence/app/assets/images/games/ter/classic_aspa.png +0 -0
  49. data/presence/app/assets/images/games/ter/classic_board.png +0 -0
  50. data/presence/app/assets/images/games/ter/classic_circle.png +0 -0
  51. data/presence/app/assets/images/games/ter/modern_aspa.png +0 -0
  52. data/presence/app/assets/images/games/ter/modern_board.png +0 -0
  53. data/presence/app/assets/images/games/ter/modern_circle.png +0 -0
  54. data/presence/app/assets/javascripts/jquery.ui.chatbox.sstreampresence.js +34 -3
  55. data/presence/app/assets/javascripts/presence.js.erb +4 -0
  56. data/presence/app/assets/javascripts/{xmpp_client_management.js.erb → presence_XmppClient.js.erb} +417 -49
  57. data/presence/app/assets/javascripts/{chat_audio.js.erb → presence_audio.js.erb} +0 -0
  58. data/presence/app/assets/javascripts/presence_game.js.erb +76 -0
  59. data/presence/app/assets/javascripts/presence_game_ter.js.erb +384 -0
  60. data/presence/app/assets/javascripts/presence_notifications.js +191 -0
  61. data/presence/app/assets/javascripts/{chat_parser.js → presence_parser.js} +0 -0
  62. data/presence/app/assets/javascripts/{chat_persistence.js → presence_persistence.js} +84 -70
  63. data/presence/app/assets/javascripts/{store.js → presence_store.js} +0 -0
  64. data/presence/app/assets/javascripts/{chat_interface_manager.js.erb → presence_uiManager.js.erb} +42 -132
  65. data/presence/app/assets/javascripts/{chat_utilities.js → presence_utilities.js} +10 -34
  66. data/presence/app/assets/javascripts/{videochat.js.erb → presence_videochat.js.erb} +4 -24
  67. data/presence/app/assets/javascripts/{chat_window_manager.js → presence_windowManager.js} +275 -217
  68. data/presence/app/assets/javascripts/social_stream-presence.js +0 -2
  69. data/presence/app/assets/stylesheets/chat.css.scss +12 -1
  70. data/presence/app/views/chat/_contacts.html.erb +5 -5
  71. data/presence/app/views/chat/_index.html.erb +10 -2
  72. data/presence/config/locales/en.yml +9 -1
  73. data/presence/config/locales/es.yml +9 -1
  74. data/presence/ejabberd/ejabberd_files.zip +0 -0
  75. data/presence/ejabberd/ejabberd_scripts/emanagement +132 -2
  76. data/presence/ejabberd/installer.sh +1 -0
  77. data/presence/ejabberd/mod_muc_admin/mod_muc_admin.beam +0 -0
  78. data/presence/ejabberd/mod_muc_admin/mod_muc_admin.erl +871 -0
  79. data/presence/ejabberd/mod_sspresence/mod_sspresence.beam +0 -0
  80. data/presence/lib/social_stream/presence/models/buddy_manager.rb +32 -26
  81. data/presence/lib/social_stream/presence/models/group_manager.rb +12 -2
  82. data/presence/lib/social_stream/presence/version.rb +1 -1
  83. data/presence/lib/social_stream/presence/xmpp_server_order.rb +2 -2
  84. data/presence/social_stream-presence.gemspec +1 -1
  85. data/presence/vendor/assets/javascripts/strophe.muc.js +1 -1
  86. data/social_stream.gemspec +5 -5
  87. metadata +63 -41
  88. data/events/app/assets/javascripts/0_init.js +0 -4
@@ -0,0 +1,191 @@
1
+ ////////////////////
2
+ //Chat Boxes Notifications
3
+ ////////////////////
4
+
5
+ function fadeInChatNotification(notification){
6
+ if(notification!=null){
7
+ notification.css("display","block");
8
+ notification.css("visibility","visible");
9
+ notification.fadeIn();
10
+ }
11
+ }
12
+
13
+ function showChatNotification(notification,type,msg){
14
+ notification.html("<p notification_type=\"" + type + "\" class=\"ui-chatbox-notify-text\">" + msg + "</p>");
15
+ fadeInChatNotification(notification);
16
+ }
17
+
18
+ function showChatNotificationForSlug(slug,type,msg){
19
+ var notification = $("#" + slug).parent().find("div.ui-chatbox-notify");
20
+ if(notification.length==1){
21
+ showChatNotification(notification,type,msg);
22
+ }
23
+ }
24
+
25
+ function showOfflineChatNotificationForSlug(slug){
26
+ var msg = I18n.t("chat.notify.guestOffline", {name: getNameFromSlug(slug)});
27
+ showChatNotificationForSlug(slug,"guestOffline",msg);
28
+ }
29
+
30
+ function showVideoChatNotificationForSlug(slug,msg){
31
+ showChatNotificationForSlug(slug,"videochat",msg);
32
+ }
33
+
34
+ function showVideoChatNotificationForSlugClientIssue(slug){
35
+ var msg = I18n.t("chat.notify.videochat.clientIssue", {name: getNameFromSlug(slug)});
36
+ showVideoChatNotificationForSlug(slug,msg);
37
+ }
38
+
39
+ function showVideoChatNotificationForSlugClientOffline(slug){
40
+ var msg = I18n.t("chat.notify.videochat.offline", {name: getNameFromSlug(slug)});
41
+ showVideoChatNotificationForSlug(slug,msg);
42
+ }
43
+
44
+ function fadeOutChatNotification(notification){
45
+ if(notification!=null){
46
+ notification.fadeOut();
47
+ notification.css("display","none");
48
+ notification.css("visibility","hidden");
49
+ }
50
+ }
51
+
52
+ function hideChatNotificationForSlug(slug){
53
+ var notification = getChatNotificationForSlug(slug);
54
+ fadeOutChatNotification(notification);
55
+ }
56
+
57
+ function updateNotificationsAfterUserDisconnect(){
58
+ var notification = $("div.ui-chatbox-notify");
59
+ var msg = I18n.t('chat.notify.offline');
60
+ showChatNotification(notification,"userOffline",msg);
61
+ }
62
+
63
+ function hideAllNotifications(){
64
+ var notification = $("div.ui-chatbox-notify");
65
+ fadeOutChatNotification(notification);
66
+ }
67
+
68
+ function updateAllNotifications(){
69
+ hideAllNotifications();
70
+ if(disconnectionFlag){
71
+ updateNotificationsAfterUserDisconnect();
72
+ } else {
73
+ //Notification for offline contacts
74
+ $.each(getAllDisconnectedSlugsWithChatBoxes(), function(index, value) {
75
+ if(!isSlugGroup(value)){
76
+ showOfflineChatNotificationForSlug(value)
77
+ }
78
+ });
79
+ }
80
+ }
81
+
82
+ function getChatNotificationForSlug(slug){
83
+ var chatBox = getChatBoxForSlug(slug)
84
+ if(chatBox!=null){
85
+ var notification = chatBox.parent().find("div.ui-chatbox-notify");
86
+ if (notification.length == 1) {
87
+ return notification;
88
+ }
89
+ }
90
+ return null;
91
+ }
92
+
93
+ function getNotificationType(notification){
94
+ return $(notification).find("p").attr("notification_type");
95
+ }
96
+
97
+ function addTextToNotification(notification,txt,type,name){
98
+ var new_p = document.createElement('p')
99
+ $(new_p).attr("class","ui-chatbox-notify-text")
100
+ $(new_p).attr("notification_type",type)
101
+ $(new_p).html(txt)
102
+ if(name!=null){
103
+ $(new_p).attr("name",name)
104
+ }
105
+ $(notification).append(new_p)
106
+ fadeInChatNotification(notification)
107
+ }
108
+
109
+ function removeTextFromNotification(notification,name){
110
+ var p = $(notification).find("p.ui-chatbox-notify-text[name=" + name + "]")
111
+ if (p!=null){
112
+ p.remove()
113
+ var empty = ($(notification).find("p").length==0)
114
+ if (empty){
115
+ fadeOutChatNotification(notification)
116
+ }
117
+ }
118
+ }
119
+
120
+ function removeAllTextsFromNotification(notification){
121
+ var p = $(notification).find("p.ui-chatbox-notify-text")
122
+ if (p!=null){
123
+ p.remove()
124
+ var empty = ($(notification).find("p").length==0)
125
+ if (empty){
126
+ fadeOutChatNotification(notification)
127
+ }
128
+ }
129
+ }
130
+
131
+ function addTextToNotificationForSlug(slug,txt,type,name){
132
+ var notification = getChatNotificationForSlug(slug);
133
+ if(notification!=null){
134
+ addTextToNotification(notification,txt,type,name)
135
+ }
136
+ }
137
+
138
+ function removeTextFromNotificationForSlug(slug,name){
139
+ var notification = getChatNotificationForSlug(slug);
140
+ if(notification!=null){
141
+ removeTextFromNotification(notification,name)
142
+ }
143
+ }
144
+
145
+ function removeAllTextsFromNotificationForSlug(slug){
146
+ var notification = getChatNotificationForSlug(slug);
147
+ if(notification!=null){
148
+ removeAllTextsFromNotification(notification)
149
+ }
150
+ }
151
+
152
+
153
+ ////////////////////////
154
+ // Group notifications
155
+ ///////////////////////
156
+
157
+ function addNickToNotificationInGroup(roomName,nick){
158
+ if(isSlugGroup(roomName)){
159
+ addTextToNotificationForSlug(roomName,nick,"roomNotification",nick)
160
+ }
161
+ }
162
+
163
+ function removeNickFromNotificationInGroup(roomName,nick){
164
+ if(isSlugGroup(roomName)){
165
+ removeTextFromNotificationForSlug(roomName,nick)
166
+ }
167
+ }
168
+
169
+ function initialNotificationInGroup(roomName,msg){
170
+ removeAllTextsFromNotificationForSlug(roomName);
171
+ addTextToNotificationForSlug(roomName,msg,"roomNotification","Initial_Notification")
172
+ }
173
+
174
+ function changeInitialNotificationInGroup(roomName,msg){
175
+ var notification = getChatNotificationForSlug(roomName);
176
+ if(notification!=null){
177
+ $(notification).find("p.ui-chatbox-notify-text[name=" + "Initial_Notification" + "]").html(msg)
178
+ }
179
+ }
180
+
181
+
182
+ ////////////////////
183
+ //Events
184
+ ////////////////////
185
+
186
+ function onClickChatNotification(notification){
187
+ if (getNotificationType(notification)=="roomNotification"){
188
+ return;
189
+ }
190
+ fadeOutChatNotification(notification)
191
+ }
@@ -2,7 +2,6 @@
2
2
  // Store and restore conversations using session storage.
3
3
  ////////////////////
4
4
 
5
-
6
5
  function storeChatData(){
7
6
 
8
7
  //Check for Session Storage support
@@ -25,19 +24,25 @@ function storeChatStatus(){
25
24
  }
26
25
 
27
26
  function storeConversations() {
28
-
29
27
  var chatboxes = getAllChatBoxes();
30
28
  var visibleChatBoxes = getVisibleChatBoxes();
31
29
  var storedSlugs = [];
30
+ var storedGroupSlugs = [];
32
31
  var visibleMaxSlugs = [];
33
32
  var visibleMinSlugs = [];
34
33
 
35
34
  //Stored all conversations
36
35
  for (var i=0;i<chatboxes.length;i++){
37
36
  var slug = chatboxes[i].id
38
- var log = $(chatboxes[i]).html()
39
- sessionStorage.setItem("chat_log_" + slug, log);
40
- storedSlugs.push(slug)
37
+ if(isSlugGroup(slug)){
38
+ if(visibleChatBoxes.indexOf(getChatBoxForSlug(slug))!=-1){
39
+ storedGroupSlugs.push(slug)
40
+ }
41
+ } else {
42
+ var log = $(chatboxes[i]).html()
43
+ sessionStorage.setItem("chat_log_" + slug, log);
44
+ storedSlugs.push(slug)
45
+ }
41
46
  }
42
47
 
43
48
  if(storedSlugs.length>0){
@@ -47,6 +52,13 @@ function storeConversations() {
47
52
  sessionStorage.setItem("slugs_with_stored_log", null);
48
53
  }
49
54
 
55
+ if(storedGroupSlugs.length>0){
56
+ //Stored open groups slugs
57
+ sessionStorage.setItem("open_group_slugs", storedGroupSlugs.join(","));
58
+ } else {
59
+ sessionStorage.setItem("open_group_slugs", null);
60
+ }
61
+
50
62
  //Stored slugs with visible chatbox
51
63
  for (var j=0;j<visibleChatBoxes.length;j++){
52
64
  if(visibleChatBoxes[j].is(":visible")){
@@ -80,6 +92,7 @@ function removeAllDataStored(){
80
92
  sessionStorage.removeItem("slugs_with_stored_log");
81
93
  sessionStorage.removeItem("slugs_with_visible_max_chatbox");
82
94
  sessionStorage.removeItem("slugs_with_visible_min_chatbox");
95
+ sessionStorage.removeItem("open_group_slugs");
83
96
  }
84
97
 
85
98
  function getRestoreUserChatStatus(){
@@ -95,7 +108,6 @@ function getRestoreUserChatStatus(){
95
108
  }
96
109
  }
97
110
 
98
-
99
111
  function restoreChatData(){
100
112
 
101
113
  //Check for Session Storage support
@@ -103,10 +115,9 @@ function restoreChatData(){
103
115
  return
104
116
  }
105
117
 
106
- restoreConversations();
118
+ restoreChatBoxes();
107
119
  }
108
120
 
109
-
110
121
  function getRestoreMainChatBoxStatus(){
111
122
  if (!window.sessionStorage) {
112
123
  return false;
@@ -119,76 +130,79 @@ function getRestoreMainChatBoxStatus(){
119
130
  }
120
131
  }
121
132
 
122
- function restoreConversations() {
133
+ function restoreChatBoxes(){
123
134
 
124
- //Get Stored slugs
125
- var storedSlugsString = sessionStorage.getItem("slugs_with_stored_log");
135
+ //Get slugs with visible chatbox
136
+ var visibleMaxSlugsString = sessionStorage.getItem("slugs_with_visible_max_chatbox");
137
+ var visibleMinSlugsString = sessionStorage.getItem("slugs_with_visible_min_chatbox");
138
+
139
+ if(visibleMaxSlugsString!=null){
140
+ var visibleMaxSlugs = visibleMaxSlugsString.split(",")
141
+ } else {
142
+ var visibleMaxSlugs = [];
143
+ }
144
+
145
+ if(visibleMinSlugsString!=null){
146
+ var visibleMinSlugs = visibleMinSlugsString.split(",")
147
+ } else {
148
+ var visibleMinSlugs = [];
149
+ }
150
+
151
+ restoreBuddyChatBoxes(visibleMaxSlugs,visibleMinSlugs);
152
+ restoreGroupsChatBoxes(visibleMaxSlugs,visibleMinSlugs);
153
+ }
154
+
155
+ function restoreGroupsChatBoxes(visibleMaxSlugs,visibleMinSlugs){
156
+ var groupSlugsString = sessionStorage.getItem("open_group_slugs")
157
+ if((groupSlugsString != null)&&(groupSlugsString != "null")){
158
+ var groupSlugs=groupSlugsString.split(",")
126
159
 
127
- if (storedSlugsString != null){
128
- var storedSlugs=storedSlugsString.split(",")
129
-
130
- //Get slugs with visible chatbox
131
- var visibleMaxSlugsString = sessionStorage.getItem("slugs_with_visible_max_chatbox");
132
- var visibleMinSlugsString = sessionStorage.getItem("slugs_with_visible_min_chatbox");
133
-
134
- if(visibleMaxSlugsString!=null){
135
- var visibleMaxSlugs = visibleMaxSlugsString.split(",")
136
- } else {
137
- var visibleMaxSlugs = [];
138
- }
139
-
140
- if(visibleMinSlugsString!=null){
141
- var visibleMinSlugs = visibleMinSlugsString.split(",")
142
- } else {
143
- var visibleMinSlugs = [];
144
- }
145
-
160
+ for (var i=0;i<groupSlugs.length;i++){
161
+ var guest_slug = groupSlugs[i]
162
+ var guest_name = getNameFromSlug(guest_slug)
163
+ var open = (visibleMinSlugs.indexOf(guest_slug)==-1)
164
+ accessRoom(guest_slug,open)
165
+ }
166
+ }
167
+ }
168
+
169
+ function restoreBuddyChatBoxes(visibleMaxSlugs,visibleMinSlugs) {
170
+ //Get Stored slugs
171
+ var storedSlugsString = sessionStorage.getItem("slugs_with_stored_log");
172
+
173
+ if (storedSlugsString != null){
174
+ var storedSlugs=storedSlugsString.split(",")
175
+
176
+ for (var i=0;i<storedSlugs.length;i++){
177
+ var restoreLog = sessionStorage.getItem("chat_log_" + storedSlugs[i]);
146
178
 
147
- for (var i=0;i<storedSlugs.length;i++){
148
- var restoreLog = sessionStorage.getItem("chat_log_" + storedSlugs[i]);
179
+ if (restoreLog != null){
180
+
181
+ var guest_slug = storedSlugs[i];
182
+ var guest_name = getNameFromSlug(guest_slug)
183
+ var guest_jid = guest_slug + "@" + domain;
184
+ createBuddyChatBox(guest_slug)
185
+
186
+ if ((visibleMinSlugs.indexOf(guest_slug)!=-1)){
187
+ //Minimize chatbox
188
+ window[getChatVariableFromSlug(guest_slug)].parent().toggle(false);
189
+ }
190
+ if ((visibleMaxSlugs.indexOf(guest_slug)==-1)&&(visibleMinSlugs.indexOf(guest_slug)==-1)){
191
+ closeChatBox(guest_slug);
192
+ }
149
193
 
150
- if (restoreLog != null){
151
-
152
- //Create window (if it not exists)
153
-
154
- var guest_slug = storedSlugs[i];
155
-
156
- //Check for slug name and connectionBox visibility
157
- if (typeof($('div.user_presence[slug=' + guest_slug + ']').attr('name')) == 'undefined') {
158
- //No connectionBox for this user (user disconnect)
159
- var guest_name = getNameFromSlug(guest_slug)
160
- } else {
161
- var guest_name = $('div.user_presence[slug=' + guest_slug + ']').attr('name');
162
- }
163
-
164
- var guest_jid = guest_slug + "@" + domain;
165
-
166
-
167
- if (createChatBox(guest_slug, guest_name, guest_jid, user_name, user_jid)) {
168
- if ((visibleMinSlugs.indexOf(guest_slug)!=-1)){
169
- //Minimize chatbox
170
- window[getChatVariableFromSlug(guest_slug)].parent().toggle(false);
171
- }
172
- if ((visibleMaxSlugs.indexOf(guest_slug)==-1)&&(visibleMinSlugs.indexOf(guest_slug)==-1)){
173
- closeChatBox(guest_slug);
174
- }
175
- } else {
176
- //Always created.
177
- }
178
-
179
- window[getChatVariableFromSlug(guest_slug)].html(restoreLog)
180
-
181
- if (! isSlugChatConnected(guest_slug)) {
182
- showOfflineChatNotificationForSlug(guest_slug);
183
- }
184
-
194
+ getChatBoxForSlug(guest_slug).html(restoreLog)
195
+
196
+ if (! isSlugChatConnected(guest_slug)) {
197
+ showOfflineChatNotificationForSlug(guest_slug);
185
198
  }
186
- }
187
- }
199
+
200
+ }
201
+ }
202
+ }
188
203
  }
189
204
 
190
205
 
191
-
192
206
  ////////////////////
193
207
  // Events
194
208
  ////////////////////
@@ -1,8 +1,6 @@
1
- var global;
2
1
  ////////////////////
3
2
  //Reconnect button interface functions
4
3
  ////////////////////
5
-
6
4
  var connectButtonTimer;
7
5
  var periodBetweenAttempts=15; //(seg)
8
6
  var connectButtonTimerCounter=periodBetweenAttempts+1;
@@ -38,11 +36,9 @@ function changeChatHeaderTitle(msg){
38
36
  ////////////////////
39
37
  //Chat interface: Setting Functions
40
38
  ////////////////////
41
-
42
39
  var focusSearchContactsFlag=false;
43
40
  var changeSelectContactValueFlag = false;
44
41
 
45
-
46
42
  function settingStatusSelector(){
47
43
  //JQuery DropdwanStatus
48
44
  $(".dropdown dt a").click(function(event) {
@@ -81,18 +77,11 @@ function settingStatusSelector(){
81
77
  });
82
78
  }
83
79
 
84
-
85
80
  function settingChatBoxFunctions(){
86
81
 
87
82
  $("div.user_presence").click(function(event, ui){
88
- var guest_name = $(this).attr("name");
89
83
  var guest_slug = $(this).attr("slug");
90
- var guest_jid = guest_slug + "@" + domain;
91
-
92
- if (createChatBox(guest_slug, guest_name, guest_jid, user_name, user_jid)) {
93
- } else {
94
- getChatBoxForSlug(guest_slug).chatbox("option", "boxManager").toggleBox(true);
95
- };
84
+ createBuddyChatBox(guest_slug)
96
85
  });
97
86
 
98
87
  //Hide tooltips on mouseleave
@@ -161,18 +150,11 @@ function setAllUserFunctions(){
161
150
  settingTooltips();
162
151
  }
163
152
 
164
-
165
153
  function changeSelectContactValue(name,valueSelectedInSearchContacts){
166
154
 
167
155
  if((valueSelectedInSearchContacts != "ZERO_CONTACTS")&&(valueSelectedInSearchContacts != "")){
168
156
  var guest_slug = valueSelectedInSearchContacts;
169
- var guest_name = getNameFromSlug(guest_slug);
170
- var guest_jid = guest_slug + "@" + domain;
171
-
172
- if (createChatBox(guest_slug, guest_name, guest_jid, user_name, user_jid)) {
173
- } else {
174
- window[getChatVariableFromSlug(guest_slug)].chatbox("option", "boxManager").toggleBox(true);
175
- };
157
+ createBuddyChatBox(guest_slug)
176
158
 
177
159
  //Check for online status and show notification
178
160
  if (! isSlugChatConnected(guest_slug)) {
@@ -184,7 +166,6 @@ function changeSelectContactValue(name,valueSelectedInSearchContacts){
184
166
  changeContactListVisibility(false);
185
167
  }
186
168
 
187
-
188
169
  function changeContactListVisibility(visible){
189
170
  var nItems = getAllSlugsLength();
190
171
  if (visible){
@@ -202,7 +183,6 @@ function changeContactListVisibility(visible){
202
183
  }
203
184
  }
204
185
 
205
-
206
186
  function setStatusWidgetTitle(status){
207
187
 
208
188
  if((status in sstreamChatStatus)){
@@ -279,7 +259,7 @@ function updateChatWindow(){
279
259
  updateConnectedUsersOfMainChatBox();
280
260
  return;
281
261
  }
282
-
262
+
283
263
  $.post("/chatWindow", { }, function(data){
284
264
  //Prevent tooltips
285
265
  $(".tooltip").hide()
@@ -293,13 +273,21 @@ function updateChatWindow(){
293
273
  afterNewConnectionFlag = false;
294
274
  if(afterFirstConnectionFlag){
295
275
  restoreChatData();
276
+ if(typeof current_group_slug != 'undefined') {
277
+ accessRoom(current_group_slug,false);
278
+ }
296
279
  afterFirstConnectionFlag = false;
297
280
  } else {
298
281
  updateAllNotifications();
282
+ //Rejoin rooms
283
+ $.each(getAllSlugsWithVisibleGroupBoxes(), function(index, value) {
284
+ accessRoom(value,$(value).is(":visible"))
285
+ });
299
286
  }
300
287
  }
301
288
  }
302
- });
289
+ },'html');
290
+
303
291
  }
304
292
 
305
293
 
@@ -341,7 +329,6 @@ function loadDisconnectionDiv(){
341
329
  }
342
330
  }
343
331
 
344
-
345
332
  function loadWidgetsDiv(data){
346
333
  $("#chat_partial").html(modifyChatPartialIfMainBox($("#chat_widgets").html()));
347
334
  $("#chat_partial").append(data);
@@ -357,7 +344,13 @@ function fillSearchContactSelect(){
357
344
  });
358
345
  }
359
346
 
360
-
347
+ function updateInterfaceAfterUserDisconnect(){
348
+ updateNotificationsAfterUserDisconnect();
349
+ $.each(getAllSlugsWithVisibleVideoBoxes(), function(index, value) {
350
+ closeVideoSession(value);
351
+ });
352
+
353
+ }
361
354
 
362
355
  /////////////////////
363
356
  // Connection Box Management
@@ -436,7 +429,7 @@ function isSlugChatConnected(slug){
436
429
  }
437
430
 
438
431
  function existsSlugChatBox(slug){
439
- return getConnectionBoxFromSlug(slug)!=null;
432
+ return getChatBoxForSlug(slug)!=null;
440
433
  }
441
434
 
442
435
  function getConnectedSlugsLength(){
@@ -485,36 +478,33 @@ function getAllSlugsByChatConnectedState(){
485
478
  //Insert received message in chatbox
486
479
  ////////////////////
487
480
 
488
- function putReceivedMessageOnChatWindow(from_jid,from_slug,body,msgID){
489
-
481
+ function afterReceivedChatMessage(from_slug,msg,msgID){
490
482
  //Antiflood control
491
- if (antifloodControl(from_jid,from_slug,body,msgID)){
483
+ if (antifloodControl(from_slug,msg,msgID)){
492
484
  return;
493
- }
494
-
495
- //Check slugs connectionBox
496
- if (!existsSlugChatBox(from_slug)) {
497
- //No connectionBox for this user!
498
- var from_name = getNameFromSlug(from_slug);
499
- if(! isAdminSlug(from_slug)){
500
- updateChatWindow();
501
- }
502
- } else {
503
- var from_name = $('div.user_presence[slug=' + from_slug + ']').attr('name');
485
+ }
486
+ var from_name = getNameFromSlug(from_slug)
487
+ createBuddyChatBox(from_slug)
488
+ writeReceivedMessageOnChatWindow(from_name,from_slug,msg)
489
+ }
490
+
491
+ function afterReceivedGroupChatMessage(room_nick_jid,msg){
492
+ var from_slug = getSlugFromJid(room_nick_jid)
493
+ var from_name = getNickFromChatRoomJid(room_nick_jid)
494
+
495
+ if(!(existsSlugChatBox(from_slug))){
496
+ createGroupChatBox(from_slug,true)
504
497
  }
498
+ writeReceivedMessageOnChatWindow(from_name,from_slug,msg)
499
+ }
505
500
 
506
- //Create or toggle from_slug's chatBox.
507
- if (createChatBox(from_slug, from_name, from_jid, user_name, user_jid)) {
508
- } else {
509
- window[getChatVariableFromSlug(from_slug)].chatbox("option", "boxManager").toggleBox(true);
510
- }
511
-
501
+ function writeReceivedMessageOnChatWindow(from_name,from_slug,msg){
512
502
  //Parse content before show it.
513
- var content = getParsedContent(Strophe.getText(body), false)
503
+ var content = getParsedContent(msg, false)
514
504
  var headerMessage = getParsedName(from_name,false);
515
505
 
516
- //Show message to chatBox.
517
- $("#" + from_slug).chatbox("option", "boxManager").addMsg(headerMessage, content);
506
+ //Write message in chatBox.
507
+ getChatBoxForSlug(from_slug).chatbox("option", "boxManager").addMsg(headerMessage, content);
518
508
 
519
509
  //Rotate chatBoxes priority.
520
510
  rotatePriority(from_slug);
@@ -523,89 +513,9 @@ function putReceivedMessageOnChatWindow(from_jid,from_slug,body,msgID){
523
513
  blinkTitleOnMessage(from_name);
524
514
 
525
515
  //Check for play sound
526
- if (mustPlaySoundForChatWindow(window[getChatVariableFromSlug(from_slug)])) {
516
+ if (mustPlaySoundForChatWindow(getChatBoxForSlug(from_slug))) {
527
517
  playSound("onMessageAudio");
528
- }
529
-
530
- }
531
-
532
-
533
- ////////////////////
534
- //Notifications on chat Window
535
- ////////////////////
536
-
537
- function showChatNotification(notification,type,msg){
538
- notification.html("<p notification_type=\"" + type + "\" class=\"ui-chatbox-notify-text\">" + msg + "</p>");
539
- notification.css("display","block");
540
- notification.css("visibility","visible");
541
- notification.fadeIn();
542
- }
543
-
544
- function showChatNotificationForSlug(slug,type,msg){
545
- var notification = $("#" + slug).parent().find("div.ui-chatbox-notify");
546
- if(notification.length==1){
547
- showChatNotification(notification,type,msg);
548
- }
549
- }
550
-
551
- function showOfflineChatNotificationForSlug(slug){
552
- var msg = I18n.t("chat.notify.guestOffline", {name: getNameFromSlug(slug)});
553
- showChatNotificationForSlug(slug,"guestOffline",msg);
554
- }
555
-
556
- function showVideoChatNotificationForSlug(slug,msg){
557
- showChatNotificationForSlug(slug,"videochat",msg);
558
- }
559
-
560
- function showVideoChatNotificationForSlugClientIssue(slug){
561
- var msg = I18n.t("chat.notify.videochat.clientIssue", {name: getNameFromSlug(slug)});
562
- showVideoChatNotificationForSlug(slug,msg);
563
- }
564
-
565
- function showVideoChatNotificationForSlugClientOffline(slug){
566
- var msg = I18n.t("chat.notify.videochat.offline", {name: getNameFromSlug(slug)});
567
- showVideoChatNotificationForSlug(slug,msg);
568
- }
569
-
570
- function hideChatNotification(notification){
571
- notification.fadeOut();
572
- notification.css("display","none");
573
- notification.css("visibility","hidden");
574
- }
575
-
576
- function hideChatNotificationForSlug(slug){
577
- var notification = $("#" + slug).parent().find("div.ui-chatbox-notify");
578
- hideChatNotification(notification);
579
- }
580
-
581
- function updateInterfaceAfterUsersDisconnect(){
582
- updateNotificationsAfterUserDisconnect();
583
- $.each(getAllSlugsWithVisibleVideoBoxes(), function(index, value) {
584
- closeVideoSession(value);
585
- });
586
- }
587
-
588
- function updateNotificationsAfterUserDisconnect(){
589
- var notification = $("div.ui-chatbox-notify");
590
- var msg = I18n.t('chat.notify.offline');
591
- showChatNotification(notification,"userOffline",msg);
592
- }
593
-
594
- function hideAllNotifications(){
595
- var notification = $("div.ui-chatbox-notify");
596
- hideChatNotification(notification);
597
- }
598
-
599
- function updateAllNotifications(){
600
- hideAllNotifications();
601
- if(disconnectionFlag){
602
- updateNotificationsAfterUserDisconnect();
603
- } else {
604
- //Notification for offline contacts
605
- $.each(getAllDisconnectedSlugsWithChatBoxes(), function(index, value) {
606
- showOfflineChatNotificationForSlug(value)
607
- });
608
- }
518
+ }
609
519
  }
610
520
 
611
521