social_stream-presence 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/chat_interface_manager.js.erb +264 -143
- data/app/assets/javascripts/chat_persistence.js +3 -5
- data/app/assets/javascripts/chat_utilities.js +6 -0
- data/app/assets/javascripts/chat_window_manager.js +9 -1
- data/{vendor/assets/javascripts/jquery.flexselect.js → app/assets/javascripts/jquery.flexselect.sstreampresence.js} +16 -8
- data/{vendor/assets/javascripts/jquery.ui.chatbox.js → app/assets/javascripts/jquery.ui.chatbox.sstreampresence.js} +0 -0
- data/app/assets/javascripts/social_stream-presence.js +2 -2
- data/app/assets/javascripts/xmpp_client_management.js.erb +8 -21
- data/app/assets/stylesheets/chat.css.scss +17 -13
- data/app/controllers/xmpp_controller.rb +1 -4
- data/app/helpers/xmpp_helper.rb +6 -15
- data/app/views/chat/_contacts.html.erb +16 -63
- data/app/views/chat/_index.html.erb +83 -15
- data/lib/social_stream-presence.rb +1 -0
- data/lib/social_stream/presence/version.rb +1 -1
- metadata +93 -68
- data/app/views/chat/_connecting.html.erb +0 -8
- data/app/views/chat/_off.html.erb +0 -54
@@ -146,7 +146,7 @@ function restoreConversations() {
|
|
146
146
|
|
147
147
|
|
148
148
|
for (var i=0;i<storedSlugs.length;i++){
|
149
|
-
restoreLog = sessionStorage.getItem("chat_log_" + storedSlugs[i]);
|
149
|
+
var restoreLog = sessionStorage.getItem("chat_log_" + storedSlugs[i]);
|
150
150
|
|
151
151
|
if (restoreLog != null){
|
152
152
|
|
@@ -179,10 +179,8 @@ function restoreConversations() {
|
|
179
179
|
|
180
180
|
window[getChatVariableFromSlug(guest_slug)].html(restoreLog)
|
181
181
|
|
182
|
-
|
183
|
-
|
184
|
-
//No connectionBox for this user!
|
185
|
-
showChatNotificationForSlug(guest_slug,guest_name + " is offline");
|
182
|
+
if (! isSlugChatConnected(guest_slug)) {
|
183
|
+
showOfflineChatNotificationForSlug(guest_slug);
|
186
184
|
}
|
187
185
|
|
188
186
|
}
|
@@ -241,6 +241,12 @@ function getNameFromSlug(slug){
|
|
241
241
|
}
|
242
242
|
|
243
243
|
|
244
|
+
////////////////////
|
245
|
+
//Special slugs management
|
246
|
+
////////////////////
|
247
|
+
function isAdminSlug(slug){
|
248
|
+
return (slug == '<%=SocialStream::Presence.social_stream_presence_username%>');
|
249
|
+
}
|
244
250
|
|
245
251
|
|
246
252
|
|
@@ -70,6 +70,7 @@ function createChatBox(guest_slug,guest_name,guest_jid,user_name,user_jid){
|
|
70
70
|
}
|
71
71
|
|
72
72
|
window[getChatVariableFromSlug(guest_slug)].chatbox("option", "hidden", false);
|
73
|
+
window[getChatVariableFromSlug(guest_slug)].parent().toggle(true)
|
73
74
|
return false;
|
74
75
|
}
|
75
76
|
|
@@ -115,6 +116,10 @@ function closeChatBox(guest_slug){
|
|
115
116
|
}
|
116
117
|
|
117
118
|
|
119
|
+
/////////
|
120
|
+
//Getters
|
121
|
+
/////////
|
122
|
+
|
118
123
|
function getChatVariableFromSlug(slug){
|
119
124
|
return "slug_" + slug;
|
120
125
|
}
|
@@ -168,6 +173,7 @@ function getAllDisconnectedSlugsWithChatBoxes(){
|
|
168
173
|
}
|
169
174
|
|
170
175
|
|
176
|
+
|
171
177
|
////////////////////
|
172
178
|
//Box replacement
|
173
179
|
////////////////////
|
@@ -198,6 +204,7 @@ function rotatePriority(guest_slug){
|
|
198
204
|
}
|
199
205
|
|
200
206
|
|
207
|
+
|
201
208
|
////////////////////
|
202
209
|
//Video Window Manager functions
|
203
210
|
////////////////////
|
@@ -239,6 +246,7 @@ function getVideoEmbedForSlug(slug){
|
|
239
246
|
}
|
240
247
|
|
241
248
|
|
249
|
+
|
242
250
|
///////////////////////////
|
243
251
|
// Create Main Chat Box
|
244
252
|
///////////////////////////
|
@@ -331,7 +339,7 @@ function changeMainChatBoxHeaderTitle(title){
|
|
331
339
|
function changeMainChatBoxHeight(height){
|
332
340
|
if (mainChatBox != null) {
|
333
341
|
|
334
|
-
if(($("#search_chat_contact_flexselect").is(":focus"))&&(! (focusSearchContactsFlag))){
|
342
|
+
if(($("#chat_partial #search_chat_contact_flexselect").is(":focus"))&&(! (focusSearchContactsFlag))){
|
335
343
|
return;
|
336
344
|
} else {
|
337
345
|
focusSearchContactsFlag=false;
|
@@ -47,17 +47,24 @@
|
|
47
47
|
this.wire();
|
48
48
|
},
|
49
49
|
|
50
|
-
|
51
|
-
// this.cache = this.select.children("option").map(function() {
|
52
|
-
// return { name: $.trim($(this).text()), value: $(this).val(), score: 0.0 };
|
53
|
-
// });
|
54
|
-
//},
|
55
|
-
|
56
|
-
preloadCache: function() {
|
50
|
+
preloadCache: function() {
|
57
51
|
this.cache = this.select.children("option").map(function() {
|
58
|
-
return { name: ($(this).
|
52
|
+
return { name: $.trim($(this).text()), value: $(this).val(), score: 0.0 };
|
59
53
|
});
|
60
54
|
},
|
55
|
+
|
56
|
+
//preloadCache: function() {
|
57
|
+
// this.cache = this.select.children("option").map(function() {
|
58
|
+
// var slug = $(this).val();
|
59
|
+
|
60
|
+
// if(slug!=""){
|
61
|
+
// var code = $(getAvatarBoxFromSlug(slug)).html();
|
62
|
+
// return { name: code, value: slug, score: 0.0 };
|
63
|
+
// }
|
64
|
+
|
65
|
+
//return { name: ($(this).html()), value: $(this).val(), score: 0.0 };
|
66
|
+
// });
|
67
|
+
//},
|
61
68
|
|
62
69
|
renderControls: function() {
|
63
70
|
var selected = this.select.children("option:selected");
|
@@ -119,6 +126,7 @@
|
|
119
126
|
self.markSelected(rows.index($(event.target)));
|
120
127
|
}
|
121
128
|
});
|
129
|
+
|
122
130
|
this.dropdownList.mouseleave(function () {
|
123
131
|
self.markSelected(-1);
|
124
132
|
});
|
File without changes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
//= require jquery
|
2
2
|
//= require strophe
|
3
3
|
//= require jquery.tools.tooltip
|
4
|
-
//= require jquery.ui.chatbox
|
5
|
-
//= require jquery.flexselect
|
4
|
+
//= require jquery.ui.chatbox.sstreampresence
|
5
|
+
//= require jquery.flexselect.sstreampresence
|
6
6
|
//= require liquidmetal
|
7
7
|
//= require_tree .
|
@@ -223,8 +223,8 @@ function onConnect(status) {
|
|
223
223
|
awayTimer = setInterval("awayTimerFunction()", awayTimerPeriod);
|
224
224
|
timer = setInterval("timerFunction()", timerPeriod);
|
225
225
|
}
|
226
|
-
|
227
|
-
|
226
|
+
|
227
|
+
updateChatWindow();
|
228
228
|
}
|
229
229
|
|
230
230
|
function onReconnect(){
|
@@ -249,15 +249,6 @@ function onReconnect(){
|
|
249
249
|
}
|
250
250
|
|
251
251
|
|
252
|
-
function changeChatHeaderTitle(msg){
|
253
|
-
if(mainChatBox==null){
|
254
|
-
$("#chat_header_title").html(msg)
|
255
|
-
} else {
|
256
|
-
changeMainChatBoxHeaderTitle(msg);
|
257
|
-
}
|
258
|
-
}
|
259
|
-
|
260
|
-
|
261
252
|
function disconnectStrophe(){
|
262
253
|
userStatus = "offline";
|
263
254
|
setStatusWidgetTitle("offline");
|
@@ -328,14 +319,12 @@ function processAvailablePresenceStanza(presence){
|
|
328
319
|
if (slug != user_slug) {
|
329
320
|
if (getConnectionBoxFromSlug(slug)!=null){
|
330
321
|
var status = $(presence).find('show').text();
|
331
|
-
setUserIconStatus(slug,
|
332
|
-
|
333
|
-
showConnectionBoxFromSlug(slug);
|
334
|
-
hideChatNotificationForSlug(slug);
|
335
|
-
updateConnectedUsersOfMainChatBox();
|
336
|
-
}
|
322
|
+
setUserIconStatus(slug,status);
|
323
|
+
updateInterfaceAfterPresenceStanza(slug,true);
|
337
324
|
} else {
|
338
|
-
|
325
|
+
if(! isAdminSlug(slug)){
|
326
|
+
setTimeout("refreshChatWindow()", 3000);
|
327
|
+
}
|
339
328
|
}
|
340
329
|
}
|
341
330
|
}
|
@@ -346,9 +335,7 @@ function processUnavailablePresenceStanza(presence){
|
|
346
335
|
|
347
336
|
if (slug != user_slug) {
|
348
337
|
if (getConnectionBoxFromSlug(slug)!=null){
|
349
|
-
|
350
|
-
showOfflineChatNotificationForSlug(slug);
|
351
|
-
updateConnectedUsersOfMainChatBox();
|
338
|
+
updateInterfaceAfterPresenceStanza(slug,false)
|
352
339
|
}
|
353
340
|
}
|
354
341
|
}
|
@@ -106,9 +106,9 @@ div.ui-chatbox-notify{
|
|
106
106
|
}
|
107
107
|
|
108
108
|
p.ui-chatbox-notify-text{
|
109
|
-
margin-top:
|
109
|
+
margin-top: 0px;
|
110
110
|
text-align: center;
|
111
|
-
font-weight: bold;
|
111
|
+
/* font-weight: bold; */
|
112
112
|
}
|
113
113
|
|
114
114
|
|
@@ -141,6 +141,18 @@ p.ui-chatbox-notify-text{
|
|
141
141
|
|
142
142
|
/* Presence Partial */
|
143
143
|
|
144
|
+
#chat_connecting{
|
145
|
+
display: none;
|
146
|
+
}
|
147
|
+
|
148
|
+
#chat_connection_off{
|
149
|
+
display: none;
|
150
|
+
}
|
151
|
+
|
152
|
+
#chat_widgets{
|
153
|
+
display: none;
|
154
|
+
}
|
155
|
+
|
144
156
|
div.user_presence {
|
145
157
|
float: left;
|
146
158
|
position: relative;
|
@@ -161,9 +173,9 @@ div.user_presence {
|
|
161
173
|
|
162
174
|
.presence_status {
|
163
175
|
position: absolute;
|
164
|
-
bottom:0px;
|
165
|
-
|
166
|
-
border:none;
|
176
|
+
bottom: 0px;
|
177
|
+
left: 14px;
|
178
|
+
border: none;
|
167
179
|
}
|
168
180
|
|
169
181
|
.users_connected{
|
@@ -194,7 +206,6 @@ input.chat_password{
|
|
194
206
|
margin-bottom: 5px;
|
195
207
|
}
|
196
208
|
|
197
|
-
|
198
209
|
input.connectChatButton{
|
199
210
|
text-align: center;
|
200
211
|
width: 150px;
|
@@ -355,15 +366,8 @@ a.chatImageLink:link, a.chatImageLink:visited {
|
|
355
366
|
}
|
356
367
|
|
357
368
|
|
358
|
-
|
359
|
-
|
360
369
|
/* Search contacts stylesheet */
|
361
370
|
|
362
|
-
div.allContacts {
|
363
|
-
width: 100px;
|
364
|
-
display: block;
|
365
|
-
}
|
366
|
-
|
367
371
|
#search_chat_contact_flexselect {
|
368
372
|
background: url('btn/search_icon.png') 5px 50% no-repeat $secondary-color;
|
369
373
|
padding: 0 0px 0 0px;
|
@@ -106,11 +106,8 @@ class XmppController < ApplicationController
|
|
106
106
|
#OPEN METHODS
|
107
107
|
|
108
108
|
def chatWindow
|
109
|
-
if current_user and current_user.chat_enabled
|
109
|
+
if current_user and current_user.chat_enabled
|
110
110
|
render :partial => 'chat/contacts'
|
111
|
-
elsif current_user and current_user.chat_enabled
|
112
|
-
#User not connected
|
113
|
-
render :partial => 'chat/off'
|
114
111
|
else
|
115
112
|
#User with chat disabled
|
116
113
|
render :text => ''
|
data/app/helpers/xmpp_helper.rb
CHANGED
@@ -1,22 +1,13 @@
|
|
1
1
|
module XmppHelper
|
2
2
|
|
3
3
|
def getChatContacts
|
4
|
-
|
5
|
-
|
4
|
+
#Get bidirectional contacts
|
5
|
+
contacts = current_user.contact_actors(:type=>:user)
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
#Apply filters
|
8
|
+
#...
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
contacts.each do |contact|
|
13
|
-
if contact.user.connected
|
14
|
-
connected_users << contact.user
|
15
|
-
end
|
16
|
-
all_users << contact.user
|
17
|
-
end
|
18
|
-
|
19
|
-
return [connected_users,all_users]
|
10
|
+
return contacts;
|
20
11
|
end
|
21
|
-
|
12
|
+
|
22
13
|
end
|
@@ -1,65 +1,18 @@
|
|
1
|
-
|
2
|
-
<div class="block">
|
3
|
-
<div class="header">
|
4
|
-
<%=image_tag("btn/btn_friend.png", :class => "header_icon")%>
|
5
|
-
<div class="header_text">
|
6
|
-
<%=t('chat.title')%>
|
7
|
-
</div>
|
8
|
-
</div>
|
9
|
-
|
10
|
-
<div id="status" class="dropdown">
|
11
|
-
<dt><a href=""><span><%=t('chat.status.choose')%></span></a></dt>
|
12
|
-
<dd>
|
13
|
-
<ul id="statusList">
|
14
|
-
<li><a id="available" href="#" class="option"><img class="flag" src="<%=image_path("status/available.png")%>" alt=""/> <%=t('chat.status.available')%> <span class="value">available</span></a></li>
|
15
|
-
<li><a id="away" href="#" class="option"><img class="flag" src="<%=image_path("status/away.png")%>" alt=""/> <%=t('chat.status.away')%> <span class="value">away</span></a></li>
|
16
|
-
<li><a id="dnd" href="#" class="option"><img class="flag" src="<%=image_path("status/dnd.png")%>" alt=""/> <%=t('chat.status.dnd')%> <span class="value">dnd</span></a></li>
|
17
|
-
<li><a id="offline" href="#" class="option"><img class="flag" src="<%=image_path("status/offline.png")%>" alt=""/> <%=t('chat.status.offline')%> <span class="value">offline</span></a></li>
|
18
|
-
</ul>
|
19
|
-
</dd>
|
20
|
-
</div>
|
21
|
-
|
22
|
-
</div>
|
23
|
-
|
24
|
-
<% @contacts = getChatContacts %>
|
25
|
-
<% @online_contacts = @contacts[0] %>
|
26
|
-
<% @all_contacts = @contacts[1] %>
|
27
|
-
|
28
|
-
<div class="allContacts">
|
29
|
-
<select data-placeholder="Search Contact" id="search_chat_contact" class="flexselect">
|
30
|
-
<option value=""></option>
|
31
|
-
<% unless @all_contacts.empty? %>
|
32
|
-
<%@all_contacts.each do |contact| %>
|
33
|
-
<option value="<%=contact.slug%>">
|
34
|
-
<%=contact.name%>
|
35
|
-
<a title='<%=contact.name%>' class="presence_user_link" width="28">
|
36
|
-
<%=image_tag(contact.logo.url, :alt => contact.name , :size => "28x28")%>
|
37
|
-
<% if contact.user.status %>
|
38
|
-
<%=image_tag("status/" + contact.user.status + ".png", :class => "presence_status") %></a>
|
39
|
-
<% end %>
|
40
|
-
</a>
|
41
|
-
</option>
|
42
|
-
<% end %>
|
43
|
-
<% else %>
|
44
|
-
<option value="ZERO_CONTACTS"> <%=t('chat.zerocontacts')%></option>
|
45
|
-
<% end %>
|
46
|
-
</select>
|
47
|
-
</div>
|
1
|
+
<% @all_contacts = getChatContacts %>
|
48
2
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
<a title='<%=contact.name%>' class="presence_user_link" width="28">
|
56
|
-
<%=image_tag(contact.logo.url, :alt => contact.name , :size => "28x28")%>
|
57
|
-
<% if contact.user.status %>
|
58
|
-
<%=image_tag("status/" + contact.user.status + ".png", :class => "presence_status") %></a>
|
59
|
-
<% end %>
|
60
|
-
</a>
|
61
|
-
</div>
|
62
|
-
<%end%>
|
3
|
+
<div class="users_connected">
|
4
|
+
<%@all_contacts.each do |contact| %>
|
5
|
+
<% if contact.user.connected %>
|
6
|
+
<div class="user_presence" name='<%=contact.name%>' slug='<%=contact.slug%>' connected='true'>
|
7
|
+
<% else %>
|
8
|
+
<div class="user_presence" name='<%=contact.name%>' slug='<%=contact.slug%>' connected='false'>
|
63
9
|
<% end %>
|
64
|
-
|
65
|
-
|
10
|
+
<a title='<%=contact.name%>' class="presence_user_link" width="28">
|
11
|
+
<%=image_tag(contact.logo.url, :alt => contact.name , :size => "28x28")%>
|
12
|
+
<% if contact.user.status %>
|
13
|
+
<%=image_tag("status/" + contact.user.status + ".png", :class => "presence_status") %>
|
14
|
+
<% end %>
|
15
|
+
</a>
|
16
|
+
</div>
|
17
|
+
<%end%>
|
18
|
+
</div>
|
@@ -1,12 +1,73 @@
|
|
1
1
|
<% if current_user and current_user.chat_enabled and current_subject.subject_type=="User" %>
|
2
2
|
|
3
3
|
<div id="chat_wrapper">
|
4
|
-
|
5
|
-
|
4
|
+
|
5
|
+
<div id="chat_partial">
|
6
6
|
</div>
|
7
|
+
|
7
8
|
<div id="chat_divs">
|
8
9
|
<div id="chat_div"></div>
|
9
10
|
</div>
|
11
|
+
|
12
|
+
<div id="chat_connecting">
|
13
|
+
<div class="block">
|
14
|
+
<div class="header">
|
15
|
+
<%=image_tag("btn/btn_friend.png", :class => "header_icon")%>
|
16
|
+
<div class="header_text">
|
17
|
+
<%=t('chat.connecting')%>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
|
23
|
+
<div id="chat_connection_off">
|
24
|
+
<div class="block">
|
25
|
+
<div class="header">
|
26
|
+
<%=image_tag("btn/btn_friend.png", :class => "header_icon")%>
|
27
|
+
<div class="header_text">
|
28
|
+
<p id="chat_header_title"><%=t('chat.disconnected')%></p>
|
29
|
+
</div>
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
<div class="chat_off">
|
33
|
+
<div id="passwordFormChat">
|
34
|
+
<label for="user_password" class="chatPasswordTitle"><%=t('chat.password')%></label>
|
35
|
+
<input id="user_password" class="chat_password" type="password"></input>
|
36
|
+
</div>
|
37
|
+
<input class="connectChatButton storePass" value="Connect">
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<div id="chat_widgets">
|
42
|
+
<div class="block">
|
43
|
+
<div class="header">
|
44
|
+
<%=image_tag("btn/btn_friend.png", :class => "header_icon")%>
|
45
|
+
<div class="header_text">
|
46
|
+
<%=t('chat.title')%>
|
47
|
+
</div>
|
48
|
+
</div>
|
49
|
+
|
50
|
+
<div id="status" class="dropdown">
|
51
|
+
<dt><a href=""><span><%=t('chat.status.choose')%></span></a></dt>
|
52
|
+
<dd>
|
53
|
+
<ul id="statusList">
|
54
|
+
<li><a id="available" href="#" class="option"><img class="flag" src="<%=image_path("status/available.png")%>" alt=""/> <%=t('chat.status.available')%> <span class="value">available</span></a></li>
|
55
|
+
<li><a id="away" href="#" class="option"><img class="flag" src="<%=image_path("status/away.png")%>" alt=""/> <%=t('chat.status.away')%> <span class="value">away</span></a></li>
|
56
|
+
<li><a id="dnd" href="#" class="option"><img class="flag" src="<%=image_path("status/dnd.png")%>" alt=""/> <%=t('chat.status.dnd')%> <span class="value">dnd</span></a></li>
|
57
|
+
<li><a id="offline" href="#" class="option"><img class="flag" src="<%=image_path("status/offline.png")%>" alt=""/> <%=t('chat.status.offline')%> <span class="value">offline</span></a></li>
|
58
|
+
</ul>
|
59
|
+
</dd>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div class="searchChatContacts">
|
63
|
+
<select id="search_chat_contact" class="flexselect">
|
64
|
+
<option value="">""</option>
|
65
|
+
</select>
|
66
|
+
</div>
|
67
|
+
|
68
|
+
</div>
|
69
|
+
</div>
|
70
|
+
|
10
71
|
</div>
|
11
72
|
|
12
73
|
|
@@ -21,10 +82,17 @@
|
|
21
82
|
|
22
83
|
|
23
84
|
$(document).ready(function () {
|
24
|
-
|
85
|
+
|
86
|
+
//Inicial field
|
87
|
+
$("#chat_partial").html($("#chat_connecting").html())
|
88
|
+
|
25
89
|
if(getRestoreUserChatStatus()!="offline"){
|
26
|
-
|
27
|
-
|
90
|
+
if (authByCookie()){
|
91
|
+
connectToChat(user_jid,cookie,null);
|
92
|
+
} else {
|
93
|
+
//Auth by password
|
94
|
+
connectToChat(user_jid,null,null);
|
95
|
+
}
|
28
96
|
|
29
97
|
initialTimer = setTimeout("updateChatWindow()", 15000);
|
30
98
|
} else {
|
@@ -32,20 +100,20 @@
|
|
32
100
|
}
|
33
101
|
|
34
102
|
initAudio();
|
35
|
-
initFocusListeners();
|
103
|
+
initFocusListeners();
|
36
104
|
});
|
37
105
|
|
38
106
|
</script>
|
39
107
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
108
|
+
<% if flow %>
|
109
|
+
<script type="text/javascript">
|
110
|
+
$(document).ready(function () {
|
111
|
+
createMainChatBox();
|
112
|
+
addContentToMainChatBox(modifyChatPartialIfMainBox($("#chat_partial")));
|
113
|
+
$("#chat_wrapper").find("#chat_partial").remove();
|
114
|
+
});
|
115
|
+
</script>
|
116
|
+
<% end %>
|
49
117
|
|
50
118
|
|
51
119
|
<% end %>
|