social_stream 0.21.3 → 0.21.4

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 (52) hide show
  1. data/base/app/assets/stylesheets/base.css.scss +1 -1
  2. data/base/app/assets/stylesheets/header.css.scss +1 -1
  3. data/base/app/helpers/notifications_helper.rb +6 -0
  4. data/base/app/models/activity.rb +13 -0
  5. data/base/app/models/comment.rb +7 -0
  6. data/base/app/models/post.rb +1 -1
  7. data/base/app/views/comments/_comment_focus_search.html.erb +37 -0
  8. data/base/app/views/comments/_comment_global_search.html.erb +18 -0
  9. data/base/app/views/comments/_comment_with_details.html.erb +3 -0
  10. data/base/app/views/notifications/_index.html.erb +1 -0
  11. data/base/app/views/notifications/activities/_like.html.erb +4 -4
  12. data/base/app/views/notifications/activities/_like.text.erb +2 -2
  13. data/base/app/views/notifications/activities/_post.html.erb +2 -2
  14. data/base/app/views/notifications/activities/_post.text.erb +1 -1
  15. data/base/app/views/notifications/activities/_update.html.erb +3 -3
  16. data/base/app/views/notifications/activities/_update.text.erb +3 -3
  17. data/base/lib/social_stream-base.rb +2 -1
  18. data/base/lib/social_stream/base/engine.rb +1 -0
  19. data/base/lib/social_stream/base/version.rb +1 -1
  20. data/base/lib/social_stream/controllers/mark_notifications_read.rb +19 -0
  21. data/documents/app/models/audio.rb +2 -2
  22. data/documents/app/models/document.rb +2 -2
  23. data/documents/app/models/picture.rb +2 -2
  24. data/documents/app/models/video.rb +2 -2
  25. data/documents/lib/social_stream/documents/version.rb +1 -1
  26. data/documents/social_stream-documents.gemspec +1 -1
  27. data/events/lib/social_stream/events/version.rb +1 -1
  28. data/events/social_stream-events.gemspec +1 -1
  29. data/lib/social_stream/version.rb +1 -1
  30. data/linkser/app/models/link.rb +2 -2
  31. data/linkser/lib/social_stream/linkser/version.rb +1 -1
  32. data/linkser/social_stream-linkser.gemspec +1 -1
  33. data/presence/app/assets/javascripts/chat_interface_manager.js.erb +264 -143
  34. data/presence/app/assets/javascripts/chat_persistence.js +3 -5
  35. data/presence/app/assets/javascripts/chat_utilities.js +6 -0
  36. data/presence/app/assets/javascripts/chat_window_manager.js +9 -1
  37. data/presence/{vendor/assets/javascripts/jquery.flexselect.js → app/assets/javascripts/jquery.flexselect.sstreampresence.js} +16 -8
  38. data/presence/{vendor/assets/javascripts/jquery.ui.chatbox.js → app/assets/javascripts/jquery.ui.chatbox.sstreampresence.js} +0 -0
  39. data/presence/app/assets/javascripts/social_stream-presence.js +2 -2
  40. data/presence/app/assets/javascripts/xmpp_client_management.js.erb +8 -21
  41. data/presence/app/assets/stylesheets/chat.css.scss +17 -13
  42. data/presence/app/controllers/xmpp_controller.rb +1 -4
  43. data/presence/app/helpers/xmpp_helper.rb +6 -15
  44. data/presence/app/views/chat/_contacts.html.erb +16 -63
  45. data/presence/app/views/chat/_index.html.erb +83 -15
  46. data/presence/lib/social_stream-presence.rb +1 -0
  47. data/presence/lib/social_stream/presence/version.rb +1 -1
  48. data/presence/social_stream-presence.gemspec +1 -1
  49. data/social_stream.gemspec +5 -5
  50. metadata +37 -35
  51. data/presence/app/views/chat/_connecting.html.erb +0 -8
  52. data/presence/app/views/chat/_off.html.erb +0 -54
@@ -237,7 +237,7 @@ div.chzn-container ul.chzn-choices li.search-field input{ cursor:pointer;}
237
237
  text-decoration: none;
238
238
  }
239
239
  .menu_plain_list li span {
240
- padding: 5px 10px;
240
+ padding: 5px 7px;
241
241
  background-color: $secondary-color;
242
242
  }
