social_stream-presence 0.13.1 → 0.13.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. data/app/assets/javascripts/jquery.flexselect.sstreampresence.js +2 -2
  2. data/app/assets/javascripts/jquery.ui.chatbox.sstreampresence.js +5 -5
  3. data/app/assets/javascripts/presence.js.erb +6 -4
  4. data/app/assets/javascripts/presence_XmppClient.js.erb +1136 -996
  5. data/app/assets/javascripts/presence_audio.js.erb +74 -60
  6. data/app/assets/javascripts/presence_game.js.erb +35 -22
  7. data/app/assets/javascripts/presence_game_comunication.js.erb +22 -5
  8. data/app/assets/javascripts/presence_game_factory.js.erb +1 -1
  9. data/app/assets/javascripts/presence_game_interface.js.erb +33 -13
  10. data/app/assets/javascripts/presence_notifications.js +206 -183
  11. data/app/assets/javascripts/presence_parser.js +265 -247
  12. data/app/assets/javascripts/presence_persistence.js +199 -188
  13. data/app/assets/javascripts/presence_store.js +22 -11
  14. data/app/assets/javascripts/presence_uiManager.js.erb +553 -530
  15. data/app/assets/javascripts/presence_utilities.js +244 -219
  16. data/app/assets/javascripts/presence_videochat.js.erb +436 -409
  17. data/app/assets/javascripts/presence_windowManager.js +586 -532
  18. data/app/views/chat/_index.html.erb +7 -13
  19. data/config/locales/en.yml +2 -1
  20. data/config/locales/es.yml +2 -1
  21. data/ejabberd/ejabberd_files.zip +0 -0
  22. data/ejabberd/ejabberd_scripts/authentication_script +9 -2
  23. data/ejabberd/mod_sspresence/mod_sspresence.beam +0 -0
  24. data/lib/generators/social_stream/presence/templates/initializer.rb +4 -0
  25. data/lib/social_stream/presence/version.rb +1 -1
  26. data/lib/social_stream/presence/xmpp_server_order.rb +1 -0
  27. data/lib/social_stream-presence.rb +3 -0
  28. metadata +68 -63
@@ -1,191 +1,214 @@
1
- ////////////////////
2
- //Chat Boxes Notifications
3
- ////////////////////
1
+ PRESENCE.NOTIFICATIONS = (function(P,$,undefined){
4
2
 
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
- }
3
+ var init = function(){ }
29
4
 
30
- function showVideoChatNotificationForSlug(slug,msg){
31
- showChatNotificationForSlug(slug,"videochat",msg);
32
- }
33
5
 
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");
6
+ ////////////////////
7
+ //Chat Boxes Notifications
8
+ ////////////////////
9
+
10
+ var fadeInChatNotification = function(notification){
11
+ if(notification!=null){
12
+ notification.css("display","block");
13
+ notification.css("visibility","visible");
14
+ notification.fadeIn();
15
+ }
49
16
  }
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)
17
+
18
+ var showChatNotification = function(notification,type,msg){
19
+ notification.html("<p notification_type=\"" + type + "\" class=\"ui-chatbox-notify-text\">" + msg + "</p>");
20
+ fadeInChatNotification(notification);
21
+ }
22
+
23
+ var showChatNotificationForSlug = function(slug,type,msg){
24
+ var notification = $("#" + slug).parent().find("div.ui-chatbox-notify");
25
+ if(notification.length==1){
26
+ showChatNotification(notification,type,msg);
27
+ }
178
28
  }
