social_stream-presence 0.7.5 → 0.8.0

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.
Binary file
@@ -91,7 +91,7 @@ function settingChatBoxFunctions(){
91
91
 
92
92
  if (createChatBox(guest_slug, guest_name, guest_jid, user_name, user_jid)) {
93
93
  } else {
94
- window[getChatVariableFromSlug(guest_slug)].chatbox("option", "boxManager").toggleBox(true);
94
+ getChatBoxForSlug(guest_slug).chatbox("option", "boxManager").toggleBox(true);
95
95
  };
96
96
  });
97
97
 
@@ -268,33 +268,13 @@ function restartAwayTimer(){
268
268
  //Update chatWindow Management
269
269
  ////////////////////
270
270
 
271
- function timerFunction(){
272
- timerCounter++;
273
-
274
- if((timerCounter > cyclesToRefresh)&&(requestContacts)) {
275
- requestContacts = false;
276
- updateChatWindow();
277
- }
278
- }
279
-
280
-
281
- function refreshChatWindow(){
282
- if(timerCounter > cyclesToRefresh){
283
- updateChatWindow();
284
- } else {
285
- requestContacts = true;
286
- }
287
- }
288
-
289
-
290
- function updateChatWindow(){
291
- var stropheConnectedAndOnlineStatus = ((isStropheConnected()) && (userStatus!="offline") && (!disconnectionFlag));
271
+ function updateChatWindow(){
292
272
  timerCounter=0;
293
273
 
294
274
  log("updateChatWindow()");
295
- log("Connected " + stropheConnectedAndOnlineStatus);
275
+ log("Connected " + isUserConnected());
296
276
 
297
- if(! stropheConnectedAndOnlineStatus){
277
+ if(! isUserConnected()){
298
278
  loadDisconnectionDiv();
299
279
  updateConnectedUsersOfMainChatBox();
300
280
  return;
@@ -307,6 +287,7 @@ function updateChatWindow(){
307
287
  hideConnectionBoxesFromDisconnectedSlugs();
308
288
  setAllUserFunctions();
309
289
  updateConnectedUsersOfMainChatBox();
290
+ checkForZeroUsersConnected();
310
291
  if (isStropheConnected()) {
311
292
  if (afterNewConnectionFlag){
312
293
  afterNewConnectionFlag = false;
@@ -403,6 +384,7 @@ function updateInterfaceAfterPresenceStanza(slug,available){
403
384
  } else {
404
385
  hideConnectionBoxFromSlug(slug);
405
386
  showOfflineChatNotificationForSlug(slug);
387
+ closeVideoSession(slug);
406
388
  }
407
389
  updateMainChatBoxAfterConnectionBoxChanges();
408
390
  checkForZeroUsersConnected();
@@ -510,20 +492,17 @@ function putReceivedMessageOnChatWindow(from_jid,from_slug,body,msgID){
510
492
  return;
511
493
  }
512
494
 
513
- //Check slug connection and slugs connectionBox
514
- if (existsSlugChatBox(from_slug)) {
495
+ //Check slugs connectionBox
496
+ if (!existsSlugChatBox(from_slug)) {
515
497
  //No connectionBox for this user!
516
498
  var from_name = getNameFromSlug(from_slug);
517
499
  if(! isAdminSlug(from_slug)){
518
- refreshChatWindow();
519
- }
500
+ updateChatWindow();
501
+ }
520
502
  } else {
521
- if(! isSlugChatConnected(from_slug)){
522
- updateInterfaceAfterPresenceStanza(from_slug,"true");
523
- }
524
- var from_name = $('div.user_presence[slug=' + from_slug + ']').attr('name');
525
- }
526
-
503
+ var from_name = $('div.user_presence[slug=' + from_slug + ']').attr('name');
504
+ }
505
+
527
506
  //Create or toggle from_slug's chatBox.
528
507
  if (createChatBox(from_slug, from_name, from_jid, user_name, user_jid)) {
529
508
  } else {
@@ -564,16 +543,28 @@ function showChatNotification(notification,type,msg){
564
543
 
565
544
  function showChatNotificationForSlug(slug,type,msg){
566
545
  var notification = $("#" + slug).parent().find("div.ui-chatbox-notify");
567
- showChatNotification(notification,type,msg);
546
+ if(notification.length==1){
547
+ showChatNotification(notification,type,msg);
548
+ }
568
549
  }
569
550
 
570
551
  function showOfflineChatNotificationForSlug(slug){
571
- var slug_chat_box = getChatBoxForSlug(slug);
572
- if(slug_chat_box!=null){
573
- var name = slug_chat_box.attr("name")
574
- var msg = name + ' ' + I18n.t('chat.notify.guestOffline');
552
+ var msg = I18n.t("chat.notify.guestOffline", {name: getNameFromSlug(slug)});
575
553
  showChatNotificationForSlug(slug,"guestOffline",msg);
576
- }
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);
577
568
  }
578
569
 
579
570
  function hideChatNotification(notification){
@@ -587,8 +578,15 @@ function hideChatNotificationForSlug(slug){
587
578
  hideChatNotification(notification);
588
579
  }
589
580
 
590
- function notifyWhenUsersDisconnect(){
591
- var notification = $("div.ui-chatbox-notify");
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");
592
590
  var msg = I18n.t('chat.notify.offline');
593
591
  showChatNotification(notification,"userOffline",msg);
594
592
  }
@@ -601,7 +599,7 @@ function hideAllNotifications(){
601
599
  function updateAllNotifications(){
602
600
  hideAllNotifications();
603
601
  if(disconnectionFlag){
604
- notifyWhenUsersDisconnect();
602
+ updateNotificationsAfterUserDisconnect();
605
603
  } else {
606
604
  //Notification for offline contacts
607
605
  $.each(getAllDisconnectedSlugsWithChatBoxes(), function(index, value) {
@@ -617,8 +615,7 @@ function updateAllNotifications(){
617
615
 
618
616
  function updateConnectedUsersOfMainChatBox(){
619
617
  if(mainChatBox!=null){
620
- var stropheConnectedAndOnlineStatus = ((isStropheConnected()) && (userStatus!="offline") && (!disconnectionFlag));
621
- if(stropheConnectedAndOnlineStatus){
618
+ if(isUserConnected()){
622
619
  var connectedUsers = getConnectedSlugsLength();
623
620
  changeMainChatBoxHeaderTitle( I18n.t('chat.title') + " (" + connectedUsers + ")");
624
621
  changeMainChatBoxHeight(getChatBoxHeightRequiredForConnectionBoxes());
@@ -46,7 +46,7 @@ function parseContent(content){
46
46
  return "<pre>" + content + "</pre>"
47
47
  }
48
48
 
49
- words = content.split(" ");
49
+ var words = content.split(" ");
50
50
  for(i=0; i<words.length; i++){
51
51
  words[i] = parseWord(words[i]);
52
52
  }
@@ -131,18 +131,18 @@ function parseWord(word){
131
131
  }
132
132
 
133
133
  function splitFirst(word,key){
134
- split=[]
135
- cut = word.split(key);
134
+ var split=[]
135
+ var cut = word.split(key);
136
136
  split[0]=cut[0]
137
137
  cut.shift()
138
- paste = cut.join(key)
138
+ var paste = cut.join(key)
139
139
  split[1]=paste
140
140
  return split
141
141
  }
142
142
 
143
143
  function buildIconImage(icon){
144
144
  if (icon in chatIcons){
145
- image_file = chatIcons[icon]
145
+ var image_file = chatIcons[icon]
146
146
  return "<img class=\"chatEmoticon\" src=\"/assets/emoticons/" + image_file + "\"/>";
147
147
  }
148
148
  return icon
@@ -93,7 +93,7 @@ function userChatDataInputControl(){
93
93
  ////////////////////
94
94
 
95
95
  var lastMessageTimes = new Array();
96
- //lastMessageTimes['from_slug'] = ["timeOfLastMessage",["msgID1","msgID2"]];
96
+ //lastMessageTimes['slug'] = ["timeOfLastMessage",["msgID1","msgID2"]];
97
97
 
98
98
  var timeBetweenMessages = 500; //mseconds
99
99
 
@@ -181,11 +181,6 @@ function floodControl() {
181
181
  };
182
182
 
183
183
 
184
- function initControlFlood(){
185
- $(".ui-chatbox-input-box")
186
- }
187
-
188
-
189
184
  ////////////////////
190
185
  //Bounce chatbox control
191
186
  ////////////////////
@@ -193,21 +188,30 @@ var lastBounceTimes = new Array();
193
188
  var timeBetweenBounces = 5000; //mseconds
194
189
 
195
190
  function mustBounceBoxForChatWindow(jqueryUIChatbox){
196
- var from_slug = $($(jqueryUIChatbox.elem.uiChatbox).find(".ui-chatbox-content").children()[0]).attr("id")
197
191
 
192
+ var slug = jqueryUIChatbox.elem.uiChatbox.find(".ui-chatbox-content").find(".ui-chatbox-log").attr("id")
193
+
194
+ if (typeof slug == 'undefined') {
195
+ return false;
196
+ }
197
+
198
+ if((slug in contactsInfo)&&(contactsInfo[slug].videoChatStatus!="disconnected")){
199
+ return false;
200
+ }
201
+
198
202
  var t = (new Date()).getTime();
199
203
 
200
- if(!(from_slug in lastBounceTimes)){
201
- lastBounceTimes[from_slug] = t;
204
+ if(!(slug in lastBounceTimes)){
205
+ lastBounceTimes[slug] = t;
202
206
  return true;
203
207
  }
204
208
 
205
- var lastBounceTime = lastBounceTimes[from_slug];
209
+ var lastBounceTime = lastBounceTimes[slug];
206
210
 
207
211
  if (t - lastBounceTime < timeBetweenBounces) {
208
212
  return false;
209
213
  } else {
210
- lastBounceTimes[from_slug] = t;
214
+ lastBounceTimes[slug] = t;
211
215
  return true;
212
216
  }
213
217
 
@@ -5,8 +5,8 @@
5
5
  var nBox = 0;
6
6
  var maxBox = 5;
7
7
  var chatBoxWidth = 230;
8
- var chatBoxHeight = 170;
9
- var videoBoxHeight = 150;
8
+ var chatBoxHeight = 180;
9
+ var videoBoxHeight = 145;
10
10
  var visibleChatBoxes = new Array();
11
11
  var offsetForFlowBox = 0;
12
12
  var chatBoxSeparation = chatBoxWidth+12;
@@ -150,13 +150,66 @@ function getChatBoxForSlug(slug){
150
150
  }
151
151
  }
152
152
 
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
+ }
153
161
 
154
- function getAllSlugsWithChatBoxes(){
155
- var slugsWithChatBox = [];
156
- $.each(getAllChatBoxes(), function(index, value) {
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
+ }
170
+
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
+ }
192
+ }
193
+
194
+
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
+ }
157
202
  slugsWithChatBox.push($(value).attr("id"))
158
203
  });
159
- return slugsWithChatBox;
204
+ return [slugsWithChatBox,slugsWithVideoBox];
205
+ }
206
+
207
+ function getAllSlugsWithChatBoxes(){
208
+ return getAllSlugsWithChatOrVideoBoxes()[0];
209
+ }
210
+
211
+ function getAllSlugsWithVisibleVideoBoxes(){
212
+ return getAllSlugsWithChatOrVideoBoxes()[1];
160
213
  }
161
214
 
162
215
  function getAllDisconnectedSlugsWithChatBoxes(){
@@ -209,41 +262,88 @@ function rotatePriority(guest_slug){
209
262
  //Video Window Manager functions
210
263
  ////////////////////
211
264
 
212
- function getVideoBoxFromSlug(slug){
213
- return $("#" + slug).parent().find("div.ui-videobox")
265
+ function getVideoBoxForSlug(slug){
266
+ var videoBox = $("#" + slug).parent().find("div.ui-videobox");
267
+ if(videoBox.length == 1){
268
+ return videoBox;
269
+ } else {
270
+ return null;
271
+ }
272
+ }
273
+
274
+ function getPublisherVideoBoxForSlug(slug){
275
+ var pubDiv = $("#stream_publish_videochat_" + slug);
276
+ if (pubDiv.length > 0) {
277
+ return pubDiv
278
+ } else {
279
+ return null;
280
+ }
281
+ }
282
+
283
+ function setVideoBoxContent(slug,embed){
284
+ var videoBox = getVideoBoxForSlug(slug);
285
+ if(videoBox!=null){
286
+ videoBox.html(embed);
287
+ }
214
288
  }
215
289
 
216
- function showVideoBox(slug,embed){
217
- var chatBox = window[getChatVariableFromSlug(slug)]
218
- getVideoBoxFromSlug(slug).html(embed);
219
- chatBox.chatbox("option", "video",videoBoxHeight);
290
+ function addVideoBoxContent(slug,embed){
291
+ var videoBox = getVideoBoxForSlug(slug);
292
+ if(videoBox!=null){
293
+ videoBox.append(embed);
294
+ }
220
295
  }
221
296
 
297
+ function showVideoBox(chatBox){
298
+ chatBox.chatbox("option", "video",videoBoxHeight);
299
+ }
222
300
 
223
- function hideVideoBox(slug){
224
- var chatBox = window[getChatVariableFromSlug(slug)]
225
- chatBox.chatbox("option", "video", 0);
301
+ function hideVideoBox(chatBox){
302
+ chatBox.chatbox("option", "video", 0);
226
303
  }
227
304
 
228
305
 
229
306
  //Function called from JQuery UI Plugin
230
- function toogleVideoBox(uiElement){
231
- var slug = $(uiElement.element).attr("id");
232
- toogleVideoBoxForSlug(slug)
307
+ function toggleVideoBox(uiElement){
308
+ var slug = $(uiElement.element).attr("id");
309
+ clickVideoChatButton(slug);
233
310
  }
234
311
 
235
- function toogleVideoBoxForSlug(slug){
236
- var chatBox = window[getChatVariableFromSlug(slug)]
237
- if (chatBox.chatbox("option", "video")==0){
238
- showVideoBox(slug,getVideoEmbedForSlug(slug))
312
+ //Function called from JQuery UI Plugin
313
+ function toggleVideoBoxChange(uiElement){
314
+ var slug = $(uiElement.element).attr("id");
315
+ clickVideoChangeChatButton(slug);
316
+ }
317
+
318
+ function toggleVideoBoxForSlug(slug,force){
319
+ var aux;
320
+ var chatBox = getChatBoxForSlug(slug);
321
+
322
+ if(chatBox==null) {
323
+ return null;
324
+ }
325
+
326
+ if(typeof force != 'undefined'){
327
+ aux = force;
239
328
  } else {
240
- hideVideoBox(slug);
329
+ if (chatBox.chatbox("option", "video")==0){
330
+ aux=true;
331
+ } else {
332
+ aux=false;
333
+ }
241
334
  }
335
+
336
+ if (aux){
337
+ //Show
338
+ showVideoBox(chatBox);
339
+ return true;
340
+ } else {
341
+ //Hide
342
+ hideVideoBox(chatBox);
343
+ return false;
344
+ }
242
345
  }
243
346
 
244
- function getVideoEmbedForSlug(slug){
245
- return "<img src=\"http://www.batiburrillo.net/wp-content/uploads/2011/03/Freemake.jpg?cda6c1\" width=\"" + (chatBoxWidth-20) + "\"/>"
246
- }
247
347
 
248
348
 
249
349
 
@@ -304,6 +404,9 @@ function createMainChatBox(){
304
404
  $(mainChatBox).css('overflow-x','hidden')
305
405
  $(mainChatBox).css('overflow-y','hidden')
306
406
 
407
+ //Minimize
408
+ mainChatBox.parent().toggle(false);
409
+
307
410
  //Header title
308
411
  updateConnectedUsersOfMainChatBox();
309
412
  }
@@ -176,10 +176,10 @@
176
176
  'ui-chatbox-icon' + ' ui-videobox-icon'
177
177
  )
178
178
  .attr('role', 'button')
179
- //.hover(function() {uiChatboxTitlebarMinimize.addClass('ui-state-hover');},
180
- // function() {uiChatboxTitlebarMinimize.removeClass('ui-state-hover');})
179
+ .hover(function() {uiChatboxTitlebarVideo.addClass('ui-state-hover');},
180
+ function() {uiChatboxTitlebarVideo.removeClass('ui-state-hover');})
181
181
  .click(function(event) {
182
- toogleVideoBox(self)
182
+ toggleVideoBox(self)
183
183
  return false;
184
184
  })
185
185
  .appendTo(uiChatboxTitlebar),
@@ -189,6 +189,25 @@
189
189
  .appendTo(uiChatboxTitlebarVideo),
190
190
 
191
191
 
192
+ //Change video-window Menu button
193
+ uiChatboxTitlebarVideoChange = (self.uiChatboxTitlebarVideoChange = $('<a href="#"></a>'))
194
+ .addClass('ui-corner-all ' +
195
+ 'ui-chatbox-icon' + ' ui-videobox-icon-change'
196
+ )
197
+ .attr('role', 'button')
198
+ .hover(function() {uiChatboxTitlebarVideoChange.addClass('ui-state-hover');},
199
+ function() {uiChatboxTitlebarVideoChange.removeClass('ui-state-hover');})
200
+ .click(function(event) {
201
+ toggleVideoBoxChange(self)
202
+ return false;
203
+ })
204
+ .appendTo(uiChatboxTitlebar),
205
+ uiChatboxTitlebarVideoText = $('<span></span>')
206
+ .addClass('ui-icon-newwin ' + 'chat-thick ' + ' chat-videoPublisherthick' )
207
+ .text('')
208
+ .appendTo(uiChatboxTitlebarVideoChange),
209
+
210
+
192
211
  // content
193
212
  uiChatboxContent = (self.uiChatboxContent = $('<div></div>'))
194
213
  .addClass('ui-widget-content ' +