243
243
  .menu_plain_list li span.selected {
@@ -1,7 +1,7 @@
1
1
  @import "colors";
2
2
 
3
3
  /****************** HEADER STRUCTURE ******/
4
- #headerFront { width: 100%; padding: 0; background: $header-color; padding: 0px 0px 0px 0px;}
4
+ #headerFront { width: 100%; padding: 0px; background: $header-color; }
5
5
  #header_left { left: 0px; float: left; padding-left: 15px; padding-right: 5px; width:155px;}
6
6
  #header_right { right: 0px; float: right; padding-right: 10px; }
7
7
  .banner_top{ width: 960px; margin-left: auto; margin-right: auto; margin-top: 0px;
@@ -28,4 +28,10 @@ module NotificationsHelper
28
28
  end
29
29
  end
30
30
 
31
+ # Add notification_id param to URL in order to mark notification read
32
+ def notification_url_of(target, notification)
33
+ return polymorphic_url(target, :notification_id => notification.id) unless notification.nil?
34
+ polymorphic_url(target)
35
+ end
36
+
31
37
  end
@@ -17,6 +17,10 @@ class Activity < ActiveRecord::Base
17
17
  # See {SocialStream::Models::Channeled}
18
18
  channeled
19
19
 
20
+ # This has to be declared before 'has_ancestry' to work around rails issue #670
21
+ # See: https://github.com/rails/rails/issues/670
22
+ before_destroy :destroy_children_comments
23
+
20
24
  has_ancestry
21
25
 
22
26
  paginates_per 10
@@ -397,6 +401,15 @@ class Activity < ActiveRecord::Base
397
401
  direct_activity_object.increment!(:like_count)
398
402
  end
399
403
 
404
+ # before_destroy callback
405
+ #
406
+ # Destroy children comments when the activity is destroyed
407
+ def destroy_children_comments
408
+ comments.each do |c|
409
+ c.direct_object.destroy
410
+ end
411
+ end
412
+
400
413
  # after_destroy callback
401
414
  #
402
415
  # Decrement like counter in objects when like activity is destroyed
@@ -4,6 +4,13 @@ class Comment < ActiveRecord::Base
4
4
  alias_attribute :text, :description
5
5
  validates_presence_of :text
6
6
 
7
+ define_index do
8
+ indexes activity_object.description
9
+
10
+ has created_at
11
+ end
12
+
13
+
7
14
  def parent_post
8
15
  self.post_activity.parent.direct_object
9
16
  end
@@ -5,7 +5,7 @@ class Post < ActiveRecord::Base
5
5
  validates_presence_of :text
6
6
 
7
7
  define_index do
8
- indexes text
8
+ indexes activity_object.description
9
9
 
10
10
  has created_at
11
11
  end
@@ -0,0 +1,37 @@
1
+ <% activity = comment.post_activity %>
2
+ <%= div_for activity, :class => 'super_activity' do %>
3
+ <div class="actor_logo">
4
+ <%= link_to image_tag(activity.sender_subject.logo.url(:actor),
5
+ :alt => activity.sender_subject.name),
6
+ activity.sender_subject %>
7
+ </div>
8
+ <div class="activity_content">
9
+ <div class="actor_name">
10
+ <%= activity.title(self) %>
11
+ </div>
12
+ <div class="activity_objects">
13
+ <%= link_to comment do%>
14
+ <% text = excerpt(strip_tags(comment.text),get_search_query_words.first,:radius => 180) || "" %>
15
+ <% if text.length < 400 %>
16
+ <% text = excerpt(strip_tags(comment.text),get_search_query_words.first,:radius => 540 - text.length) || "" %>
17
+ <% end %>
18
+ <%= highlight(text,get_search_query_words) %>
19
+ <% end %>
20
+ </div>
21
+ <div class="activity_options">
22
+ <div class="comment_time_ago">
23
+ <%= t('time.ago', :time => time_ago_in_words(activity.created_at)) %>
24
+ </div>
25
+ <% if user_signed_in? %>
26
+ ·
27
+ <%= link_to activity.audience_in_words(current_subject, :details => :summary),
28
+ 'javascript:;',
29
+ :class => 'activity_audience_summary' %>
30
+ <div class="activity_audience">
31
+ <%= activity.audience_in_words(current_subject) %>
32
+ </div>
33
+ <% end %>
34
+ </div>
35
+ </div>
36
+ <% end %>
37
+
@@ -0,0 +1,18 @@
1
+ <% author = comment.author_subject %>
2
+ <div class="model_with_details">
3
+ <div class="logo">
4
+ <%= link_to (image_tag(author.logo.url , :size => "50x50", :alt => author.name )), author %>
5
+ </div>
6
+ <div class="sub-block">
7
+ <div class="brief">
8
+ <%= link_to comment do%>
9
+ <% text = excerpt(strip_tags(comment.text),get_search_query_words.first,:radius => 25) || "" %>
10
+ <% if text.length < 60 %>
11
+ <% text = excerpt(strip_tags(comment.text),get_search_query_words.first,:radius => 30 + (60 - text.length)) || "" %>
12
+ <% end %>
13
+ <%= highlight(text,get_search_query_words) %>
14
+ <% end %>
15
+ <br>
16
+ </div>
17
+ </div>
18
+ </div>
@@ -0,0 +1,3 @@
1
+ <%= div_for comment, :class => 'content_size' do %>
2
+ <%= simple_format comment.text %>
3
+ <% end %>
@@ -13,6 +13,7 @@
13
13
 
14
14
  <div class="conversations">
15
15
  <% @notifications.each do |notification|%>
16
+ <% @notification = notification %>
16
17
  <% read_class = notification.is_unread?(@actor) ? 'unread' : '' %>
17
18
  <%= render :partial => 'notification', :object => notification, :locals => {:read_class => read_class} %>
18
19
  <% end %>
@@ -16,15 +16,15 @@
16
16
  :whose => t('notification.whose.'+ activity.receiver.subject.class.to_s.underscore,
17
17
  :receiver => truncate_name(activity.receiver.name)),
18
18
  :thing => link_to(t(activity.direct_object.class.to_s.underscore+'.name'),
19
- polymorphic_url( activity.direct_object))) %>
19
+ notification_url_of( activity.direct_object, @notification))) %>
20
20
  </div>
21
21
  <div class="briefing">
22
22
  <% if activity.direct_object.respond_to? :text %>
23
23
  "<%= link_to(sanitize(activity.direct_object.text.truncate(100, :separator =>' ')),
24
- polymorphic_url( activity.direct_object))%>"
24
+ notification_url_of( activity.direct_object, @notification))%>"
25
25
  <% else%>
26
26
  <%= link_to(t('notification.watch_it'),
27
- polymorphic_url( activity.direct_object))%>
27
+ notification_url_of( activity.direct_object, @notification))%>
28
28
  <%end%>
29
29
  </div>
30
- <% end %>
30
+ <% end %>
@@ -13,9 +13,9 @@
13
13
 
