social_stream-presence 0.5.2 → 0.5.3

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.
@@ -178,7 +178,7 @@ function updateChatWindow(){
178
178
  var stropheConnectedAndOnlineStatus = ((isStropheConnected()) && (userStatus!="offline") && (!disconnectionFlag));
179
179
  $.post("/chatWindow", { userConnected: stropheConnectedAndOnlineStatus }, function(data){
180
180
  $(".tooltip").hide() //Prevent tooltips
181
- $("#chat_partial").html(data);
181
+ $("#chat_partial").html(modifyChatPartialIfMainBox(data));
182
182
  if (isStropheConnected()) {
183
183
  setStatusWidgetTitle(userStatus);
184
184
  $(".user_presence a[title]").tooltip();
@@ -4,6 +4,7 @@
4
4
 
5
5
 
6
6
  function storeChatData(){
7
+
7
8
  //Check for Session Storage support
8
9
  if (! window.sessionStorage){
9
10
  return
@@ -75,6 +76,19 @@ function storeUserChatStatus(){
75
76
  sessionStorage.setItem("chat_user_status", userStatus);
76
77
  }
77
78
 
79
+ function removeAllDataStored(){
80
+ sessionStorage.removeItem("cookie");
81
+ sessionStorage.removeItem("chat_user_name");
82
+ sessionStorage.removeItem("chat_user_slug");
83
+ sessionStorage.removeItem("chat_user_jid");
84
+
85
+ sessionStorage.removeItem("chat_user_status");
86
+
87
+ sessionStorage.removeItem("slugs_with_stored_log");
88
+ sessionStorage.removeItem("slugs_with_visible_max_chatbox");
89
+ sessionStorage.removeItem("slugs_with_visible_min_chatbox");
90
+ }
91
+
78
92
  function getRestoreUserChatStatus(){
79
93
  if (!window.sessionStorage) {
80
94
  return "available";
@@ -8,6 +8,7 @@ var chatBoxWidth = 230;
8
8
  var chatBoxHeight = 170;
9
9
  var videoBoxHeight = 150;
10
10
  var visibleChatBoxes = new Array();
11
+ var offsetForFlowBox = 0;
11
12
  var chatBoxSeparation = chatBoxWidth+12;
12
13
 
13
14
 
@@ -98,6 +99,11 @@ function getBoxParams(){
98
99
  } else {
99
100
  nBox++;
100
101
  boxParams[0] = (nBox-1)*(chatBoxSeparation);
102
+
103
+ if((nBox!=1)&&(mainChatBox!=null)){
104
+ boxParams[0] = boxParams[0] - offsetForFlowBox;
105
+ }
106
+
101
107
  boxParams[1] = nBox;
102
108
  }
103
109
 
@@ -115,11 +121,18 @@ function getSlugFromChatVariable(variable){
115
121
  }
116
122
 
117
123
  function getVisibleChatBoxes(){
124
+
125
+ for(i=0; i<visibleChatBoxes.length; i++){
126
+ if (visibleChatBoxes[i][0].id==chatSlugId){
127
+ visibleChatBoxes.splice(i,1)
128
+ }
129
+ }
130
+
118
131
  return visibleChatBoxes
119
132
  }
120
133
 
121
134
  function getAllChatBoxes(){
122
- return $(".chatbox")
135
+ return $(".chatbox").not(document.getElementById(chatSlugId))
123
136
  }
124
137
 
125
138
  ////////////////////
@@ -191,3 +204,69 @@ function toogleVideoBoxForSlug(slug){
191
204
  function getVideoEmbedForSlug(slug){
192
205
  return "<img src=\"http://www.batiburrillo.net/wp-content/uploads/2011/03/Freemake.jpg?cda6c1\" width=\"" + (chatBoxWidth-20) + "\"/>"
193
206
  }
207
+
208
+
209
+ ///////////////////////////
210
+ // Create Main Chat Box
211
+ ///////////////////////////
212
+
213
+ var mainChatBox;
214
+ var chatSlugId="SocialStream_MainChat"
215
+
216
+ function createMainChatBox(){
217
+ if (mainChatBox==null){
218
+
219
+ //createChatBox(guest_slug,guest_name,guest_jid,user_name,user_jid)
220
+ if (createChatBox(chatSlugId,"Chat","Any","Any","Any")){
221
+ mainChatBox = window[getChatVariableFromSlug(chatSlugId)]
222
+
223
+ //Modify default box
224
+
225
+ //Delete closeTick and video Tick
226
+ $(mainChatBox.parent().parent()).find(".ui-chatbox-titlebar").find(".ui-icon-closethick").remove();
227
+ $(mainChatBox.parent().parent()).find(".ui-videobox-icon").remove();
228
+ //Delete nofitications div
229
+ $(mainChatBox.parent()).find(".ui-chatbox-notify").remove();
230
+ //Delete video div
231
+ $(mainChatBox.parent()).find(".ui-videobox").remove();
232
+ //Delete input
233
+ $(mainChatBox.parent()).find(".ui-chatbox-input").remove();
234
+
235
+ //Set height
236
+ window[getChatVariableFromSlug(chatSlugId)].css( "height", "180" );
237
+
238
+ //Set width
239
+ var windowWidth=150;
240
+ window[getChatVariableFromSlug(chatSlugId)].parent().parent().css( "width", windowWidth );
241
+ $(mainChatBox.parent().parent()).find(".ui-chatbox-titlebar").css( "width", windowWidth-6 );
242
+ $(mainChatBox).css( "width", windowWidth-6 );
243
+
244
+
245
+ //Adjust window offset
246
+ offsetForFlowBox = 235-windowWidth;
247
+
248
+ //CSS Adjusts
249
+ $("#chat_partial").css("margin-top",-3)
250
+ $("#chat_partial").css("margin-left",-3)
251
+ $(".dropdown dd ul").css("min-width",147)
252
+
253
+ }
254
+ }
255
+ }
256
+
257
+
258
+ function addContentToMainChatBox(content){
259
+ $(mainChatBox.parent()).find("#" + chatSlugId).html(content);
260
+ }
261
+
262
+
263
+ function modifyChatPartialIfMainBox(chatPartial){
264
+ if (mainChatBox != null) {
265
+ p = $(chatPartial)
266
+
267
+ $(p).find(".header").remove();
268
+ $(p).find(".dropdown dd ul").css("min-width",147);
269
+ }
270
+
271
+ return $(p);
272
+ }
@@ -1,7 +1,6 @@
1
1
  ////////////////////
2
2
  //Global constants
3
3
  ////////////////////
4
- var BOSH_SERVICE = '<%= SocialStream::Presence.bosh_service || root_url + "http-bind/" %>';
5
4
  var domain = '<%=SocialStream::Presence.domain%>';
6
5
  var sound_path = "/assets/audio/chat/onMessage";
7
6
 
@@ -11,7 +11,7 @@
11
11
  <div id="status" class="dropdown">
12
12
  <dt><a href=""><span><%=t('chat.status.choose')%></span></a></dt>
13
13
  <dd>
14
- <ul>
14
+ <ul id="statusList">
15
15
  <li><a id="available" href="#" class="option"><img class="flag" src="assets/status/available.png" alt=""/> <%=t('chat.status.available')%> <span class="value">available</span></a></li>
16
16
  <li><a id="away" href="#" class="option"><img class="flag" src="assets/status/away.png" alt=""/> <%=t('chat.status.away')%> <span class="value">away</span></a></li>
17
17
  <li><a id="dnd" href="#" class="option"><img class="flag" src="assets/status/dnd.png" alt=""/> <%=t('chat.status.dnd')%> <span class="value">dnd</span></a></li>
@@ -41,7 +41,4 @@
41
41
 
42
42
  </div>
43
43
 
44
- <div id="chat_divs">
45
- <div id="chat_div">
46
- </div>
47
- </div>
44
+
@@ -1,35 +1,52 @@
1
1
  <% if current_user and current_user.chat_enabled and current_subject.subject_type=="User" %>
2
2
 
3
+ <div id="chat_wrapper">
4
+ <div id="chat_partial">
5
+ <%= render :partial => 'chat/connecting' %>
6
+ </div>
7
+ <div id="chat_divs">
8
+ <div id="chat_div"></div>
9
+ </div>
10
+ </div>
3
11
 
4
- <script type="text/javascript">
5
12
 
6
- //Global variables
7
- var cookie = "AuthenticationByCookie>>" + "<%=cookies[Rails.application.config.session_options[:key]]%>";
8
- var user_name = '<%=current_user.name%>';
9
- var user_slug = '<%=current_user.slug%>';
10
- var user_jid = '<%=current_user.slug%>'+"@"+domain;
13
+ <script type="text/javascript">
11
14
 
15
+ //Global variables
16
+ var cookie = "AuthenticationByCookie>>" + "<%=cookies[Rails.application.config.session_options[:key]]%>";
17
+ var BOSH_SERVICE = '<%= SocialStream::Presence.bosh_service || root_url + "http-bind/" %>';
18
+ var user_name = '<%=current_user.name%>';
19
+ var user_slug = '<%=current_user.slug%>';
20
+ var user_jid = '<%=current_user.slug%>'+"@"+domain;
12
21
 
13
- $(document).ready(function () {
14
-
15
- if(getRestoreUserChatStatus()!="offline"){
16
- connectToChat(user_jid,cookie,null);
17
- //connectToChat(user_jid,null,null); //To use auth by password.
18
-
19
- initialTimer = setTimeout("updateChatWindow()", 15000);
20
- } else {
21
- initialTimer = setTimeout("updateChatWindow()", 1);
22
- }
23
-
24
- initAudio();
25
- initFocusListeners();
26
- });
27
-
28
- </script>
22
+
23
+ $(document).ready(function () {
24
+
25
+ if(getRestoreUserChatStatus()!="offline"){
26
+ connectToChat(user_jid,cookie,null);
27
+ //connectToChat(user_jid,null,null); //To use auth by password.
28
+
29
+ initialTimer = setTimeout("updateChatWindow()", 15000);
30
+ } else {
31
+ initialTimer = setTimeout("updateChatWindow()", 1);
32
+ }
33
+
34
+ initAudio();
35
+ initFocusListeners();
29
36
 
37
+ });
38
+
39
+ </script>
40
+
41
+ <% if flow %>
42
+ <script type="text/javascript">
43
+ $(document).ready(function () {
44
+ createMainChatBox();
45
+ addContentToMainChatBox(modifyChatPartialIfMainBox($("#chat_partial")));
46
+ $("#chat_wrapper").find("#chat_partial").remove();
47
+ });
48
+ </script>
49
+ <% end %>
50
+
30
51
 
31
- <div id="chat_partial">
32
- <%= render :partial => 'chat/connecting' %>
33
- </div>
34
-
35
52
  <% end %>
data/config/routes.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  Rails.application.routes.draw do
2
- #match "/active_users" => "Xmpp#active_users"
2
+ match "/active_users" => "Xmpp#active_users"
3
3
 
4
4
  match '/xmpp/setConnection' => "Xmpp#setConnection"
5
5
  match '/xmpp/unsetConnection' => "Xmpp#unsetConecction"
@@ -1,5 +1,5 @@
1
1
  module Socialstream
2
2
  module Presence
3
- VERSION = "0.5.2"
3
+ VERSION = "0.5.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 2
9
- version: 0.5.2
8
+ - 3
9
+ version: 0.5.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Aldo Gordillo