179
- }
29
+
30
+ var showOfflineChatNotificationForSlug = function(slug){
31
+ var msg = I18n.t("chat.notify.guestOffline", {name: PRESENCE.XMPPClient.getNameFromSlug(slug)});
32
+ showChatNotificationForSlug(slug,"guestOffline",msg);
33
+ }
34
+
35
+ var showVideoChatNotificationForSlug = function(slug,msg){
36
+ showChatNotificationForSlug(slug,"videochat",msg);
37
+ }
38
+
39
+ var showVideoChatNotificationForSlugClientIssue = function(slug){
40
+ var msg = I18n.t("chat.notify.videochat.clientIssue", {name: PRESENCE.XMPPClient.getNameFromSlug(slug)});
41
+ showVideoChatNotificationForSlug(slug,msg);
42
+ }
43
+
44
+ var showVideoChatNotificationForSlugClientOffline = function(slug){
45
+ var msg = I18n.t("chat.notify.videochat.offline", {name: PRESENCE.XMPPClient.getNameFromSlug(slug)});
46
+ showVideoChatNotificationForSlug(slug,msg);
47
+ }
48
+
49
+ var fadeOutChatNotification = function(notification){
50
+ if(notification!=null){
51
+ notification.fadeOut();
52
+ notification.css("display","none");
53
+ notification.css("visibility","hidden");
54
+ }
55
+ }
56
+
57
+ var hideChatNotificationForSlug = function(slug){
58
+ var notification = getChatNotificationForSlug(slug);
59
+ fadeOutChatNotification(notification);
60
+ }
61
+
62
+ var updateNotificationsAfterUserDisconnect = function(){
63
+ var notification = $("div.ui-chatbox-notify");
64
+ var msg = I18n.t('chat.notify.offline');
65
+ showChatNotification(notification,"userOffline",msg);
66
+ }
67
+
68
+ var hideAllNotifications = function(){
69
+ var notification = $("div.ui-chatbox-notify");
70
+ fadeOutChatNotification(notification);
71
+ }
72
+
73
+ var updateAllNotifications = function(){
74
+ hideAllNotifications();
75
+ if(PRESENCE.XMPPClient.getDisconnectionFlag()){
76
+ updateNotificationsAfterUserDisconnect();
77
+ } else {
78
+ //Notification for offline contacts
79
+ $.each(PRESENCE.WINDOW.getAllDisconnectedSlugsWithChatBoxes(), function(index, value) {
80
+ if(!PRESENCE.WINDOW.isSlugGroup(value)){
81
+ showOfflineChatNotificationForSlug(value)
82
+ }
83
+ });
84
+ }
85
+ }
86
+
87
+ var getChatNotificationForSlug = function(slug){
88
+ var chatBox = PRESENCE.WINDOW.getChatBoxForSlug(slug)
89
+ if(chatBox!=null){
90
+ var notification = chatBox.parent().find("div.ui-chatbox-notify");
91
+ if (notification.length == 1) {
92
+ return notification;
93
+ }
94
+ }
95
+ return null;
96
+ }
97
+
98
+ var getNotificationType = function(notification){
99
+ return $(notification).find("p").attr("notification_type");
100
+ }
101
+
102
+ var addTextToNotification = function(notification,txt,type,name){
103
+ var new_p = document.createElement('p')
104
+ $(new_p).attr("class","ui-chatbox-notify-text")
105
+ $(new_p).attr("notification_type",type)
106
+ $(new_p).html(txt)
107
+ if(name!=null){
108
+ $(new_p).attr("name",name)
109
+ }
110
+ $(notification).append(new_p)
111
+ fadeInChatNotification(notification)
112
+ }
113
+
114
+ var removeTextFromNotification = function(notification,name){
115
+ var p = $(notification).find("p.ui-chatbox-notify-text[name=" + name + "]")
116
+ if (p!=null){
117
+ p.remove()
118
+ var empty = ($(notification).find("p").length==0)
119
+ if (empty){
120
+ fadeOutChatNotification(notification)
121
+ }
122
+ }
123
+ }
124
+
125
+ var removeAllTextsFromNotification = function(notification){
126
+ var p = $(notification).find("p.ui-chatbox-notify-text")
127
+ if (p!=null){
128
+ p.remove()
129
+ var empty = ($(notification).find("p").length==0)
130
+ if (empty){
131
+ fadeOutChatNotification(notification)
132
+ }
133
+ }
134
+ }
135
+
136
+ var addTextToNotificationForSlug = function(slug,txt,type,name){
137
+ var notification = getChatNotificationForSlug(slug);
138
+ if(notification!=null){
139
+ addTextToNotification(notification,txt,type,name)
140
+ }
141
+ }
142
+
143
+ var removeTextFromNotificationForSlug = function(slug,name){
144
+ var notification = getChatNotificationForSlug(slug);
145
+ if(notification!=null){
146
+ removeTextFromNotification(notification,name)
147
+ }
148
+ }
149
+
150
+ var removeAllTextsFromNotificationForSlug = function(slug){
151
+ var notification = getChatNotificationForSlug(slug);
152
+ if(notification!=null){
153
+ removeAllTextsFromNotification(notification)
154
+ }
155
+ }
156
+
157
+
158
+ ////////////////////////
159
+ // Group notifications
160
+ ///////////////////////
161
+
162
+ var addNickToNotificationInGroup = function(roomName,nick){
163
+ if(PRESENCE.WINDOW.isSlugGroup(roomName)){
164
+ addTextToNotificationForSlug(roomName,nick,"roomNotification",nick)
165
+ }
166
+ }
167
+
168
+ var removeNickFromNotificationInGroup = function(roomName,nick){
169
+ if(PRESENCE.WINDOW.isSlugGroup(roomName)){
170
+ removeTextFromNotificationForSlug(roomName,nick)
171
+ }
172
+ }
173
+
174
+ var initialNotificationInGroup = function(roomName,msg){
175
+ removeAllTextsFromNotificationForSlug(roomName);
176
+ addTextToNotificationForSlug(roomName,msg,"roomNotification","Initial_Notification")
177
+ }
178
+
179
+ var changeInitialNotificationInGroup = function(roomName,msg){
180
+ var notification = getChatNotificationForSlug(roomName);
181
+ if(notification!=null){
182
+ $(notification).find("p.ui-chatbox-notify-text[name=" + "Initial_Notification" + "]").html(msg)
183
+ }
184
+ }
185
+
186
+
187
+ ////////////////////
188
+ //Events
189
+ ////////////////////
190
+
191
+ var onClickChatNotification = function(notification){
192
+ if (getNotificationType(notification)=="roomNotification"){
193
+ return;
194
+ }
195
+ fadeOutChatNotification(notification)
196
+ }
197
+
180
198
 
181
199
 
182
- ////////////////////
183
- //Events
184
- ////////////////////
200
+ return {
201
+ init: init,
202
+ showOfflineChatNotificationForSlug : showOfflineChatNotificationForSlug,
203
+ hideChatNotificationForSlug : hideChatNotificationForSlug,
204
+ updateNotificationsAfterUserDisconnect : updateNotificationsAfterUserDisconnect,
205
+ updateAllNotifications : updateAllNotifications,
206
+ addNickToNotificationInGroup : addNickToNotificationInGroup,
207
+ removeNickFromNotificationInGroup : removeNickFromNotificationInGroup,
208
+ initialNotificationInGroup : initialNotificationInGroup,
209
+ changeInitialNotificationInGroup : changeInitialNotificationInGroup,
210
+ onClickChatNotification : onClickChatNotification
211
+ };
212
+
213
+ }) (PRESENCE, jQuery);
185
214
 
186
- function onClickChatNotification(notification){
187
- if (getNotificationType(notification)=="roomNotification"){
188
- return;
189
- }
190
- fadeOutChatNotification(notification)
191
- }