14
14
  <% if activity.direct_object.respond_to? :text %>
15
15
  "<%= sanitize(activity.direct_object.text.truncate(100, :separator =>' '))%>"
16
- <%= raw t('notification.all_text', :url => polymorphic_url(activity.direct_object))%>
16
+ <%= raw t('notification.all_text', :url => notification_url_of(activity.direct_object, @notification))%>
17
17
  <% else%>
18
- --><%= raw t('notification.watch', :url => polymorphic_url( activity.direct_object))%>
18
+ --><%= raw t('notification.watch', :url => notification_url_of( activity.direct_object, @notification))%>
19
19
  <%end%>
20
20
  <% end %>
21
21
 
@@ -5,9 +5,9 @@
5
5
  :whose => t('notification.whose.'+ activity.receiver.subject.class.to_s.underscore,
6
6
  :receiver => truncate_name(activity.receiver.name)),
7
7
  :title => link_to(title_of(activity.direct_object),
8
- polymorphic_url(activity.direct_object))) %>
8
+ notification_url_of(activity.direct_object, @notification))) %>
9
9
  </div>
10
10
  <div class="briefing">
11
- "<%= link_to(description_of(activity.direct_object), polymorphic_url(activity.direct_object))%>"
11
+ "<%= link_to(description_of(activity.direct_object), notification_url_of(activity.direct_object, @notification))%>"
12
12
  </div>
13
13
 
@@ -6,7 +6,7 @@
6
6
  :title => title_of(activity.direct_object)) %>
7
7
 
8
8
  "<%= description_of(activity.direct_object) %>"
9
- --><%= t('notification.all_text', :url => polymorphic_url(activity.direct_object))%>
9
+ --><%= t('notification.all_text', :url => notification_url_of(activity.direct_object, @notification))%>
10
10
 
11
11
  <%= raw t('notification.look',
12
12
  :sender => truncate_name(activity.sender.name))%>: <%=polymorphic_url(activity.sender.subject)%>
@@ -5,14 +5,14 @@
5
5
  :whose => t('notification.whose.'+ activity.receiver.subject.class.to_s.underscore,
6
6
  :receiver => truncate_name(activity.receiver.name)),
7
7
  :thing => link_to(t(activity.direct_object.class.to_s.underscore+'.one'),
8
- polymorphic_url( activity.direct_object))) %>
8
+ notification_url_of( activity.direct_object, @notification))) %>
9
9
  </div>
10
10
  <div class="briefing">
11
11
  <% if activity.direct_object.respond_to? :text %>
12
12
  "<%= link_to(sanitize(activity.direct_object.text.truncate(100, :separator =>' ')),
13
- polymorphic_url(activity.direct_object))%>"
13
+ notification_url_of(activity.direct_object, @notification))%>"
14
14
  <% else%>
15
15
  <%= link_to(t('notification.watch_it'),
16
- polymorphic_url( activity.direct_object))%>
16
+ notification_url_of( activity.direct_object, @notification))%>
17
17
  <%end%>
18
18
  </div>
@@ -6,10 +6,10 @@
6
6
 
7
7
  <% if activity.direct_object.respond_to? :text %>
8
8
  "<%= sanitize activity.direct_object.text.truncate(100, :separator =>' ')%>"
9
- --><%= t('notification.all_text', :url => polymorphic_url(activity.direct_object))%>
9
+ --><%= t('notification.all_text', :url => notification_url_of(activity.direct_object, @notification))%>
10
10
  <% else%>
11
- <%= t('notification.watch', :url => polymorphic_url( activity.direct_object))%>
11
+ <%= t('notification.watch', :url => notification_url_of( activity.direct_object, @notification))%>
12
12
  <% end%>
13
13
 
14
14
  <%= raw t('notification.look',
15
- :sender => truncate_name(activity.sender.name))%>: <%=polymorphic_url(activity.sender.subject)%>
15
+ :sender => truncate_name(activity.sender.name))%>: <%=polymorphic_url(activity.sender.subject)%>
@@ -10,6 +10,7 @@ module SocialStream
10
10
  autoload :TestHelpers, 'social_stream/test_helpers'
11
11
 
12
12
  module Controllers
13
+ autoload :MarkNotificationsRead, 'social_stream/controllers/mark_notifications_read'
13
14
  autoload :I18nIntegration, 'social_stream/controllers/i18n_integration'
14
15
  autoload :CancanDeviseIntegration, 'social_stream/controllers/cancan_devise_integration'
15
16
  autoload :Helpers, 'social_stream/controllers/helpers'
@@ -62,7 +63,7 @@ module SocialStream
62
63
  @@quick_search_models = [ :user, :group, :post ]
63
64
 
64
65
  mattr_accessor :extended_search_models
65
- @@extended_search_models = [ :user, :group, :post ]
66
+ @@extended_search_models = [ :user, :group, :post, :comment ]
66
67
 
67
68
  mattr_accessor :cleditor_controls
68
69
  @@cleditor_controls = "bold italic underline strikethrough subscript superscript | size style | bullets | image link unlink"
@@ -31,6 +31,7 @@ module SocialStream
31
31
  include SocialStream::Controllers::Helpers
32
32
  include SocialStream::Controllers::CancanDeviseIntegration
33
33
  include SocialStream::Controllers::I18nIntegration
34
+ include SocialStream::Controllers::MarkNotificationsRead
34
35
  end
35
36
  end
36
37
 
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Base
3
- VERSION = "0.16.1".freeze
3
+ VERSION = "0.16.2".freeze
4
4
  end
5
5
  end
