social_stream 0.26.1 → 0.26.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. data/README.rdoc +10 -0
  2. data/base/lib/social_stream/base/version.rb +1 -1
  3. data/base/social_stream-base.gemspec +1 -1
  4. data/lib/social_stream/release/component.rb +5 -0
  5. data/lib/social_stream/release/global.rb +8 -7
  6. data/lib/social_stream/release/kernel.rb +24 -0
  7. data/lib/social_stream/version.rb +1 -1
  8. data/presence/app/assets/javascripts/jquery.flexselect.sstreampresence.js +2 -2
  9. data/presence/app/assets/javascripts/jquery.ui.chatbox.sstreampresence.js +5 -5
  10. data/presence/app/assets/javascripts/presence.js.erb +6 -4
  11. data/presence/app/assets/javascripts/presence_XmppClient.js.erb +1146 -996
  12. data/presence/app/assets/javascripts/presence_audio.js.erb +74 -60
  13. data/presence/app/assets/javascripts/presence_game.js.erb +35 -22
  14. data/presence/app/assets/javascripts/presence_game_comunication.js.erb +22 -5
  15. data/presence/app/assets/javascripts/presence_game_factory.js.erb +1 -1
  16. data/presence/app/assets/javascripts/presence_game_interface.js.erb +33 -13
  17. data/presence/app/assets/javascripts/presence_notifications.js +206 -183
  18. data/presence/app/assets/javascripts/presence_parser.js +265 -247
  19. data/presence/app/assets/javascripts/presence_persistence.js +199 -188
  20. data/presence/app/assets/javascripts/presence_store.js +22 -11
  21. data/presence/app/assets/javascripts/presence_uiManager.js.erb +553 -530
  22. data/presence/app/assets/javascripts/presence_utilities.js +244 -219
  23. data/presence/app/assets/javascripts/presence_videochat.js.erb +436 -409
  24. data/presence/app/assets/javascripts/presence_windowManager.js +586 -532
  25. data/presence/app/views/chat/_index.html.erb +7 -13
  26. data/presence/config/locales/en.yml +2 -1
  27. data/presence/config/locales/es.yml +2 -1
  28. data/presence/ejabberd/ejabberd_files.zip +0 -0
  29. data/presence/ejabberd/ejabberd_scripts/authentication_script +9 -2
  30. data/presence/ejabberd/mod_sspresence/mod_sspresence.beam +0 -0
  31. data/presence/lib/generators/social_stream/presence/templates/initializer.rb +4 -0
  32. data/presence/lib/social_stream-presence.rb +3 -0
  33. data/presence/lib/social_stream/presence/version.rb +1 -1
  34. data/presence/lib/social_stream/presence/xmpp_server_order.rb +1 -0
  35. data/release.thor +33 -13
  36. data/social_stream.gemspec +2 -2
  37. metadata +90 -29
@@ -1,543 +1,597 @@
1
1
  ////////////////////
2
- //Chat Window Manager functions
2
+ //WINDOW MANAGER MODULE
3
3
  ////////////////////
4
4
 
