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
@@ -1,19 +1,12 @@
1
1
  ////////////////////
2
- //Test functions
2
+ //Debug functions
3
3
  ////////////////////
4
+ var sspresence_debugging=false;
4
5
 
5
6
  function log(msg) {
6
- //console.log(msg)
7
- }
8
-
9
- function simulate_new_user_connected(slug) {
10
- var stanza_test = '<presence xmlns="jabber:client" from="' + slug + '@localhost/27825459741328802387991286" to="demo@localhost/2517285379132880233667729">'
11
- onPresence(stanza_test);
12
- }
13
-
14
- function simulate_new_user_disconnected(slug) {
15
- var stanza_test = '<presence xmlns="jabber:client" type="unavailable" from="' + slug + '@localhost/27825459741328802387991286" to="demo@localhost/2517285379132880233667729">'
16
- onPresence(stanza_test);
7
+ if(sspresence_debugging){
8
+ console.log(msg)
9
+ }
17
10
  }
18
11
 
19
12
 
@@ -99,7 +92,7 @@ var timeBetweenMessages = 500; //mseconds
99
92
 
100
93
  //Return true when detects a text storm and control the text flood:
101
94
  //timeBetweenMessages is the minimum time that must elapse between the messages of the same contact.
102
- function antifloodControl(from_jid,from_slug,body,msgID) {
95
+ function antifloodControl(from_slug,msg,msgID) {
103
96
 
104
97
  if( from_slug in lastMessageTimes){
105
98
 
@@ -116,7 +109,7 @@ function antifloodControl(from_jid,from_slug,body,msgID) {
116
109
  var t = (new Date()).getTime();
117
110
  if(t - lastMessageTime < timeBetweenMessages) {
118
111
  //Flood detected
119
- return retryToShowMessage(from_jid,from_slug,body,msgID);
112
+ return retryToShowMessage(from_slug,msg,msgID);
120
113
  }
121
114
 
122
115
  //Check if is the first message of this user to be send.
@@ -128,7 +121,7 @@ function antifloodControl(from_jid,from_slug,body,msgID) {
128
121
  lastMessageTimes[from_slug][1].splice(0,1);
129
122
  } else {
130
123
  //Message is not the first on the queue
131
- return retryToShowMessage(from_jid,from_slug,body,msgID);
124
+ return retryToShowMessage(from_slug,msg,msgID);
132
125
  }
133
126
  }
134
127
 
@@ -144,13 +137,13 @@ function generateMessageID(){
144
137
  }
145
138
 
146
139
 
147
- function retryToShowMessage(from_jid,from_slug,body,msgID){
140
+ function retryToShowMessage(from_slug,msg,msgID){
148
141
  //Enque the message if isn't in the queue
149
142
  if (lastMessageTimes[from_slug][1].indexOf(msgID)==-1){
150
143
  lastMessageTimes[from_slug][1].push(msgID);
151
144
  }
152
145
 
153
- setTimeout(function(){putReceivedMessageOnChatWindow(from_jid,from_slug,body,msgID)}, timeBetweenMessages);
146
+ setTimeout(function(){afterReceivedChatMessage(from_slug,msg,msgID)}, timeBetweenMessages);
154
147
  return true;
155
148
  }
156
149
 
@@ -228,23 +221,6 @@ function offlineDataSendControl(){
228
221
  }
229
222
 
230
223
 
231
- ////////////////////
232
- //Build name from slug
233
- ////////////////////
234
-
235
- function getNameFromSlug(slug){
236
- var cname = slug.split("-");
237
- var name = "";
238
- for(i=0; i<cname.length; i++){
239
- if (i!=0){
240
- name = name + " ";
241
- }
242
- name = name + cname[i][0].toUpperCase() + cname[i].substring(1,cname[i].length);
243
- }
244
- return name;
245
- }
246
-
247
-
248
224
  ////////////////////
249
225
  //Special slugs management
250
226
  ////////////////////
@@ -3,7 +3,6 @@
3
3
  ////////////////////
4
4
  var opentok_apiKey = '<%=SocialStream::Presence.opentok_api_key%>';
5
5
 
6
-
7
6
  //Correspondence between slugs and session ids
8
7
  var slugOfSession = new Array();
9
8
  //slugOfSession['session_id'] = "slug";
@@ -11,7 +10,6 @@ var slugOfSession = new Array();
11
10
  ////////////////////
12
11
  //Videochat button actions
13
12
  ////////////////////
14
-
15
13
  function clickVideoChatButton(slug){
16
14
  var videoBoxVisibility = toggleVideoBoxForSlug(slug);
17
15
 
@@ -28,7 +26,6 @@ function closeVideoChatWindow(slug){
28
26
  return;
29
27
  }
30
28
 
31
-
32
29
  //Single variable for all slugs.
33
30
  var reconnectAttemptsVideo = 1;
34
31
 
@@ -87,7 +84,6 @@ function openVideoChatWindow(slug){
87
84
  }
88
85
 
89
86
 
90
-
91
87
  ////////////////////
92
88
  //Session establishment
93
89
  ////////////////////
@@ -134,7 +130,6 @@ function requestSessionIDAndTokenForVideoChat(slug){
134
130
  });
135
131
  }
136
132
 
137
-
138
133
  //VideoChat Session: Step 3
139
134
  function sendVideoChatRequestToUser(slug){
140
135
  contactsInfo[slug].videoChatStatus="waiting";
@@ -202,7 +197,6 @@ function closeVideoSession(slug){
202
197
  /////////////
203
198
  // Videochat interface functions
204
199
  ////////////
205
-
206
200
  function clientInfoReceivedTrigger(slug){
207
201
  //Check for videochat request
208
202
  if ((slug in contactsInfo)&&(contactsInfo[slug].videoChatStatus="negotiating")){
@@ -214,7 +208,6 @@ function showNotificationOnVideoBox(slug,msg){
214
208
  setVideoBoxContent(slug,"<p class=\"video-info\"> " + msg +" </p>");
215
209
  }
216
210
 
217
-
218
211
  function updateInterfaceAfterVideoRequestReceived(slug){
219
212
 
220
213
  if (contactsInfo[slug].videoChatStatus!="disconnected"){
@@ -224,13 +217,8 @@ function updateInterfaceAfterVideoRequestReceived(slug){
224
217
  contactsInfo[slug].videoChatStatus="pending";
225
218
  }
226
219
 
227
- var jid = slug+"@"+contactsInfo[slug].domain
228
-
229
- //Show chatbox
230
- if (createChatBox(slug, getNameFromSlug(slug), jid, user_name, user_jid)) {
231
- } else {
232
- getChatBoxForSlug(slug).chatbox("option", "boxManager").toggleBox(true);
233
- };
220
+ //Show or create chatbox
221
+ createBuddyChatBox(slug);
234
222
 
235
223
  var chatBox = getChatBoxForSlug(slug);
236
224
 
@@ -241,7 +229,6 @@ function updateInterfaceAfterVideoRequestReceived(slug){
241
229
  toggleVideoBoxForSlug(slug,true);
242
230
  }
243
231
 
244
-
245
232
  function showInvitationInVideoBox(slug){
246
233
  var title = "<p class=\"video-info\">" + I18n.t("chat.videochat.call", {name: getNameFromSlug(slug)}) + " </p>";
247
234
  var msg = title + "<p class=\"video-request\"> <a class=\"videoChatButton\" slug=\""+slug+"\" value=\"yes\">" + I18n.t("chat.videochat.accept") + "</a> -"
@@ -337,18 +324,17 @@ function clickVideoChangeChatButton(slug){
337
324
  togglePublisherDivOnVideoChat(slug);
338
325
  }
339
326
 
327
+
328
+
340
329
  ////////////////
341
330
  /// Tokbox management
342
331
  ////////////////
343
-
344
332
  var OPENTOK_PUBLISHER_WIDTH = 235;
345
333
  var OPENTOK_PUBLISHER_HEIGHT = 145;
346
334
 
347
335
  var OPENTOK_SUBSCRIBER_WIDTH = 235;
348
336
  var OPENTOK_SUBSCRIBER_HEIGHT = 145;
349
337
 
350
-
351
-
352
338
  function initVideoCallWith(slug){
353
339
  if (TB.checkSystemRequirements() != TB.HAS_REQUIREMENTS) {
354
340
  showNotificationOnVideoBox(slug,I18n.t('chat.videochat.requirements'));
@@ -365,7 +351,6 @@ function initVideoCallWith(slug){
365
351
  }
366
352
  }
367
353
 
368
-
369
354
  function sessionConnectedHandler(event) {
370
355
  if (event.target.sessionId in slugOfSession){
371
356
  var slug = slugOfSession[event.target.sessionId];
@@ -400,7 +385,6 @@ function sessionConnectedHandler(event) {
400
385
  }
401
386
  }
402
387
 
403
-
404
388
  function sessionDisconnectedHandler(event) {
405
389
  // This signals that the user was disconnected from the Session. Any subscribers and publishers
406
390
  // will automatically be removed. This default behaviour can be prevented using event.preventDefault()
@@ -410,7 +394,6 @@ function sessionDisconnectedHandler(event) {
410
394
  contactsInfo[slug].videoChatStatus="disconnected";
411
395
  }
412
396
 
413
-
414
397
  function streamCreatedHandler(event) {
415
398
  var slug = slugOfSession[event.target.sessionId];
416
399
  subscribeToStreams(event.streams,slug);
@@ -420,11 +403,9 @@ function streamDestroyedHandler(event) {
420
403
  // This signals that a stream was destroyed. Any Subscribers will automatically be removed.
421
404
  // This default behaviour can be prevented using event.preventDefault()
422
405
  var slug = slugOfSession[event.target.sessionId];
423
- log("streamDestroyedHandler: se destruyo el stream de " + slug)
424
406
  closeVideoSession(slug);
425
407
  }
426
408
 
427
-
428
409
  function subscribeToStreams(streams,slug) {
429
410
  var session = contactsInfo[slug].session
430
411
 
@@ -452,7 +433,6 @@ function subscribeToStreams(streams,slug) {
452
433
  }
453
434
  }
454
435
 
455
-
456
436
  function accessAllowed(event){
457
437
  var slug = event.target.replacedDivId.split("&")[1];
458
438
  togglePublisherDivOnVideoChat(slug);
@@ -2,6 +2,9 @@
2
2
  //Chat Window Manager functions
3
3
  ////////////////////
4
4
 
5
+ ////////////////////
6
+ //ChatBoxes Creation
7
+ ////////////////////
5
8
  var nBox = 0;
6
9
  var maxBox = 5;
7
10
  var chatBoxWidth = 230;
@@ -12,24 +15,29 @@ var offsetForFlowBox = 0;
12
15
  var chatBoxSeparation = chatBoxWidth+12;
13
16
 
14
17
 
15
- function createChatBox(guest_slug,guest_name,guest_jid,user_name,user_jid){
18
+ //Create chatbox for new conversations
19
+ //Open chatbox for old conversations
20
+ function createChatBox(guest_slug,isGroup){
21
+
22
+ var guest_name = getNameFromSlug(guest_slug)
16
23
 
17
- //Create chatbox for new conversations
18
- //Open chatbox for old conversations
19
-
24
+ if(isGroup){
25
+ var chatBoxTitle = I18n.t("chat.muc.group", {group: guest_name})
26
+ } else {
27
+ var chatBoxTitle = guest_name;
28
+ }
29
+
20
30
  //Box Variable name = getChatVariableFromSlug(guest_slug)
21
31
  if (typeof window[getChatVariableFromSlug(guest_slug)] == 'undefined') {
22
32
 
23
33
  //Add div with id = guest_slug
24
34
  $("#chat_divs").append("<div id=" + guest_slug + " name=" + guest_name + " class=chatbox ></div>")
25
35
 
26
-
27
36
  //Offset Management for new box
28
37
  boxParams = getBoxParams();
29
38
  var offset = boxParams[0];
30
39
  var position = boxParams[1];
31
40
 
32
-
33
41
  window[getChatVariableFromSlug(guest_slug)] = $("#" + guest_slug).chatbox({id: user_name,
34
42
  user:{key : "value"},
35
43
  hidden: false,
@@ -37,21 +45,19 @@ function createChatBox(guest_slug,guest_name,guest_jid,user_name,user_jid){
37
45
  width: chatBoxWidth, // width of the chatbox
38
46
  height: chatBoxHeight, // height of the chatbox
39
47
  video: 0, //height of the videoBox
40
- title : guest_name,
48
+ title : chatBoxTitle,
41
49
  position: position,
42
50
  priority: visibleChatBoxes.length+1,
51
+ groupBox: isGroup,
43
52
  boxClosed: function(id) {
44
53
  closeChatBox(guest_slug)
45
54
  },
46
55
 
47
- messageSent : function(id, user, msg) {
48
- rotatePriority(guest_slug);
49
- var headerMessage = getParsedName(id,true);
50
- $("#" + guest_slug).chatbox("option", "boxManager").addMsg(headerMessage, getParsedContent(msg,true));
51
- sendChatMessage(user_jid,guest_jid,msg);
52
- }});
56
+ messageSent: function(id, user, msg){
57
+ sendChatMessage(guest_slug, msg)
58
+ }});
53
59
 
54
- visibleChatBoxes[position-1] = window[getChatVariableFromSlug(guest_slug)];
60
+ visibleChatBoxes[position-1] = window[getChatVariableFromSlug(guest_slug)];
55
61
 
56
62
  return true;
57
63
 
@@ -72,8 +78,7 @@ function createChatBox(guest_slug,guest_name,guest_jid,user_name,user_jid){
72
78
  window[getChatVariableFromSlug(guest_slug)].chatbox("option", "hidden", false);
73
79
  window[getChatVariableFromSlug(guest_slug)].parent().toggle(true)
74
80
  return false;
75
- }
76
-
81
+ }
77
82
  }
78
83
 
79
84
  function getBoxParams(){
@@ -101,9 +106,8 @@ function getBoxParams(){
101
106
  return boxParams
102
107
  }
103
108
 
104
-
105
109
  function closeChatBox(guest_slug){
106
- var position = $("#" + guest_slug).chatbox("option", "position");
110
+ var position = getChatBoxForSlug(guest_slug).chatbox("option", "position");
107
111
 
108
112
  for (i=position+1;i<visibleChatBoxes.length+1;i++){
109
113
  visibleChatBoxes[i-1].chatbox("option", "offset", visibleChatBoxes[i-1].chatbox("option", "offset") - chatBoxSeparation);
@@ -113,118 +117,179 @@ function closeChatBox(guest_slug){
113
117
  visibleChatBoxes.splice(position-1,1);
114
118
  $("#" + guest_slug).chatbox("option", "hidden", true);
115
119
  nBox--;
120
+
121
+ if(isSlugGroup(guest_slug)){
122
+ leaveRoom(guest_slug)
123
+ }
124
+
116
125
  }
117
126
 
118
127
 
119
- /////////
120
- //Getters
121
- /////////
122
-
123
- function getChatVariableFromSlug(slug){
124
- return "slug_" + slug;
125
- }
126
-
127
- function getSlugFromChatVariable(variable){
128
- return variable.split("_")[1];
129
- }
130
-
131
- function getVisibleChatBoxes(){
132
- for(i=0; i<visibleChatBoxes.length; i++){
133
- if (visibleChatBoxes[i][0].id==chatSlugId){
134
- visibleChatBoxes.splice(i,1)
135
- }
136
- }
137
- return visibleChatBoxes
128
+ ////////////////
129
+ //Create Buddy chatBox
130
+ ////////////////
131
+ function createBuddyChatBox(guest_slug){
132
+ return createChatBox(guest_slug,false);
138
133
  }
139
134
 
140
135
 
141
- function getAllChatBoxes(){
142
- return $(".chatbox").not(document.getElementById(chatSlugId))
143
- }
136
+ ///////////////////////////
137
+ // Create Group Chat Box
138
+ ///////////////////////////
144
139
 
145
- function getChatBoxForSlug(slug){
146
- if (typeof window[getChatVariableFromSlug(slug)] == 'undefined') {
147
- return null;
140
+ function createGroupChatBox(group_slug,open){
141
+
142
+ //createChatBox(guest_slug,isGroup)
143
+ if (createChatBox(group_slug,true)){
144
+
145
+ var groupChatBox = getChatBoxForSlug(group_slug);
146
+
147
+ //Modify default box
148
+
149
+ //Delete video Tick
150
+ $(getChatBoxButtonForSlug(group_slug,"video")).remove();
151
+
152
+ //Delete video div
153
+ $(groupChatBox.parent()).find(".ui-videobox").remove();
154
+
155
+ //Minimize
156
+ groupChatBox.parent().toggle(open);
157
+
158
+ //Initial notifications
159
+ initialNotificationInGroup(group_slug,I18n.t('chat.muc.joining'))
160
+
161
+ return true;
148
162
  } else {
149
- return window[getChatVariableFromSlug(slug)];
150
- }
163
+ return false;
164
+ }
151
165
  }
152
166
 
153
- function getChatBoxHeaderForSlug(slug){
154
- var chatBox = getChatBoxForSlug(slug);
155
- if(chatBox!=null){
156
- return chatBox.parent().parent().find(".ui-chatbox-titlebar")
157
- } else {
158
- return null;
159
- }
160
- }
161
167
 
162
- function getChatBoxButtonsForSlug(slug){
163
- var chatBoxHeader = getChatBoxHeaderForSlug(slug);
164
- if(chatBoxHeader!=null){
165
- return chatBoxHeader.find(".ui-chatbox-icon");
166
- } else {
167
- return null;
168
- }
169
- }
168
+ ///////////////////////////
169
+ // Create Main Chat Box
170
+ ///////////////////////////
170
171
 
171
- function getChatBoxButtonForSlug(slug,button){
172
- var chatBoxButtons = getChatBoxButtonsForSlug(slug);
173
- if(chatBoxButtons!=null){
174
- switch (button){
175
- case "close":
176
- return chatBoxButtons[0];
177
- break;
178
- case "min":
179
- return chatBoxButtons[1];
180
- break;
181
- case "video":
182
- return chatBoxButtons[2];
183
- break;
184
- case "videoChange":
185
- return chatBoxButtons[3];
186
- break;
187
- default : return null;
188
- }
189
- } else {
190
- return null;
191
- }
172
+ var mainChatBox;
173
+ var connectionBoxesForFile=5;
174
+ var maxConnectionChatBoxesFilesWithoutOverflow = 11;
175
+ var mainChatBoxWidth=150;
176
+ var mainChatBoxaddonsHeight=50;
177
+ var heightForConnectionBoxFile=30;
178
+ var mainChatBoxHeightWhileSearchContacts=260;
179
+ var mainChatBoxMinHeight=136;
180
+ var mainChatBoxMaxHeight= mainChatBoxaddonsHeight + heightForConnectionBoxFile*maxConnectionChatBoxesFilesWithoutOverflow;
181
+ var chatSlugId="SocialStream_MainChat";
182
+
183
+ function createMainChatBox(){
184
+ if (mainChatBox==null){
185
+ //createChatBox(guest_slug,isGroup)
186
+ createChatBox(chatSlugId,false)
187
+ mainChatBox = window[getChatVariableFromSlug(chatSlugId)]
188
+
189
+ //Modify default box
190
+
191
+ //Delete closeTick and video Tick
192
+ $(mainChatBox.parent().parent()).find(".ui-chatbox-titlebar").find(".ui-icon-closethick").remove();
193
+ $(mainChatBox.parent().parent()).find(".ui-videobox-icon").remove();
194
+ //Margin for minusthick
195
+ (mainChatBox.parent().parent()).find(".ui-chatbox-titlebar").find(".chat-minusthick").parent().css("margin-right","5px")
196
+ //Delete nofitications div
197
+ $(mainChatBox.parent()).find(".ui-chatbox-notify").remove();
198
+ //Delete video div
199
+ $(mainChatBox.parent()).find(".ui-videobox").remove();
200
+ //Delete input
201
+ $(mainChatBox.parent()).find(".ui-chatbox-input").remove();
202
+ //Background
203
+ $(mainChatBox).css("background-color",$(mainChatBox.parent().parent()).find(".ui-chatbox-titlebar").css("background-color"));
204
+
205
+ //Set height
206
+ changeMainChatBoxHeight(getChatBoxHeightRequiredForConnectionBoxes());
207
+
208
+ //Set width
209
+ window[getChatVariableFromSlug(chatSlugId)].parent().parent().css( "width", mainChatBoxWidth );
210
+ $(mainChatBox.parent().parent()).find(".ui-chatbox-titlebar").css( "width", mainChatBoxWidth-6 );
211
+ $(mainChatBox).css( "width", mainChatBoxWidth-6 );
212
+
213
+
214
+ //Adjust window offset
215
+ offsetForFlowBox = 235-mainChatBoxWidth;
216
+
217
+ //CSS Adjusts
218
+ $("#chat_partial").css("margin-top",-3)
219
+ $("#chat_partial").css("margin-left",-3)
220
+ $(".dropdown dd ul").css("min-width",147)
221
+ $(mainChatBox).css('overflow-x','hidden')
222
+ $(mainChatBox).css('overflow-y','hidden')
223
+
224
+ //Minimize
225
+ mainChatBox.parent().toggle(getRestoreMainChatBoxStatus());
226
+
227
+ //Header title
228
+ updateConnectedUsersOfMainChatBox();
229
+ }
192
230
  }
193
231
 
232
+ //////////////////////////
233
+ // Main Chat Box functions
234
+ //////////////////////////
194
235
 
195
- function getAllSlugsWithChatOrVideoBoxes(){
196
- var slugsWithChatBox = [];
197
- var slugsWithVideoBox = [];
198
- $.each(getAllChatBoxes(), function(index, value) {
199
- if($(value).parent().find(".ui-videobox").is(":visible")){
200
- slugsWithVideoBox.push($(value).attr("id"))
201
- }
202
- slugsWithChatBox.push($(value).attr("id"))
203
- });
204
- return [slugsWithChatBox,slugsWithVideoBox];
236
+ function addContentToMainChatBox(content){
237
+ if (mainChatBox != null) {
238
+ $(mainChatBox.parent()).find("#" + chatSlugId).html(content);
239
+ }
205
240
  }
206
241
 
207
- function getAllSlugsWithChatBoxes(){
208
- return getAllSlugsWithChatOrVideoBoxes()[0];
242
+ function modifyChatPartialIfMainBox(chatPartial){
243
+ if (mainChatBox != null) {
244
+ p = $(chatPartial)
245
+ $(p).find(".header").remove();
246
+ $(p).find(".dropdown dd ul").css("min-width",147);
247
+ return $(p);
248
+ }
249
+
250
+ return chatPartial;
209
251
  }
210
252
 
211
- function getAllSlugsWithVisibleVideoBoxes(){
212
- return getAllSlugsWithChatOrVideoBoxes()[1];
253
+ function changeMainChatBoxHeaderTitle(title){
254
+ if (mainChatBox != null) {
255
+ $($(mainChatBox.parent().parent()).find(".ui-chatbox-titlebar").find("span")[0]).html(title);
256
+ }
213
257
  }
214
258
 
215
- function getAllDisconnectedSlugsWithChatBoxes(){
216
- var slugsWithChatBox = getAllSlugsWithChatBoxes();
217
- var slugsConnected = getAllConnectedSlugs();
218
- var allDisconnectedSlugsWithChatBox = [];
219
-
220
- $.each(slugsWithChatBox, function(index, value) {
221
- if (slugsConnected.indexOf(value)==-1){
222
- allDisconnectedSlugsWithChatBox.push(value);
223
- }
224
- });
225
- return allDisconnectedSlugsWithChatBox;
259
+ function changeMainChatBoxHeight(height){
260
+ if (mainChatBox != null) {
261
+
262
+ if(($("#chat_partial #search_chat_contact_flexselect").is(":focus"))&&(! (focusSearchContactsFlag))){
263
+ return;
264
+ } else {
265
+ focusSearchContactsFlag=false;
266
+ }
267
+
268
+ if(height > mainChatBoxMaxHeight){
269
+ //overflow = true;
270
+ height = mainChatBoxMaxHeight;
271
+ $(mainChatBox).css('overflow-y','visible');
272
+ mainChatBox.chatbox("option", "offset","5px")
273
+ mainChatBox.chatbox("option", "width", mainChatBoxWidth + 5)
274
+ } else {
275
+ $(mainChatBox).css('overflow-y','hidden');
276
+ mainChatBox.chatbox("option", "offset","0px")
277
+ mainChatBox.chatbox("option", "width",mainChatBoxWidth)
278
+ height = Math.max(height,mainChatBoxMinHeight)
279
+ }
280
+
281
+ window[getChatVariableFromSlug(chatSlugId)].css("height", height);
282
+ }
226
283
  }
227
284
 
285
+ function getChatBoxHeightRequiredForConnectionBoxes(){
286
+ if(mainChatBox!=null){
287
+ var desiredHeight = mainChatBoxaddonsHeight + Math.ceil(getAllConnectedSlugs().length/connectionBoxesForFile) * heightForConnectionBoxFile;
288
+ return desiredHeight;
289
+ } else {
290
+ return null;
291
+ }
292
+ }
228
293
 
229
294
 
230
295
  ////////////////////
@@ -243,7 +308,6 @@ function getBoxIndexToReplace(){
243
308
  return visibleChatBoxes.indexOf(tmp);
244
309
  }
245
310
 
246
-
247
311
  function rotatePriority(guest_slug){
248
312
  priority = $("#" + guest_slug).chatbox("option", "priority")
249
313
  if(priority>1){
@@ -257,7 +321,6 @@ function rotatePriority(guest_slug){
257
321
  }
258
322
 
259
323
 
260
-
261
324
  ////////////////////
262
325
  //Video Window Manager functions
263
326
  ////////////////////
@@ -302,7 +365,6 @@ function hideVideoBox(chatBox){
302
365
  chatBox.chatbox("option", "video", 0);
303
366
  }
304
367
 
305
-
306
368
  //Function called from JQuery UI Plugin
307
369
  function toggleVideoBox(uiElement){
308
370
  var slug = $(uiElement.element).attr("id");
@@ -345,134 +407,130 @@ function toggleVideoBoxForSlug(slug,force){
345
407
  }
346
408
 
347
409
 
410
+ /////////
411
+ //Getters
412
+ /////////
413
+ function getChatVariableFromSlug(slug){
414
+ return "Slug_" + slug;
415
+ }
348
416
 
417
+ function getSlugFromChatVariable(variable){
418
+ return variable.split("_")[1];
419
+ }
349
420
 
350
- ///////////////////////////
351
- // Create Main Chat Box
352
- ///////////////////////////
421
+ function getVisibleChatBoxes(){
422
+ for(i=0; i<visibleChatBoxes.length; i++){
423
+ if (visibleChatBoxes[i][0].id==chatSlugId){
424
+ visibleChatBoxes.splice(i,1)
425
+ }
426
+ }
427
+ return visibleChatBoxes
428
+ }
353
429
 
354
- var mainChatBox;
355
- var connectionBoxesForFile=5;
356
- var maxConnectionChatBoxesFilesWithoutOverflow = 11;
357
- var mainChatBoxWidth=150;
358
- var mainChatBoxaddonsHeight=50;
359
- var heightForConnectionBoxFile=30;
360
- var mainChatBoxHeightWhileSearchContacts=260;
361
- var mainChatBoxMinHeight=136;
362
- var mainChatBoxMaxHeight= mainChatBoxaddonsHeight + heightForConnectionBoxFile*maxConnectionChatBoxesFilesWithoutOverflow;
363
- var chatSlugId="SocialStream_MainChat";
364
430
 
365
- function createMainChatBox(){
366
- if (mainChatBox==null){
367
-
368
- //createChatBox(guest_slug,guest_name,guest_jid,user_name,user_jid)
369
- if (createChatBox(chatSlugId,"Chat","Any","Any","Any")){
370
- mainChatBox = window[getChatVariableFromSlug(chatSlugId)]
371
-
372
- //Modify default box
373
-
374
- //Delete closeTick and video Tick
375
- $(mainChatBox.parent().parent()).find(".ui-chatbox-titlebar").find(".ui-icon-closethick").remove();
376
- $(mainChatBox.parent().parent()).find(".ui-videobox-icon").remove();
377
- //Margin for minusthick
378
- (mainChatBox.parent().parent()).find(".ui-chatbox-titlebar").find(".chat-minusthick").parent().css("margin-right","5px")
379
- //Delete nofitications div
380
- $(mainChatBox.parent()).find(".ui-chatbox-notify").remove();
381
- //Delete video div
382
- $(mainChatBox.parent()).find(".ui-videobox").remove();
383
- //Delete input
384
- $(mainChatBox.parent()).find(".ui-chatbox-input").remove();
385
- //Background
386
- $(mainChatBox).css("background-color",$(mainChatBox.parent().parent()).find(".ui-chatbox-titlebar").css("background-color"));
387
-
388
- //Set height
389
- changeMainChatBoxHeight(getChatBoxHeightRequiredForConnectionBoxes());
390
-
391
- //Set width
392
- window[getChatVariableFromSlug(chatSlugId)].parent().parent().css( "width", mainChatBoxWidth );
393
- $(mainChatBox.parent().parent()).find(".ui-chatbox-titlebar").css( "width", mainChatBoxWidth-6 );
394
- $(mainChatBox).css( "width", mainChatBoxWidth-6 );
395
-
396
-
397
- //Adjust window offset
398
- offsetForFlowBox = 235-mainChatBoxWidth;
399
-
400
- //CSS Adjusts
401
- $("#chat_partial").css("margin-top",-3)
402
- $("#chat_partial").css("margin-left",-3)
403
- $(".dropdown dd ul").css("min-width",147)
404
- $(mainChatBox).css('overflow-x','hidden')
405
- $(mainChatBox).css('overflow-y','hidden')
406
-
407
- //Minimize
408
- mainChatBox.parent().toggle(getRestoreMainChatBoxStatus());
409
-
410
- //Header title
411
- updateConnectedUsersOfMainChatBox();
412
- }
413
- }
431
+ function getAllChatBoxes(){
432
+ return $(".chatbox").not(document.getElementById(chatSlugId))
414
433
  }
415
434
 
416
-
417
- function addContentToMainChatBox(content){
418
- if (mainChatBox != null) {
419
- $(mainChatBox.parent()).find("#" + chatSlugId).html(content);
435
+ function getChatBoxForSlug(slug){
436
+ if (typeof window[getChatVariableFromSlug(slug)] == 'undefined') {
437
+ return null;
438
+ } else {
439
+ return window[getChatVariableFromSlug(slug)];
420
440
  }
421
441
  }
422
442
 
443
+ function getChatBoxHeaderForSlug(slug){
444
+ var chatBox = getChatBoxForSlug(slug);
445
+ if(chatBox!=null){
446
+ return chatBox.parent().parent().find(".ui-chatbox-titlebar")
447
+ } else {
448
+ return null;
449
+ }
450
+ }
423
451
 
424
- function modifyChatPartialIfMainBox(chatPartial){
425
- if (mainChatBox != null) {
426
- p = $(chatPartial)
427
- $(p).find(".header").remove();
428
- $(p).find(".dropdown dd ul").css("min-width",147);
429
- return $(p);
452
+ function getChatBoxButtonsForSlug(slug){
453
+ var chatBoxHeader = getChatBoxHeaderForSlug(slug);
454
+ if(chatBoxHeader!=null){
455
+ return chatBoxHeader.find(".ui-chatbox-icon");
456
+ } else {
457
+ return null;
430
458
  }
431
-
432
- return chatPartial;
433
459
  }
434
460
 
435
- function changeMainChatBoxHeaderTitle(title){
436
- if (mainChatBox != null) {
437
- $($(mainChatBox.parent().parent()).find(".ui-chatbox-titlebar").find("span")[0]).html(title);
461
+ function getChatBoxButtonForSlug(slug,button){
462
+ var chatBoxButtons = getChatBoxButtonsForSlug(slug);
463
+ if(chatBoxButtons!=null){
464
+ switch (button){
465
+ case "close":
466
+ return chatBoxButtons[0];
467
+ break;
468
+ case "min":
469
+ return chatBoxButtons[1];
470
+ break;
471
+ case "video":
472
+ return chatBoxButtons[2];
473
+ break;
474
+ case "videoChange":
475
+ return chatBoxButtons[3];
476
+ break;
477
+ default : return null;
478
+ }
479
+ } else {
480
+ return null;
438
481
  }
439
482
  }
440
483
 
441
484
 
442
- function changeMainChatBoxHeight(height){
443
- if (mainChatBox != null) {
444
-
445
- if(($("#chat_partial #search_chat_contact_flexselect").is(":focus"))&&(! (focusSearchContactsFlag))){
446
- return;
447
- } else {
448
- focusSearchContactsFlag=false;
449
- }
450
-
451
- if(height > mainChatBoxMaxHeight){
452
- //overflow = true;
453
- height = mainChatBoxMaxHeight;
454
- $(mainChatBox).css('overflow-y','visible');
455
- mainChatBox.chatbox("option", "offset","5px")
456
- mainChatBox.chatbox("option", "width", mainChatBoxWidth + 5)
457
- } else {
458
- $(mainChatBox).css('overflow-y','hidden');
459
- mainChatBox.chatbox("option", "offset","0px")
460
- mainChatBox.chatbox("option", "width",mainChatBoxWidth)
461
- height = Math.max(height,mainChatBoxMinHeight)
485
+ function getAllSlugsWithChatOrVideoBoxes(){
486
+ var slugsWithChatBox = [];
487
+ var slugsWithVideoBox = [];
488
+ $.each(getAllChatBoxes(), function(index, value) {
489
+ if($(value).parent().find(".ui-videobox").is(":visible")){
490
+ slugsWithVideoBox.push($(value).attr("id"))
462
491
  }
463
-
464
- window[getChatVariableFromSlug(chatSlugId)].css("height", height);
465
- }
492
+ slugsWithChatBox.push($(value).attr("id"))
493
+ });
494
+ return [slugsWithChatBox,slugsWithVideoBox];
466
495
  }
467
496
 
497
+ function getAllSlugsWithChatBoxes(){
498
+ return getAllSlugsWithChatOrVideoBoxes()[0];
499
+ }
468
500
 
469
- function getChatBoxHeightRequiredForConnectionBoxes(){
470
- if(mainChatBox!=null){
471
- var desiredHeight = mainChatBoxaddonsHeight + Math.ceil(getAllConnectedSlugs().length/connectionBoxesForFile) * heightForConnectionBoxFile;
472
- return desiredHeight;
473
- } else {
474
- return null;
475
- }
501
+ function getAllSlugsWithVisibleVideoBoxes(){
502
+ return getAllSlugsWithChatOrVideoBoxes()[1];
503
+ }
504
+
505
+ function getAllDisconnectedSlugsWithChatBoxes(){
506
+ var slugsWithChatBox = getAllSlugsWithChatBoxes();
507
+ var slugsConnected = getAllConnectedSlugs();
508
+ var allDisconnectedSlugsWithChatBox = [];
509
+
510
+ $.each(slugsWithChatBox, function(index, value) {
511
+ if (slugsConnected.indexOf(value)==-1){
512
+ allDisconnectedSlugsWithChatBox.push(value);
513
+ }
514
+ });
515
+ return allDisconnectedSlugsWithChatBox;
516
+ }
517
+
518
+ function isSlugGroup(slug){
519
+ var chatBox = getChatBoxForSlug(slug)
520
+ if(chatBox!=null){
521
+ return chatBox.chatbox("option", "groupBox")
522
+ } else {
523
+ return false
524
+ }
476
525
  }
477
526
 
478
527
 
528
+ function getAllSlugsWithVisibleGroupBoxes(){
529
+ var groupBoxes = []
530
+ $.each(getVisibleChatBoxes(), function(index, value) {
531
+ if ($(value).chatbox("option", "groupBox")){
532
+ groupBoxes.push($(value).attr("id"));
533
+ }
534
+ });
535
+ return groupBoxes;
536
+ }