@@ -0,0 +1,19 @@
1
+ module SocialStream
2
+ module Controllers
3
+ # Common methods added to ApplicationController
4
+ module MarkNotificationsRead
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ before_filter :mark_notifications_read
9
+ end
10
+
11
+ # Mark notifications read when following a link
12
+ def mark_notifications_read
13
+ return if params[:notification_id].blank? or !user_signed_in?
14
+ n = Notification.find(params[:notification_id])
15
+ current_subject.read n
16
+ end
17
+ end
18
+ end
19
+ end
@@ -8,9 +8,9 @@ class Audio < Document
8
8
  process_in_background :file
9
9
 
10
10
  define_index do
11
- indexes title
11
+ indexes activity_object.title
12
12
  indexes file_file_name, :as => :file_name
13
- indexes description
13
+ indexes activity_object.description
14
14
  indexes activity_object.tags.name, :as => :tags
15
15
 
16
16
  has created_at
@@ -15,9 +15,9 @@ class Document < ActiveRecord::Base
15
15
  end
16
16
 
17
17
  define_index do
18
- indexes title
18
+ indexes activity_object.title
19
19
  indexes file_file_name, :as => :file_name
20
- indexes description
20
+ indexes activity_object.description
21
21
  indexes activity_object.tags.name, :as => :tags
22
22
 
23
23
  where "type IS NULL"
@@ -8,9 +8,9 @@ class Picture < Document
8
8
  }
9
9
 
10
10
  define_index do
11
- indexes title
11
+ indexes activity_object.title
12
12
  indexes file_file_name, :as => :file_name
13
- indexes description
13
+ indexes activity_object.description
14
14
  indexes activity_object.tags.name, :as => :tags
15
15
 
16
16
  has created_at
@@ -13,9 +13,9 @@ class Video < Document
13
13
  process_in_background :file
14
14
 
15
15
  define_index do
16
- indexes title
16
+ indexes activity_object.title
17
17
  indexes file_file_name, :as => :file_name
18
- indexes description
18
+ indexes activity_object.description
19
19
  indexes activity_object.tags.name, :as => :tags
20
20
 
21
21
  has created_at
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Documents
3
- VERSION = "0.11.0".freeze
3
+ VERSION = "0.11.1".freeze
4
4
  end
5
5
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.files = `git ls-files`.split("\n")
13
13
 
14
14
  # Gem dependencies
15
- s.add_runtime_dependency('social_stream-base', '~> 0.16.0')
15
+ s.add_runtime_dependency('social_stream-base', '~> 0.16.2')
16
16
  s.add_runtime_dependency('paperclip-ffmpeg', '~> 0.7.0')
17
17
  s.add_runtime_dependency('paperclip','= 2.4.5')
18
18
  s.add_runtime_dependency('delayed_paperclip','2.4.5.1')
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Events
3
- VERSION = "0.8.0".freeze
3
+ VERSION = "0.8.1".freeze
4
4
  end
5
5
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.files = `git ls-files`.split("\n")
13
13
 
14
14
  # Gem dependencies
15
- s.add_runtime_dependency('social_stream-base', '~> 0.16.0')
15
+ s.add_runtime_dependency('social_stream-base', '~> 0.16.2')
16
16
  s.add_runtime_dependency('rails-scheduler', '~> 0.0.6')
17
17
  s.add_runtime_dependency('coffee-rails', '>= 3.1.0')
18
18
 
@@ -1,3 +1,3 @@
1
1
  module SocialStream
2
- VERSION = "0.21.3".freeze
2
+ VERSION = "0.21.4".freeze
3
3
  end
@@ -8,8 +8,8 @@ class Link < ActiveRecord::Base
8
8
  before_create :check_loaded
9
9
 
10
10
  define_index do
11
- indexes title
12
- indexes description
11
+ indexes activity_object.title
12
+ indexes activity_object.description
13
13
  indexes url
14
14
 
15
15
  has created_at
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Linkser
3
- VERSION = "0.6.0".freeze
3
+ VERSION = "0.6.1".freeze
4
4
  end
5
5
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.files = `git ls-files`.split("\n")
13
13
 
14
14
  # Gem dependencies
15
- s.add_runtime_dependency('social_stream-base', '~> 0.16.0')
15
+ s.add_runtime_dependency('social_stream-base', '~> 0.16.2')
16
16
  s.add_runtime_dependency('linkser', '~> 0.0.10')
17
17
  # Development Gem dependencies
18
18
  s.add_development_dependency('sqlite3-ruby')
@@ -1,5 +1,4 @@
1
1
  var global;
2
-
3
2
  ////////////////////
4
3
  //Reconnect button interface functions
5
4
  ////////////////////
@@ -27,49 +26,25 @@ function requestConnectToChat(){
27
26
  }
28
27
  }
29
28
 
29
+ function changeChatHeaderTitle(msg){
30
+ if(mainChatBox==null){
31
+ $("#chat_header_title").html(msg)
32
+ } else {
33
+ changeMainChatBoxHeaderTitle(msg);
34
+ }
35
+ }
36
+
30
37
 
31
38
  ////////////////////
32
- //Chat interface: Connection boxes
39
+ //Chat interface: Setting Functions
33
40
  ////////////////////
34
41
 
35
42
  var focusSearchContactsFlag=false;
43
+ var changeSelectContactValueFlag = false;
36
44
 