5
- ////////////////////
6
- //ChatBoxes Creation
7
- ////////////////////
8
- var nBox = 0;
9
- var maxBox = 5;
10
- var chatBoxWidth = 230;
11
- var chatBoxHeight = 180;
12
- var videoBoxHeight = 145;
13
- var visibleChatBoxes = new Array();
14
- var offsetForFlowBox = 0;
15
- var chatBoxSeparation = chatBoxWidth+12;
16
-
17
-
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)
23
-
24
- if(isGroup){
25
- var chatBoxTitle = I18n.t("chat.muc.group", {group: guest_name})
26
- } else {
27
- var chatBoxTitle = guest_name;
28
- }
29
-
30
- //Box Variable name = getChatVariableFromSlug(guest_slug)
31
- if (typeof window[getChatVariableFromSlug(guest_slug)] == 'undefined') {
32
-
33
- //Add div with id = guest_slug
34
- $("#chat_divs").append("<div id=" + guest_slug + " name=" + guest_name + " class=chatbox ></div>")
35
-
36
- //Offset Management for new box
37
- boxParams = getBoxParams();
38
- var offset = boxParams[0];
39
- var position = boxParams[1];
40
-
41
- window[getChatVariableFromSlug(guest_slug)] = $("#" + guest_slug).chatbox({id: user_name,
42
- user:{key : "value"},
43
- hidden: false,
44
- offset: offset, // relative to right edge of the browser window
45
- width: chatBoxWidth, // width of the chatbox
46
- height: chatBoxHeight, // height of the chatbox
47
- video: 0, //height of the videoBox
48
- title : chatBoxTitle,
49
- position: position,
50
- priority: visibleChatBoxes.length+1,
51
- groupBox: isGroup,
52
- boxClosed: function(id) {
53
- closeChatBox(guest_slug)
54
- },
55
-
56
- messageSent: function(id, user, msg){
57
- sendChatMessage(guest_slug, msg)
58
- }});
59
-
60
- visibleChatBoxes[position-1] = window[getChatVariableFromSlug(guest_slug)];
61
-
62
- return true;
63
-
64
- } else {
65
-
66
- if (visibleChatBoxes.indexOf(window[getChatVariableFromSlug(guest_slug)]) == -1) {
67
-
68
- //Offset Management for old box
69
- boxParams = getBoxParams();
70
- var offset = boxParams[0];
71
- var position = boxParams[1];
72
-
73
- window[getChatVariableFromSlug(guest_slug)].chatbox("option", "offset", offset);
74
- window[getChatVariableFromSlug(guest_slug)].chatbox("option", "position", position);
75
- visibleChatBoxes[position-1] = window[getChatVariableFromSlug(guest_slug)];
76
- }
77
-
78
- window[getChatVariableFromSlug(guest_slug)].chatbox("option", "hidden", false);
79
- window[getChatVariableFromSlug(guest_slug)].parent().toggle(true)
80
- return false;
81
- }
82
- }
83
-
84
- function getBoxParams(){
85
-
86
- var boxParams = new Array(2);
87
-
88
- if (nBox==maxBox){
89
- //Select box to replaced
90
- replaced = visibleChatBoxes[getBoxIndexToReplace()];
91
- replaced.chatbox("option", "hidden", true)
92
- index = visibleChatBoxes.indexOf(replaced);
93
- boxParams[0] = replaced.chatbox("option", "offset")
94
- boxParams[1] = replaced.chatbox("option", "position")
95
- } else {
96
- nBox++;
97
- boxParams[0] = (nBox-1)*(chatBoxSeparation);
98
-
99
- if((nBox!=1)&&(mainChatBox!=null)){
100
- boxParams[0] = boxParams[0] - offsetForFlowBox;
101
- }
102
-
103
- boxParams[1] = nBox;
104
- }
105
-
106
- return boxParams
107
- }
108
-
109
- function closeChatBox(guest_slug){
110
- var position = getChatBoxForSlug(guest_slug).chatbox("option", "position");
111
-
112
- for (i=position+1;i<visibleChatBoxes.length+1;i++){
113
- visibleChatBoxes[i-1].chatbox("option", "offset", visibleChatBoxes[i-1].chatbox("option", "offset") - chatBoxSeparation);
114
- visibleChatBoxes[i-1].chatbox("option", "position", visibleChatBoxes[i-1].chatbox("option", "position") - 1 );
115
- }
116
-
117
- visibleChatBoxes.splice(position-1,1);
118
- $("#" + guest_slug).chatbox("option", "hidden", true);
119
- nBox--;
120
-
121
- if(isSlugGroup(guest_slug)){
122
- leaveRoom(guest_slug)
123
- }
124
-
125
- }
126
-
127
-
128
- ////////////////
129
- //Create Buddy chatBox
130
- ////////////////
131
- function createBuddyChatBox(guest_slug){
132
- return createChatBox(guest_slug,false);
133
- }
134
-
135
-
136
- ///////////////////////////
137
- // Create Group Chat Box
138
- ///////////////////////////
139
-
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 games Tick
150
- $(getChatBoxButtonForSlug(group_slug,"games")).remove()
151
-
152
- //Delete video Tick
153
- $(getChatBoxButtonForSlug(group_slug,"video")).remove();
154
-
155
- //Delete video div
156
- $(groupChatBox.parent()).find(".ui-videobox").remove();
157
-
158
- //Minimize
159
- groupChatBox.parent().toggle(open);
160
-
161
- //Initial notifications
162
- initialNotificationInGroup(group_slug,I18n.t('chat.muc.joining'))
163
-
164
- return true;
165
- } else {
166
- return false;
167
- }
168
- }
169
-
170
-
171
- ///////////////////////////
172
- // Create Main Chat Box
173
- ///////////////////////////
174
-
175
- var mainChatBox;
176
- var connectionBoxesForFile=5;
177
- var maxConnectionChatBoxesFilesWithoutOverflow = 11;
178
- var mainChatBoxWidth=150;
179
- var mainChatBoxaddonsHeight=50;
180
- var heightForConnectionBoxFile=30;
181
- var mainChatBoxHeightWhileSearchContacts=260;
182
- var mainChatBoxMinHeight=136;
183
- var mainChatBoxMaxHeight= mainChatBoxaddonsHeight + heightForConnectionBoxFile*maxConnectionChatBoxesFilesWithoutOverflow;
184
- var chatSlugId="SocialStream_MainChat";
185
-
186
- function createMainChatBox(){
187
- if (mainChatBox==null){
188
- //createChatBox(guest_slug,isGroup)
189
- createChatBox(chatSlugId,false)
190
- mainChatBox = window[getChatVariableFromSlug(chatSlugId)]
191
-
192
- //Modify default box
193
-
194
- //Delete closeTick, video Tick and games tick
195
- $(mainChatBox.parent().parent()).find(".ui-chatbox-titlebar").find(".ui-icon-closethick").remove();
196
- $(mainChatBox.parent().parent()).find(".ui-videobox-icon").remove();
197
- $(mainChatBox.parent().parent()).find(".chat-gamesthick").remove();
198
-
199
- //Margin for minusthick
200
- (mainChatBox.parent().parent()).find(".ui-chatbox-titlebar").find(".chat-minusthick").parent().css("margin-right","5px")
201
- //Delete nofitications div
202
- $(mainChatBox.parent()).find(".ui-chatbox-notify").remove();
203
- //Delete video div
204
- $(mainChatBox.parent()).find(".ui-videobox").remove();
205
- //Delete input
206
- $(mainChatBox.parent()).find(".ui-chatbox-input").remove();
207
- //Background
208
- $(mainChatBox).css("background-color",$(mainChatBox.parent().parent()).find(".ui-chatbox-titlebar").css("background-color"));
209
-
210
- //Set height
211
- changeMainChatBoxHeight(getChatBoxHeightRequiredForConnectionBoxes());
212
-
213
- //Set width
214
- window[getChatVariableFromSlug(chatSlugId)].parent().parent().css( "width", mainChatBoxWidth );
215
- $(mainChatBox.parent().parent()).find(".ui-chatbox-titlebar").css( "width", mainChatBoxWidth-6 );
216
- $(mainChatBox).css( "width", mainChatBoxWidth-6 );
217
-
218
-
219
- //Adjust window offset
220
- offsetForFlowBox = 235-mainChatBoxWidth;
221
-
222
- //CSS Adjusts
223
- $("#chat_partial").css("margin-top",-3)
224
- $("#chat_partial").css("margin-left",-3)
225
- $(".dropdown dd ul").css("min-width",147)
226
- $(mainChatBox).css('overflow-x','hidden')
227
- $(mainChatBox).css('overflow-y','hidden')
228
-
229
- //Minimize
230
- mainChatBox.parent().toggle(getRestoreMainChatBoxStatus());
231
-
232
- //Header title
233
- updateConnectedUsersOfMainChatBox();
234
- }
235
- }
236
-
237
- //////////////////////////
238
- // Main Chat Box functions
239
- //////////////////////////
240
-
241
- function addContentToMainChatBox(content){
242
- if (mainChatBox != null) {
243
- $(mainChatBox.parent()).find("#" + chatSlugId).html(content);
244
- }
245
- }
246
-
247
- function modifyChatPartialIfMainBox(chatPartial){
248
- if (mainChatBox != null) {
249
- p = $(chatPartial)
250
- $(p).find(".header").remove();
251
- $(p).find(".dropdown dd ul").css("min-width",147);
252
- return $(p);
253
- }
254
-
255
- return chatPartial;
256
- }
257
-
258
- function changeMainChatBoxHeaderTitle(title){
259
- if (mainChatBox != null) {
260
- $($(mainChatBox.parent().parent()).find(".ui-chatbox-titlebar").find("span")[0]).html(title);
261
- }
262
- }
263
-
264
- function changeMainChatBoxHeight(height){
265
- if (mainChatBox != null) {
266
-
267
- if(($("#chat_partial #search_chat_contact_flexselect").is(":focus"))&&(! (focusSearchContactsFlag))){
268
- return;
269
- } else {
270
- focusSearchContactsFlag=false;
271
- }
272
-
273
- if(height > mainChatBoxMaxHeight){
274
- //overflow = true;
275
- height = mainChatBoxMaxHeight;
276
- $(mainChatBox).css('overflow-y','visible');
277
- mainChatBox.chatbox("option", "offset","5px")
278
- mainChatBox.chatbox("option", "width", mainChatBoxWidth + 5)
279
- } else {
280
- $(mainChatBox).css('overflow-y','hidden');
281
- mainChatBox.chatbox("option", "offset","0px")
282
- mainChatBox.chatbox("option", "width",mainChatBoxWidth)
283
- height = Math.max(height,mainChatBoxMinHeight)
284
- }
285
-
286
- window[getChatVariableFromSlug(chatSlugId)].css("height", height);
287
- }
288
- }
289
-
290
- function getChatBoxHeightRequiredForConnectionBoxes(){
291
- if(mainChatBox!=null){
292
- var desiredHeight = mainChatBoxaddonsHeight + Math.ceil(getAllConnectedSlugs().length/connectionBoxesForFile) * heightForConnectionBoxFile;
293
- return desiredHeight;
294
- } else {
295
- return null;
296
- }
297
- }
5
+ PRESENCE.WINDOW = (function(P,$,undefined){
298
6
 
299
-
300
- ////////////////////
301
- //Box replacement
302
- ////////////////////
303
-
304
- function getBoxIndexToReplace(){
305
-
306
- tmp = visibleChatBoxes[0];
307
- for (i=0;i<visibleChatBoxes.length;i++){
308
- if (visibleChatBoxes[i].chatbox("option", "priority") > tmp.chatbox("option", "priority")) {
309
- tmp = visibleChatBoxes[i];
310
- }
311
- }
312
-
313
- return visibleChatBoxes.indexOf(tmp);
314
- }
315
-
316
- function rotatePriority(guest_slug){
317
- priority = $("#" + guest_slug).chatbox("option", "priority")
318
- if(priority>1){
319
- for (i=0;i<visibleChatBoxes.length;i++){
320
- if(visibleChatBoxes[i].chatbox("option", "priority")<priority){
321
- visibleChatBoxes[i].chatbox("option", "priority",visibleChatBoxes[i].chatbox("option", "priority")+1);
322
- }
323
- }
324
- $("#" + guest_slug).chatbox("option", "priority", 1);
325
- }
326
- }
327
-
328
-
329
- ////////////////////
330
- //Video Window Manager functions
331
- ////////////////////
332
-
333
- function getVideoBoxForSlug(slug){
334
- var videoBox = $("#" + slug).parent().find("div.ui-videobox");
335
- if(videoBox.length == 1){
336
- return videoBox;
337
- } else {
338
- return null;
339
- }
340
- }
341
-
342
- function getPublisherVideoBoxForSlug(slug){
343
- var pubDiv = $("#stream_publish_videochat_" + slug);
344
- if (pubDiv.length > 0) {
345
- return pubDiv
346
- } else {
347
- return null;
348
- }
349
- }
350
-
351
- function setVideoBoxContent(slug,embed){
352
- var videoBox = getVideoBoxForSlug(slug);
353
- if(videoBox!=null){
354
- videoBox.html(embed);
355
- }
356
- }
357
-
358
- function addVideoBoxContent(slug,embed){
359
- var videoBox = getVideoBoxForSlug(slug);
360
- if(videoBox!=null){
361
- videoBox.append(embed);
362
- }
363
- }
364
-
365
- function showVideoBox(chatBox){
366
- chatBox.chatbox("option", "video",videoBoxHeight);
367
- }
368
-
369
- function hideVideoBox(chatBox){
370
- chatBox.chatbox("option", "video", 0);
371
- }
372
-
373
- //Function called from JQuery UI Plugin
374
- function toggleVideoBox(uiElement){
375
- var slug = $(uiElement.element).attr("id");
376
- clickVideoChatButton(slug);
377
- }
378
-
379
- //Function called from JQuery UI Plugin
380
- function toggleVideoBoxChange(uiElement){
381
- var slug = $(uiElement.element).attr("id");
382
- clickVideoChangeChatButton(slug);
383
- }
384
-
385
- function toggleVideoBoxForSlug(slug,force){
386
- var aux;
387
- var chatBox = getChatBoxForSlug(slug);
388
-
389
- if(chatBox==null) {
390
- return null;
391
- }
392
-
393
- if(typeof force != 'undefined'){
394
- aux = force;
395
- } else {
396
- if (chatBox.chatbox("option", "video")==0){
397
- aux=true;
7
+ var init = function(){ }
8
+
9
+ ////////////////////
10
+ //ChatBoxes Creation
11
+ ////////////////////
12
+ var nBox = 0;
13
+ var maxBox = 5;
14
+ var chatBoxWidth = 230;
15
+ var chatBoxHeight = 180;
16
+ var videoBoxHeight = 145;
17
+ var visibleChatBoxes = new Array();
18
+ var offsetForFlowBox = 0;
19
+ var chatBoxSeparation = chatBoxWidth+12;
20
+
21
+
22
+ //Create chatbox for new conversations
23
+ //Open chatbox for old conversations
24
+ var createChatBox = function(guest_slug,isGroup){
25
+
26
+ var guest_name = PRESENCE.XMPPClient.getNameFromSlug(guest_slug)
27
+
28
+ if(isGroup){
29
+ var chatBoxTitle = I18n.t("chat.muc.group", {group: guest_name})
30
+ } else {
31
+ var chatBoxTitle = guest_name;
32
+ }
33
+
34
+ //Box Variable name = getChatVariableFromSlug(guest_slug)
35
+ if (typeof window[getChatVariableFromSlug(guest_slug)] == 'undefined') {
36
+
37
+ //Add div with id = guest_slug
38
+ $("#chat_divs").append("<div id=" + guest_slug + " name=" + guest_name + " class=chatbox ></div>")
39
+
40
+ //Offset Management for new box
41
+ boxParams = getBoxParams();
42
+ var offset = boxParams[0];
43
+ var position = boxParams[1];
44
+
45
+ window[getChatVariableFromSlug(guest_slug)] = $("#" + guest_slug).chatbox({id: user_name,
46
+ user:{key : "value"},
47
+ hidden: false,
48
+ offset: offset, // relative to right edge of the browser window
49
+ width: chatBoxWidth, // width of the chatbox
50
+ height: chatBoxHeight, // height of the chatbox
51
+ video: 0, //height of the videoBox
52
+ title : chatBoxTitle,
53
+ position: position,
54
+ priority: visibleChatBoxes.length+1,
55
+ groupBox: isGroup,
56
+ boxClosed: function(id) {
57
+ PRESENCE.WINDOW.closeChatBox(guest_slug)
58
+ },
59
+
60
+ messageSent: function(id, user, msg){
61
+ PRESENCE.XMPPClient.sendChatMessage(guest_slug, msg)
62
+ }});
63
+
64
+ visibleChatBoxes[position-1] = window[getChatVariableFromSlug(guest_slug)];
65
+
66
+ return true;
67
+
68
+ } else {
69
+
70
+ if (visibleChatBoxes.indexOf(window[getChatVariableFromSlug(guest_slug)]) == -1) {
71
+
72
+ //Offset Management for old box
73
+ boxParams = getBoxParams();
74
+ var offset = boxParams[0];
75
+ var position = boxParams[1];
76
+
77
+ window[getChatVariableFromSlug(guest_slug)].chatbox("option", "offset", offset);
78
+ window[getChatVariableFromSlug(guest_slug)].chatbox("option", "position", position);
79
+ visibleChatBoxes[position-1] = window[getChatVariableFromSlug(guest_slug)];
80
+ }
81
+
82
+ window[getChatVariableFromSlug(guest_slug)].chatbox("option", "hidden", false);
83
+ window[getChatVariableFromSlug(guest_slug)].parent().toggle(true)
84
+ return false;
85
+ }
86
+ }
87
+
88
+ var getBoxParams = function(){
89
+
90
+ var boxParams = new Array(2);
91
+
92
+ if (nBox==maxBox){
93
+ //Select box to replaced
94
+ replaced = visibleChatBoxes[getBoxIndexToReplace()];
95
+ replaced.chatbox("option", "hidden", true)
96
+ index = visibleChatBoxes.indexOf(replaced);
97
+ boxParams[0] = replaced.chatbox("option", "offset")
98
+ boxParams[1] = replaced.chatbox("option", "position")
99
+ } else {
100
+ nBox++;
101
+ boxParams[0] = (nBox-1)*(chatBoxSeparation);
102
+
103
+ if((nBox!=1)&&(mainChatBox!=null)){
104
+ boxParams[0] = boxParams[0] - offsetForFlowBox;
105
+ }
106
+
107
+ boxParams[1] = nBox;
108
+ }
109
+
110
+ return boxParams
111
+ }
112
+
113
+ var closeChatBox = function(guest_slug){
114
+ var position = getChatBoxForSlug(guest_slug).chatbox("option", "position");
115
+
116
+ for (i=position+1;i<visibleChatBoxes.length+1;i++){
117
+ visibleChatBoxes[i-1].chatbox("option", "offset", visibleChatBoxes[i-1].chatbox("option", "offset") - chatBoxSeparation);
118
+ visibleChatBoxes[i-1].chatbox("option", "position", visibleChatBoxes[i-1].chatbox("option", "position") - 1 );
119
+ }
120
+
121
+ visibleChatBoxes.splice(position-1,1);
122
+ $("#" + guest_slug).chatbox("option", "hidden", true);
123
+ nBox--;
124
+
125
+ if(isSlugGroup(guest_slug)){
126
+ PRESENCE.XMPPClient.leaveRoom(guest_slug)
127
+ }
128
+
129
+ }
130
+
131
+
132
+ ////////////////
133
+ //Create Buddy chatBox
134
+ ////////////////
135
+ var createBuddyChatBox = function(guest_slug){
136
+ return createChatBox(guest_slug,false);
137
+ }
138
+
139
+
140
+ ///////////////////////////
141
+ // Create Group Chat Box
142
+ ///////////////////////////
143
+
144
+ var createGroupChatBox = function(group_slug,open){
145
+
146
+ //createChatBox(guest_slug,isGroup)
147
+ if (createChatBox(group_slug,true)){
148
+
149
+ var groupChatBox = getChatBoxForSlug(group_slug);
150
+
151
+ //Modify default box
152
+
153
+ //Delete games Tick
154
+ $(getChatBoxButtonForSlug(group_slug,"games")).remove()
155
+
156
+ //Delete video Tick
157
+ $(getChatBoxButtonForSlug(group_slug,"video")).remove();
158
+
159
+ //Delete video div
160
+ $(groupChatBox.parent()).find(".ui-videobox").remove();
161
+
162
+ //Minimize
163
+ groupChatBox.parent().toggle(open);
164
+
165
+ //Initial notifications
166
+ PRESENCE.NOTIFICATIONS.initialNotificationInGroup(group_slug,I18n.t('chat.muc.joining'))
167
+
168
+ return true;
398
169
  } else {
399
- aux=false;
170
+ return false;
400
171
  }
401
172
  }
402
173
 
403
- if (aux){
404
- //Show
405
- showVideoBox(chatBox);
406
- return true;
407
- } else {
408
- //Hide
409
- hideVideoBox(chatBox);
410
- return false;
411
- }
412
- }
413
-
414
-
415
- /////////
416
- //Getters
417
- /////////
418
- function getChatVariableFromSlug(slug){
419
- return "Slug_" + slug;
420
- }
421
-
422
- function getSlugFromChatVariable(variable){
423
- return variable.split("_")[1];
424
- }
425
-
426
- function getVisibleChatBoxes(){
427
- for(i=0; i<visibleChatBoxes.length; i++){
428
- if (visibleChatBoxes[i][0].id==chatSlugId){
429
- visibleChatBoxes.splice(i,1)
430
- }
431
- }
432
- return visibleChatBoxes
433
- }
434
-
435
-
436
- function getAllChatBoxes(){
437
- return $(".chatbox").not(document.getElementById(chatSlugId))
438
- }
439
-
440
- function getChatBoxForSlug(slug){
441
- if (typeof window[getChatVariableFromSlug(slug)] == 'undefined') {
442
- return null;
443
- } else {
444
- return window[getChatVariableFromSlug(slug)];
445
- }
446
- }
447
-
448
- function getChatBoxHeaderForSlug(slug){
449
- var chatBox = getChatBoxForSlug(slug);
450
- if(chatBox!=null){
451
- return chatBox.parent().parent().find(".ui-chatbox-titlebar")
452
- } else {
453
- return null;
454
- }
455
- }
456
-
457
- function getChatBoxButtonsForSlug(slug){
458
- var chatBoxHeader = getChatBoxHeaderForSlug(slug);
459
- if(chatBoxHeader!=null){
460
- return chatBoxHeader.find(".ui-chatbox-icon");
461
- } else {
462
- return null;
463
- }
464
- }
465
-
466
- function getChatBoxButtonForSlug(slug,button){
467
- var chatBoxButtons = getChatBoxButtonsForSlug(slug);
468
- if(chatBoxButtons!=null){
469
- switch (button){
470
- case "close":
471
- return chatBoxButtons[0];
472
- break;
473
- case "min":
474
- return chatBoxButtons[1];
475
- break;
476
- case "video":
477
- return chatBoxButtons[2];
478
- break;
479
- case "videoChange":
480
- return chatBoxButtons[3];
481
- case "games":
482
- return chatBoxButtons[4];
483
- break;
484
- default : return null;
485
- }
486
- } else {
487
- return null;
488
- }
489
- }
490
-
491
-
492
- function getAllSlugsWithChatOrVideoBoxes(){
493
- var slugsWithChatBox = [];
494
- var slugsWithVideoBox = [];
495
- $.each(getAllChatBoxes(), function(index, value) {
496
- if($(value).parent().find(".ui-videobox").is(":visible")){
497
- slugsWithVideoBox.push($(value).attr("id"))
498
- }
499
- slugsWithChatBox.push($(value).attr("id"))
500
- });
501
- return [slugsWithChatBox,slugsWithVideoBox];
502
- }
503
-
504
- function getAllSlugsWithChatBoxes(){
505
- return getAllSlugsWithChatOrVideoBoxes()[0];
506
- }
507
-
508
- function getAllSlugsWithVisibleVideoBoxes(){
509
- return getAllSlugsWithChatOrVideoBoxes()[1];
510
- }
511
-
512
- function getAllDisconnectedSlugsWithChatBoxes(){
513
- var slugsWithChatBox = getAllSlugsWithChatBoxes();
514
- var slugsConnected = getAllConnectedSlugs();
515
- var allDisconnectedSlugsWithChatBox = [];
516
-
517
- $.each(slugsWithChatBox, function(index, value) {
518
- if (slugsConnected.indexOf(value)==-1){
519
- allDisconnectedSlugsWithChatBox.push(value);
520
- }
521
- });
522
- return allDisconnectedSlugsWithChatBox;
523
- }
174
+
175
+ ///////////////////////////
176
+ // Create Main Chat Box
177
+ ///////////////////////////
178
+
179
+ var mainChatBox;
180
+ var connectionBoxesForFile=5;
181
+ var maxConnectionChatBoxesFilesWithoutOverflow = 11;
182
+ var mainChatBoxWidth=150;
183
+ var mainChatBoxaddonsHeight=50;
184
+ var heightForConnectionBoxFile=30;
185
+ var mainChatBoxHeightWhileSearchContacts=260;
186
+ var mainChatBoxMinHeight=136;
187
+ var mainChatBoxMaxHeight= mainChatBoxaddonsHeight + heightForConnectionBoxFile*maxConnectionChatBoxesFilesWithoutOverflow;
188
+ var chatSlugId="SocialStream_MainChat";
189
+ var mainChatBoxParams = [mainChatBoxaddonsHeight,mainChatBoxHeightWhileSearchContacts];
190
+
191
+ var createMainChatBox = function(){
192
+ if (mainChatBox==null){
193
+ //createChatBox(guest_slug,isGroup)
194
+ createChatBox(chatSlugId,false)
195
+ mainChatBox = window[getChatVariableFromSlug(chatSlugId)]
196
+
197
+ //Modify default box
198
+
199
+ //Delete closeTick, video Tick and games tick
200
+ $(mainChatBox.parent().parent()).find(".ui-chatbox-titlebar").find(".ui-icon-closethick").remove();
201
+ $(mainChatBox.parent().parent()).find(".ui-videobox-icon").remove();
202
+ $(mainChatBox.parent().parent()).find(".chat-gamesthick").remove();
203
+
204
+ //Margin for minusthick
205
+ (mainChatBox.parent().parent()).find(".ui-chatbox-titlebar").find(".chat-minusthick").parent().css("margin-right","5px")
206
+ //Delete nofitications div
207
+ $(mainChatBox.parent()).find(".ui-chatbox-notify").remove();
208
+ //Delete video div
209
+ $(mainChatBox.parent()).find(".ui-videobox").remove();
210
+ //Delete input
211
+ $(mainChatBox.parent()).find(".ui-chatbox-input").remove();
212
+ //Background
213
+ $(mainChatBox).css("background-color",$(mainChatBox.parent().parent()).find(".ui-chatbox-titlebar").css("background-color"));
214
+
215
+ //Set height
216
+ changeMainChatBoxHeight(getChatBoxHeightRequiredForConnectionBoxes());
217
+
218
+ //Set width
219
+ window[getChatVariableFromSlug(chatSlugId)].parent().parent().css( "width", mainChatBoxWidth );
220
+ $(mainChatBox.parent().parent()).find(".ui-chatbox-titlebar").css( "width", mainChatBoxWidth-6 );
221
+ $(mainChatBox).css( "width", mainChatBoxWidth-6 );
222
+
223
+
224
+ //Adjust window offset
225
+ offsetForFlowBox = 235-mainChatBoxWidth;
226
+
227
+ //CSS Adjusts
228
+ $("#chat_partial").css("margin-top",-3)
229
+ $("#chat_partial").css("margin-left",-3)
230
+ $(".dropdown dd ul").css("min-width",147)
231
+ $(mainChatBox).css('overflow-x','hidden')
232
+ $(mainChatBox).css('overflow-y','hidden')
233
+
234
+ //Minimize
235
+ mainChatBox.parent().toggle(PRESENCE.PERSISTENCE.getRestoreMainChatBoxStatus());
236
+
237
+ //Header title
238
+ PRESENCE.UIMANAGER.updateConnectedUsersOfMainChatBox();
239
+ }
240
+ }
241
+
242
+ var getMainChatBox = function(){
243
+ return mainChatBox;
244
+ }
245
+
246
+ var getMainchatBoxParams = function(){
247
+ return mainChatBoxParams;
248
+ }
249
+
250
+ //////////////////////////
251
+ // Main Chat Box functions
252
+ //////////////////////////
253
+
254
+ var addContentToMainChatBox = function(content){
255
+ if (mainChatBox != null) {
256
+ $(mainChatBox.parent()).find("#" + chatSlugId).html(content);
257
+ }
258
+ }
259
+
260
+ var modifyChatPartialIfMainBox = function(chatPartial){
261
+ if (mainChatBox != null) {
262
+ p = $(chatPartial)
263
+ $(p).find(".header").remove();
264
+ $(p).find(".dropdown dd ul").css("min-width",147);
265
+ return $(p);
266
+ }
267
+
268
+ return chatPartial;
269
+ }
270
+
271
+ var changeMainChatBoxHeaderTitle = function(title){
272
+ if (mainChatBox != null) {
273
+ $($(mainChatBox.parent().parent()).find(".ui-chatbox-titlebar").find("span")[0]).html(title);
274
+ }
275
+ }
276
+
277
+ var changeMainChatBoxHeight = function(height){
278
+ if (mainChatBox != null) {
279
+
280
+ if(($("#chat_partial #search_chat_contact_flexselect").is(":focus"))&&(! (focusSearchContactsFlag))){
281
+ return;
282
+ } else {
283
+ focusSearchContactsFlag=false;
284
+ }
285
+
286
+ if(height > mainChatBoxMaxHeight){
287
+ //overflow = true;
288
+ height = mainChatBoxMaxHeight;
289
+ $(mainChatBox).css('overflow-y','visible');
290
+ mainChatBox.chatbox("option", "offset","5px")
291
+ mainChatBox.chatbox("option", "width", mainChatBoxWidth + 5)
292
+ } else {
293
+ $(mainChatBox).css('overflow-y','hidden');
294
+ mainChatBox.chatbox("option", "offset","0px")
295
+ mainChatBox.chatbox("option", "width",mainChatBoxWidth)
296
+ height = Math.max(height,mainChatBoxMinHeight)
297
+ }
298
+
299
+ window[getChatVariableFromSlug(chatSlugId)].css("height", height);
300
+ }
301
+ }
524
302
 
525
- function isSlugGroup(slug){
526
- var chatBox = getChatBoxForSlug(slug)
527
- if(chatBox!=null){
528
- return chatBox.chatbox("option", "groupBox")
529
- } else {
530
- return false
531
- }
532
- }
303
+ var getChatBoxHeightRequiredForConnectionBoxes = function(){
304
+ if(mainChatBox!=null){
305
+ var desiredHeight = mainChatBoxaddonsHeight + Math.ceil(PRESENCE.UIMANAGER.getAllConnectedSlugs().length/connectionBoxesForFile) * heightForConnectionBoxFile;
306
+ return desiredHeight;
307
+ } else {
308
+ return null;
309
+ }
310
+ }
311
+
312
+
313
+ ////////////////////
314
+ //Box replacement
315
+ ////////////////////
316
+
317
+ var getBoxIndexToReplace = function(){
318
+
319
+ tmp = visibleChatBoxes[0];
320
+ for (i=0;i<visibleChatBoxes.length;i++){
321
+ if (visibleChatBoxes[i].chatbox("option", "priority") > tmp.chatbox("option", "priority")) {
322
+ tmp = visibleChatBoxes[i];
323
+ }
324
+ }
325
+
326
+ return visibleChatBoxes.indexOf(tmp);
327
+ }
328
+
329
+ var rotatePriority = function(guest_slug){
330
+ priority = $("#" + guest_slug).chatbox("option", "priority")
331
+ if(priority>1){
332
+ for (i=0;i<visibleChatBoxes.length;i++){
333
+ if(visibleChatBoxes[i].chatbox("option", "priority")<priority){
334
+ visibleChatBoxes[i].chatbox("option", "priority",visibleChatBoxes[i].chatbox("option", "priority")+1);
335
+ }
336
+ }
337
+ $("#" + guest_slug).chatbox("option", "priority", 1);
338
+ }
339
+ }
340
+
341
+
342
+ ////////////////////
343
+ //Video Window Manager functions
344
+ ////////////////////
345
+
346
+ var getVideoBoxForSlug = function(slug){
347
+ var videoBox = $("#" + slug).parent().find("div.ui-videobox");
348
+ if(videoBox.length == 1){
349
+ return videoBox;
350
+ } else {
351
+ return null;
352
+ }
353
+ }
354
+
355
+ var getPublisherVideoBoxForSlug = function(slug){
356
+ var pubDiv = $("#stream_publish_videochat_" + slug);
357
+ if (pubDiv.length > 0) {
358
+ return pubDiv
359
+ } else {
360
+ return null;
361
+ }
362
+ }
363
+
364
+ var setVideoBoxContent = function(slug,embed){
365
+ var videoBox = getVideoBoxForSlug(slug);
366
+ if(videoBox!=null){
367
+ videoBox.html(embed);
368
+ }
369
+ }
370
+
371
+ var addVideoBoxContent = function(slug,embed){
372
+ var videoBox = getVideoBoxForSlug(slug);
373
+ if(videoBox!=null){
374
+ videoBox.append(embed);
375
+ }
376
+ }
377
+
378
+ var showVideoBox = function(chatBox){
379
+ chatBox.chatbox("option", "video",videoBoxHeight);
380
+ }
381
+
382
+ var hideVideoBox = function(chatBox){
383
+ chatBox.chatbox("option", "video", 0);
384
+ }
385
+
386
+ //Function called from JQuery UI Plugin
387
+ var toggleVideoBox = function(uiElement){
388
+ var slug = $(uiElement.element).attr("id");
389
+ PRESENCE.VIDEOCHAT.clickVideoChatButton(slug);
390
+ }
391
+
392
+ //Function called from JQuery UI Plugin
393
+ var toggleVideoBoxChange = function(uiElement){
394
+ var slug = $(uiElement.element).attr("id");
395
+ PRESENCE.VIDEOCHAT.clickVideoChangeChatButton(slug);
396
+ }
397
+
398
+ var toggleVideoBoxForSlug = function(slug,force){
399
+ var aux;
400
+ var chatBox = getChatBoxForSlug(slug);
401
+
402
+ if(chatBox==null) {
403
+ return null;
404
+ }
405
+
406
+ if(typeof force != 'undefined'){
407
+ aux = force;
408
+ } else {
409
+ if (chatBox.chatbox("option", "video")==0){
410
+ aux=true;
411
+ } else {
412
+ aux=false;
413
+ }
414
+ }
415
+
416
+ if (aux){
417
+ //Show
418
+ showVideoBox(chatBox);
419
+ return true;
420
+ } else {
421
+ //Hide
422
+ hideVideoBox(chatBox);
423
+ return false;
424
+ }
425
+ }
426
+
427
+
428
+ /////////
429
+ //Getters
430
+ /////////
431
+ var getChatVariableFromSlug = function(slug){
432
+ return "Slug_" + slug;
433
+ }
434
+
435
+ var getSlugFromChatVariable = function(variable){
436
+ return variable.split("_")[1];
437
+ }
438
+
439
+ var getVisibleChatBoxes = function(){
440
+ var tmp = new Array();
441
+ for(i=0; i<visibleChatBoxes.length; i++){
442
+ if (visibleChatBoxes[i][0].id!=chatSlugId){
443
+ tmp.push(visibleChatBoxes[i])
444
+ }
445
+ }
446
+ return tmp
447
+ }
533
448
 
449
+ var getAllChatBoxes = function(){
450
+ return $(".chatbox").not(document.getElementById(chatSlugId))
451
+ }
452
+
453
+ var getChatBoxForSlug = function(slug){
454
+ if (typeof window[getChatVariableFromSlug(slug)] == 'undefined') {
455
+ return null;
456
+ } else {
457
+ return window[getChatVariableFromSlug(slug)];
458
+ }
459
+ }
460
+
461
+ var getChatBoxHeaderForSlug = function(slug){
462
+ var chatBox = getChatBoxForSlug(slug);
463
+ if(chatBox!=null){
464
+ return chatBox.parent().parent().find(".ui-chatbox-titlebar")
465
+ } else {
466
+ return null;
467
+ }
468
+ }
469
+
470
+ var getChatBoxButtonsForSlug = function(slug){
471
+ var chatBoxHeader = getChatBoxHeaderForSlug(slug);
472
+ if(chatBoxHeader!=null){
473
+ return chatBoxHeader.find(".ui-chatbox-icon");
474
+ } else {
475
+ return null;
476
+ }
477
+ }
478
+
479
+ var getChatBoxButtonForSlug = function(slug,button){
480
+ var chatBoxButtons = getChatBoxButtonsForSlug(slug);
481
+ if(chatBoxButtons!=null){
482
+ switch (button){
483
+ case "close":
484
+ return chatBoxButtons[0];
485
+ break;
486
+ case "min":
487
+ return chatBoxButtons[1];
488
+ break;
489
+ case "video":
490
+ return chatBoxButtons[2];
491
+ break;
492
+ case "videoChange":
493
+ return chatBoxButtons[3];
494
+ case "games":
495
+ return chatBoxButtons[4];
496
+ break;
497
+ default : return null;
498
+ }
499
+ } else {
500
+ return null;
501
+ }
502
+ }
503
+
504
+
505
+ var getAllSlugsWithChatOrVideoBoxes = function(){
506
+ var slugsWithChatBox = [];
507
+ var slugsWithVideoBox = [];
508
+ $.each(getAllChatBoxes(), function(index, value) {
509
+ if($(value).parent().find(".ui-videobox").is(":visible")){
510
+ slugsWithVideoBox.push($(value).attr("id"))
511
+ }
512
+ slugsWithChatBox.push($(value).attr("id"))
513
+ });
514
+ return [slugsWithChatBox,slugsWithVideoBox];
515
+ }
516
+
517
+ var getAllSlugsWithChatBoxes = function(){
518
+ return getAllSlugsWithChatOrVideoBoxes()[0];
519
+ }
520
+
521
+ var getAllSlugsWithVisibleVideoBoxes = function(){
522
+ return getAllSlugsWithChatOrVideoBoxes()[1];
523
+ }
524
+
525
+ var getAllDisconnectedSlugsWithChatBoxes = function(){
526
+ var slugsWithChatBox = getAllSlugsWithChatBoxes();
527
+ var slugsConnected = PRESENCE.UIMANAGER.getAllConnectedSlugs();
528
+ var allDisconnectedSlugsWithChatBox = [];
529
+
530
+ $.each(slugsWithChatBox, function(index, value) {
531
+ if (slugsConnected.indexOf(value)==-1){
532
+ allDisconnectedSlugsWithChatBox.push(value);
533
+ }
534
+ });
535
+ return allDisconnectedSlugsWithChatBox;
536
+ }
537
+
538
+ var isSlugGroup = function(slug){
539
+ var chatBox = getChatBoxForSlug(slug)
540
+ if(chatBox!=null){
541
+ return chatBox.chatbox("option", "groupBox")
542
+ } else {
543
+ return false
544
+ }
545
+ }
546
+
547
+
548
+ var getAllSlugsWithVisibleGroupBoxes = function(){
549
+ var groupBoxes = []
550
+ $.each(getVisibleChatBoxes(), function(index, value) {
551
+ if ($(value).chatbox("option", "groupBox")){
552
+ groupBoxes.push($(value).attr("id"));
553
+ }
554
+ });
555
+ return groupBoxes;
556
+ }
557
+
558
+ var getChatBoxHeight = function(){
559
+ return chatBoxHeight;
560
+ }
561
+
562
+
563
+ return {
564
+ init: init,
565
+ createMainChatBox : createMainChatBox,
566
+ createBuddyChatBox : createBuddyChatBox,
567
+ createGroupChatBox : createGroupChatBox,
568
+ closeChatBox : closeChatBox,
569
+ rotatePriority : rotatePriority,
570
+ addContentToMainChatBox : addContentToMainChatBox,
571
+ modifyChatPartialIfMainBox : modifyChatPartialIfMainBox,
572
+ changeMainChatBoxHeaderTitle : changeMainChatBoxHeaderTitle,
573
+ changeMainChatBoxHeight : changeMainChatBoxHeight,
574
+ getChatBoxHeightRequiredForConnectionBoxes : getChatBoxHeightRequiredForConnectionBoxes,
575
+ getVideoBoxForSlug : getVideoBoxForSlug,
576
+ getPublisherVideoBoxForSlug : getPublisherVideoBoxForSlug,
577
+ setVideoBoxContent : setVideoBoxContent,
578
+ addVideoBoxContent : addVideoBoxContent,
579
+ toggleVideoBox : toggleVideoBox,
580
+ toggleVideoBoxChange : toggleVideoBoxChange,
581
+ toggleVideoBoxForSlug : toggleVideoBoxForSlug,
582
+ getVisibleChatBoxes : getVisibleChatBoxes,
583
+ getAllChatBoxes : getAllChatBoxes,
584
+ getChatBoxForSlug : getChatBoxForSlug,
585
+ getChatBoxHeaderForSlug : getChatBoxHeaderForSlug,
586
+ getChatBoxButtonForSlug : getChatBoxButtonForSlug,
587
+ getAllSlugsWithVisibleVideoBoxes : getAllSlugsWithVisibleVideoBoxes,
588
+ getAllDisconnectedSlugsWithChatBoxes : getAllDisconnectedSlugsWithChatBoxes,
589
+ isSlugGroup : isSlugGroup,
590
+ getAllSlugsWithVisibleGroupBoxes : getAllSlugsWithVisibleGroupBoxes,
591
+ getMainChatBox : getMainChatBox,
592
+ getMainchatBoxParams : getMainchatBoxParams,
593
+ getChatBoxHeight : getChatBoxHeight
594
+ };
595
+
596
+ }) (PRESENCE, jQuery);
534
597
 
535
- function getAllSlugsWithVisibleGroupBoxes(){
536
- var groupBoxes = []
537
- $.each(getVisibleChatBoxes(), function(index, value) {
538
- if ($(value).chatbox("option", "groupBox")){
539
- groupBoxes.push($(value).attr("id"));
540
- }
541
- });
542
- return groupBoxes;
543
- }