37
- function setUserFunctions(){
38
-
39
- settingTooltips();
40
-
41
- ///////////////////////
42
- //Open chatbox function
43
- ///////////////////////
44
- $("div.user_presence").click(function(event, ui){
45
- var guest_name = $(this).attr("name");
46
- var guest_slug = $(this).attr("slug");
47
- var guest_jid = guest_slug + "@" + domain;
48
-
49
- if (createChatBox(guest_slug, guest_name, guest_jid, user_name, user_jid)) {
50
- } else {
51
- window[getChatVariableFromSlug(guest_slug)].chatbox("option", "boxManager").toggleBox(true);
52
- };
53
- });
54
-
55
-
56
- //Hide tooltips on mouseleave
57
- $("div.user_presence").mouseleave(function(e){
58
- var div = $(this);
59
- $.each($(".tooltip:visible"), function(index, value) {
60
- if ( $($(".tooltip:visible")[0]).html() == $(div).attr("name") ){
61
- $($(".tooltip:visible")[index]).hide();
62
- }
63
- });
64
- });
65
-
66
-
67
- ////////////////////
68
- //Chat interface: Status selector
69
- ////////////////////
70
45
 
71
- //JQuery DropdwanStatus
72
-
46
+ function settingStatusSelector(){
47
+ //JQuery DropdwanStatus
73
48
  $(".dropdown dt a").click(function(event) {
74
49
  event.preventDefault();
75
50
  $(".dropdown dd ul").toggle();
@@ -81,7 +56,6 @@ function setUserFunctions(){
81
56
  }
82
57
 
83
58
  restartAwayTimer();
84
-
85
59
  });
86
60
 
87
61
  $(".dropdown dd ul li a.option").click(function(event) {
@@ -98,64 +72,41 @@ function setUserFunctions(){
98
72
 
99
73
  $(document).bind('click', function(e) {
100
74
  var $clicked = $(e.target);
101
-
75
+
102
76
  if (! $clicked.parents().hasClass("dropdown")){
103
77
  //Click outside the select...
104
78
  $(".dropdown dd ul").hide();
105
79
  setStatusWidgetTitle(userStatus);
106
80
  }
107
81
  });
108
-
109
- ///////////////
110
- //Search contacts enabling
111
- ///////////////
112
- $("select.flexselect").flexselect({
113
- allowMismatch: true,
114
- defaultmessage: I18n.t('chat.zerocontacts')
115
- });
116
-
117
- $("#search_chat_contact_flexselect").Watermark(I18n.t('chat.search'),"#666");
118
-
119
- //Select contact function
120
- //callback in changeSelectContactValue()
121
-
122
-
123
- $("#search_chat_contact_flexselect").focus(function(e) {
124
- changeContactListVisibility(true);
125
- });
126
-
127
- $("#search_chat_contact_flexselect").blur(function(e) {
128
- changeContactListVisibility(false);
129
- });
130
-
131
82
  }
132
83
 
133
84
 
134
- function changeSelectContactValue(name,value){
135
-
136
- $("#search_chat_contact_flexselect").blur();
137
-
138
- if(value == "ZERO_CONTACTS"){
139
- return;
140
- }
85
+ function settingChatBoxFunctions(){
141
86
 
142
- var guest_slug = value;
143
- var guest_name = name;
144
- var guest_jid = guest_slug + "@" + domain;
145
- if (createChatBox(guest_slug, guest_name, guest_jid, user_name, user_jid)) {
146
- } else {
147
- window[getChatVariableFromSlug(guest_slug)].chatbox("option", "boxManager").toggleBox(true);
148
- };
149
-
150
- //Check for online status and show notification
151
- if (getAllConnectedSlugs().indexOf(guest_slug)==-1) {
152
- showOfflineChatNotificationForSlug(guest_slug);
153
- }
87
+ $("div.user_presence").click(function(event, ui){
88
+ var guest_name = $(this).attr("name");
89
+ var guest_slug = $(this).attr("slug");
90
+ var guest_jid = guest_slug + "@" + domain;
91
+
92
+ if (createChatBox(guest_slug, guest_name, guest_jid, user_name, user_jid)) {
93
+ } else {
94
+ window[getChatVariableFromSlug(guest_slug)].chatbox("option", "boxManager").toggleBox(true);
95
+ };
96
+ });
154
97
 
155
- changeContactListVisibility(false);
98
+ //Hide tooltips on mouseleave
99
+ $("div.user_presence").mouseleave(function(e){
100
+ var div = $(this);
101
+ $.each($(".tooltip:visible"), function(index, value) {
102
+ if ( $($(".tooltip:visible")[0]).html() == $(div).attr("name") ){
103
+ $($(".tooltip:visible")[index]).hide();
104
+ }
105
+ });
106
+ });
107
+
156
108
  }
157
109
 
158
-
159
110
  function settingTooltips(){
160
111
  if (mainChatBox == null) {
161
112
  //Enabling default tooltips
@@ -177,14 +128,65 @@ function settingTooltips(){
177
128
  opacity: 0.95,
178
129
  relative: false,
179
130
  position: 'top left',
180
- offset: [0,37]
131
+ offset: [0,31]
181
132
  });
182
133
  }
183
134
  }
184
135
 
136
+ function settingSearchContactFunctions(){
137
+
138
+ $("#chat_partial select.flexselect").flexselect({
139
+ allowMismatch: true,
140
+ defaultmessage: I18n.t('chat.zerocontacts')
141
+ });
142
+
143
+ $("#chat_partial #search_chat_contact_flexselect").Watermark(I18n.t('chat.search'),"#666");
144
+
145
+ //Select contact function
146
+ //callback in changeSelectContactValue()
147
+
148
+
149
+ $("#chat_partial #search_chat_contact_flexselect").focus(function(e) {
150
+ changeContactListVisibility(true);
151
+ });
152
+
153
+ $("#chat_partial #search_chat_contact_flexselect").blur(function(e) {
154
+ changeContactListVisibility(false);
155
+ });
156
+ }
157
+
158
+ function setAllUserFunctions(){
159
+ settingStatusSelector();
160
+ settingChatBoxFunctions();
161
+ settingTooltips();
162
+ }
163
+
164
+
165
+ function changeSelectContactValue(name,valueSelectedInSearchContacts){
166
+
167
+ if((valueSelectedInSearchContacts != "ZERO_CONTACTS")&&(valueSelectedInSearchContacts != "")){
168
+ var guest_slug = valueSelectedInSearchContacts;
169
+ var guest_name = getNameFromSlug(guest_slug);
170
+ var guest_jid = guest_slug + "@" + domain;
171
+
172
+ if (createChatBox(guest_slug, guest_name, guest_jid, user_name, user_jid)) {
173
+ } else {
174
+ window[getChatVariableFromSlug(guest_slug)].chatbox("option", "boxManager").toggleBox(true);
175
+ };
176
+
177
+ //Check for online status and show notification
178
+ if (! isSlugChatConnected(guest_slug)) {
179
+ showOfflineChatNotificationForSlug(guest_slug);
180
+ }
181
+ }
182
+
183
+ $("#chat_partial #search_chat_contact_flexselect").blur();
184
+ changeContactListVisibility(false);
185
+ }
186
+
185
187
 
186
188
  function changeContactListVisibility(visible){
187
- var nItems = $("#search_chat_contact_flexselect_dropdown ul li").length-1;
189
+ var nItems = getAllSlugsLength();
188
190
  if (visible){
189
191
  focusSearchContactsFlag=true;
190
192
  if(nItems > 9){
@@ -207,7 +209,6 @@ function setStatusWidgetTitle(status){
207
209
  status = sstreamChatStatus[status];
208
210
  }
209
211
 
210
-
211
212
  if ($(".dropdown dt a span").length == 0){
212
213
  return;
213
214
  }
@@ -286,17 +287,27 @@ function refreshChatWindow(){
286
287
  }
287
288
 
288
289
 
289
- function updateChatWindow(){
290
- timerCounter=0;
291
- log("updateChatWindow()");
292
- var stropheConnectedAndOnlineStatus = ((isStropheConnected()) && (userStatus!="offline") && (!disconnectionFlag));
293
- $.post("/chatWindow", { userConnected: stropheConnectedAndOnlineStatus }, function(data){
294
- $(".tooltip").hide() //Prevent tooltips
295
- $("#chat_partial").html(modifyChatPartialIfMainBox(data));
290
+ function updateChatWindow(){
291
+ var stropheConnectedAndOnlineStatus = ((isStropheConnected()) && (userStatus!="offline") && (!disconnectionFlag));
292
+ timerCounter=0;
293
+
294
+ log("updateChatWindow()");
295
+ log("Connected " + stropheConnectedAndOnlineStatus);
296
+
297
+ if(! stropheConnectedAndOnlineStatus){
298
+ loadDisconnectionDiv();
299
+ updateConnectedUsersOfMainChatBox();
300
+ return;
301
+ }
302
+
303
+ $.post("/chatWindow", { }, function(data){
304
+ //Prevent tooltips
305
+ $(".tooltip").hide()
306
+ loadWidgetsDiv(data);
307
+ hideConnectionBoxesFromDisconnectedSlugs();
308
+ setAllUserFunctions();
296
309
  updateConnectedUsersOfMainChatBox();
297
310
  if (isStropheConnected()) {
298
- setStatusWidgetTitle(userStatus);
299
- setUserFunctions();
300
311
  if (afterNewConnectionFlag){
301
312
  afterNewConnectionFlag = false;
302
313
  if(afterFirstConnectionFlag){
@@ -310,55 +321,158 @@ function updateChatWindow(){
310
321
  });
311
322
  }
312
323
 
313
- function getConnectionBoxFromSlug(slug){
314
- if ($('div.user_presence[slug=' + slug + ']').length > 0){
315
- return ($('div.user_presence[slug=' + slug + ']'))[0];
316
- } else {
317
- return null;
318
- }
319
- }
320
324
 
321
- var cacheConnectedUsers = [];
325
+ //////////////
326
+ //Divs Load
327
+ //////////////
322
328
 
323
- function hideConnectionBoxFromSlug(slug){
324
- if ($('div.user_presence[slug=' + slug + ']').length > 0){
325
- $('div.user_presence[slug=' + slug + ']').hide();
326
- if(cacheConnectedUsers.indexOf(slug)==-1){
327
- cacheConnectedUsers.push(slug);
329
+ function loadConnectingDiv(){
330
+ $("#chat_partial").html($("#chat_connecting").html());
331
+ }
332
+
333
+ function loadDisconnectionDiv(){
334
+ $("#chat_partial").html(modifyChatPartialIfMainBox($("#chat_connection_off").html()));
335
+
336
+ $('.connectChatButton').bind('click', function () {
337
+ if (requestConnectToChat()){
338
+ if (authByCookie()) {
339
+ connectToChat(user_jid,cookie,null);
340
+ } else {
341
+ connectToChat(user_jid,null,$('#user_password').val());
342
+ }
328
343
  }
329
- updateMainChatBoxAfterUserDisconnect();
344
+ });
345
+
346
+ if (authByCookie()){
347
+ $("#chat_partial #passwordFormChat").hide();
348
+ } else {
349
+ //Authentication by password
330
350
 
331
- //Last user disconnected?
332
- if (getAllConnectedSlugs().length ==0){
333
- if($(".users_connected p.zero_users_connected").length > 0){
334
- $(".users_connected p.zero_users_connected").show();
335
- } else {
336
- var msg = I18n.t('chat.zerousers');
337
- $(".users_connected").append('<p class="zero_users_connected">' + msg + '</p>')
338
- }
351
+ $('.storePass').bind('click', function () {
352
+ storePassword();
353
+ });
354
+
355
+ if ((window.sessionStorage) && (sessionStorage.getItem("ss_user_pass") != null)) {
356
+ $("#chat_partial #passwordFormChat").hide()
357
+ } else {
358
+ $("#chat_partial #passwordFormChat").show();
339
359
  }
340
360
  }
341
361
  }
342
362
 
363
+
364
+ function loadWidgetsDiv(data){
365
+ $("#chat_partial").html(modifyChatPartialIfMainBox($("#chat_widgets").html()));
366
+ $("#chat_partial").append(data);
367
+ fillSearchContactSelect();
368
+ settingSearchContactFunctions();
369
+ }
370
+
371
+ function fillSearchContactSelect(){
372
+ $("#chat_partial #search_chat_contact").children().remove()
373
+ $("#chat_partial #search_chat_contact").append('<option value=""></option>')
374
+ $.each(getAllSlugs(), function(index, value) {
375
+ $("#chat_partial #search_chat_contact").append('<option value=' + value + '>' + getNameFromSlug(value) + '</option>')
376
+ });
377
+ }
378
+
379
+
380
+
381
+ /////////////////////
382
+ // Connection Box Management
383
+ /////////////////////
384
+
385
+ function hideConnectionBoxesFromDisconnectedSlugs(){
386
+ $('div.user_presence[slug][connected="false"]').hide();
387
+ }
388
+
389
+ function hideConnectionBoxFromSlug(slug){
390
+ $('div.user_presence[slug=' + slug + ']').attr("connected","false");
391
+ $('div.user_presence[slug=' + slug + ']').hide();
392
+ }
393
+
343
394
  function showConnectionBoxFromSlug(slug){
344
- if ($('div.user_presence[slug=' + slug + ']').length > 0){
345
- if (!($('div.user_presence[slug=' + slug + ']').is(":visible"))){
346
- $('div.user_presence[slug=' + slug + ']').show();
347
- $(".users_connected p.zero_users_connected").hide();
395
+ $('div.user_presence[slug=' + slug + ']').attr("connected","true");
396
+ $('div.user_presence[slug=' + slug + ']').show();
397
+ }
398
+
399
+ function updateInterfaceAfterPresenceStanza(slug,available){
400
+ if(available){
401
+ showConnectionBoxFromSlug(slug);
402
+ hideChatNotificationForSlug(slug);
403
+ } else {
404
+ hideConnectionBoxFromSlug(slug);
405
+ showOfflineChatNotificationForSlug(slug);
406
+ }
407
+ updateMainChatBoxAfterConnectionBoxChanges();
408
+ checkForZeroUsersConnected();
409
+ }
410
+
411
+ function checkForZeroUsersConnected(){
412
+ if (getConnectedSlugsLength() == 0){
413
+ if($(".users_connected p.zero_users_connected").length > 0){
414
+ $(".users_connected p.zero_users_connected").show();
415
+ } else {
416
+ var msg = I18n.t('chat.zerousers');
417
+ $(".users_connected").append('<p class="zero_users_connected">' + msg + '</p>')
348
418
  }
349
- }
419
+ } else {
420
+ $(".users_connected p.zero_users_connected").hide();
421
+ }
350
422
  }
351
423
 
424
+
425
+ ////////////////////
426
+ // Set Status Interface
427
+ ////////////////////
428
+
352
429
  function setUserIconStatus(slug, status){
353
430
  if (status in statusIcons) {
354
431
  var iconName = statusIcons[status];
355
432
  var $img_status = $('img.presence_status');
356
433
  var path = '<%=image_path("status")%>';
357
- connectionBox = getConnectionBoxFromSlug(slug);
434
+ var connectionBox = getConnectionBoxFromSlug(slug);
358
435
  $(connectionBox).find($img_status).attr("src", path + "/" + iconName + ".png")
359
436
  }
360
437
  }
361
438
 
439
+
440
+ //////////////////////
441
+ //Getters and Setters
442
+ //////////////////////
443
+
444
+ function getConnectionBoxFromSlug(slug){
445
+ if ($('div.user_presence[slug=' + slug + ']').length > 0){
446
+ return ($('div.user_presence[slug=' + slug + ']'))[0];
447
+ } else {
448
+ return null;
449
+ }
450
+ }
451
+
452
+ function isSlugChatConnected(slug){
453
+ return $('div.user_presence[slug=' + slug + ']').attr("connected")=="true";
454
+ }
455
+
456
+ function existsSlugChatBox(slug){
457
+ return getConnectionBoxFromSlug(slug)!=null;
458
+ }
459
+
460
+ function getConnectedSlugsLength(){
461
+ return $('div.user_presence[slug][connected="true"]').length;
462
+ }
463
+
464
+ function getAllSlugsLength(){
465
+ return $('div.user_presence[slug]').length;
466
+ }
467
+
468
+ function getDisconnectedSlugsLength(){
469
+ return $('div.user_presence[slug][connected="false"]').length;
470
+ }
471
+
472
+ function getAllSlugs(){
473
+ return getAllSlugsByChatConnectedState()[2];
474
+ }
475
+
362
476
  function getAllConnectedSlugs(){
363
477
  return getAllSlugsByChatConnectedState()[0];
364
478
  }
@@ -371,9 +485,9 @@ function getAllSlugsByChatConnectedState(){
371
485
  var onlineSlugs=[];
372
486
  var offlineSlugs=[];
373
487
  var allSlugs=[];
374
- connectionBoxes = $('div.user_presence[slug]');
488
+ var connectionBoxes = $('div.user_presence[slug]');
375
489
  $.each(connectionBoxes, function(index, value) {
376
- if($(value).css("display")!="none"){
490
+ if($(value).attr("connected")=="true"){
377
491
  onlineSlugs.push($(value).attr("slug"))
378
492
  } else {
379
493
  offlineSlugs.push($(value).attr("slug"))
@@ -383,6 +497,8 @@ function getAllSlugsByChatConnectedState(){
383
497
  return [onlineSlugs,offlineSlugs,allSlugs]
384
498
  }
385
499
 
500
+
501
+
386
502
  ////////////////////
387
503
  //Insert received message in chatbox
388
504
  ////////////////////
@@ -394,17 +510,20 @@ function putReceivedMessageOnChatWindow(from_jid,from_slug,body,msgID){
394
510
  return;
395
511
  }
396
512
 
397
- //Check for from_slug name and connectionBox visibility
398
- if (typeof($('div.user_presence[slug=' + from_slug + ']').attr('name')) == 'undefined') {
513
+ //Check slug connection and slugs connectionBox
514
+ if (existsSlugChatBox(from_slug)) {
399
515
  //No connectionBox for this user!
400
- var from_name = from_slug;
401
- refreshChatWindow();
516
+ var from_name = getNameFromSlug(from_slug);
517
+ if(! isAdminSlug(from_slug)){
518
+ refreshChatWindow();
519
+ }
402
520
  } else {
403
- showConnectionBoxFromSlug(from_slug);
521
+ if(! isSlugChatConnected(from_slug)){
522
+ updateInterfaceAfterPresenceStanza(from_slug,"true");
523
+ }
404
524
  var from_name = $('div.user_presence[slug=' + from_slug + ']').attr('name');
405
525
  }
406
526
 
407
-
408
527
  //Create or toggle from_slug's chatBox.
409
528
  if (createChatBox(from_slug, from_name, from_jid, user_name, user_jid)) {
410
529
  } else {
@@ -436,15 +555,16 @@ function putReceivedMessageOnChatWindow(from_jid,from_slug,body,msgID){
436
555
  //Notifications on chat Window
437
556
  ////////////////////
438
557
 
439
- function showChatNotification(notification,msg){
440
- notification.html("<p class==\"ui-chatbox-notify-text\">" + msg + "</p>");
441
- notification.css("visibility","visible");
558
+ function showChatNotification(notification,type,msg){
559
+ notification.html("<p notification_type=\"" + type + "\" class=\"ui-chatbox-notify-text\">" + msg + "</p>");
560
+ notification.css("display","block");
561
+ notification.css("visibility","visible");
442
562
  notification.fadeIn();
443
563
  }
444
564
 
445
- function showChatNotificationForSlug(slug,msg){
565
+ function showChatNotificationForSlug(slug,type,msg){
446
566
  var notification = $("#" + slug).parent().find("div.ui-chatbox-notify");
447
- showChatNotification(notification,msg);
567
+ showChatNotification(notification,type,msg);
448
568
  }
449
569
 
450
570
  function showOfflineChatNotificationForSlug(slug){
@@ -452,13 +572,14 @@ function showOfflineChatNotificationForSlug(slug){
452
572
  if(slug_chat_box!=null){
453
573
  var name = slug_chat_box.attr("name")
454
574
  var msg = name + ' ' + I18n.t('chat.notify.guestOffline');
455
- showChatNotificationForSlug(slug,msg);
575
+ showChatNotificationForSlug(slug,"guestOffline",msg);
456
576
  }
457
577
  }
458
578
 
459
579
  function hideChatNotification(notification){
460
580
  notification.fadeOut();
461
- notification.css("visibility","hidden");
581
+ notification.css("display","none");
582
+ notification.css("visibility","hidden");
462
583
  }
463
584
 
464
585
  function hideChatNotificationForSlug(slug){
@@ -469,7 +590,7 @@ function hideChatNotificationForSlug(slug){
469
590
  function notifyWhenUsersDisconnect(){
470
591
  var notification = $("div.ui-chatbox-notify");
471
592
  var msg = I18n.t('chat.notify.offline');
472
- showChatNotification(notification,msg);
593
+ showChatNotification(notification,"userOffline",msg);
473
594
  }
474
595
 
475
596
  function hideAllNotifications(){
@@ -496,8 +617,9 @@ function updateAllNotifications(){
496
617
 
497
618
  function updateConnectedUsersOfMainChatBox(){
498
619
  if(mainChatBox!=null){
499
- if(isStropheConnected()){
500
- var connectedUsers = getAllConnectedSlugs().length;
620
+ var stropheConnectedAndOnlineStatus = ((isStropheConnected()) && (userStatus!="offline") && (!disconnectionFlag));
621
+ if(stropheConnectedAndOnlineStatus){
622
+ var connectedUsers = getConnectedSlugsLength();
501
623
  changeMainChatBoxHeaderTitle( I18n.t('chat.title') + " (" + connectedUsers + ")");
502
624
  changeMainChatBoxHeight(getChatBoxHeightRequiredForConnectionBoxes());
503
625
  } else {
@@ -510,8 +632,7 @@ function updateConnectedUsersOfMainChatBox(){
510
632
  }
511
633
  }
512
634
 
513
-
514
- function updateMainChatBoxAfterUserDisconnect(){
635
+ function updateMainChatBoxAfterConnectionBoxChanges(){
515
636
  changeMainChatBoxHeight(getChatBoxHeightRequiredForConnectionBoxes());
516
637
  updateConnectedUsersOfMainChatBox();
517
638
  }