Commit 2d30ae0d1d5514749e0af715f0ac7c7bb3914029
Committed by
Antonio Terceiro
1 parent
7e35c147
Exists in
master
and in
29 other branches
Enhancements of chat
Added sound when user receives message on chat Fixed width on css of chat (ActionItem1679)
Showing
4 changed files
with
83 additions
and
2 deletions
Show diff stats
app/views/layouts/chat.rhtml
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | 5 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> |
6 | <meta name="description" content="<%= @environment.name %>" /> | 6 | <meta name="description" content="<%= @environment.name %>" /> |
7 | <link rel="shortcut icon" href="<%= image_path(theme_favicon) %>" type="image/x-icon" /> | 7 | <link rel="shortcut icon" href="<%= image_path(theme_favicon) %>" type="image/x-icon" /> |
8 | - <%= javascript_include_tag 'jquery-latest', 'jquery.noconflict', 'jquery-ui-1.8.2.custom.min', 'jquery.scrollTo', 'jquery.scrollabletab', 'strophejs-1.0.1/strophe', 'jquery.emoticon', '/designs/icons/pidgin/emoticons.js', 'ba-linkify', 'application', 'chat', :cache => 'cache-chat' %> | 8 | + <%= javascript_include_tag 'jquery-latest', 'jquery.noconflict', 'jquery-ui-1.8.2.custom.min', 'jquery.scrollTo', 'jquery.scrollabletab', 'strophejs-1.0.1/strophe', 'jquery.emoticon', '/designs/icons/pidgin/emoticons.js', 'ba-linkify', 'application', 'chat', 'jquery.sound', :cache => 'cache-chat' %> |
9 | <%= stylesheet_link_tag noosfero_stylesheets, :cache => 'cache' %> | 9 | <%= stylesheet_link_tag noosfero_stylesheets, :cache => 'cache' %> |
10 | <%= stylesheet_link_tag icon_theme_stylesheet_path %> | 10 | <%= stylesheet_link_tag icon_theme_stylesheet_path %> |
11 | <%= stylesheet_link_tag theme_stylesheet_path %> | 11 | <%= stylesheet_link_tag theme_stylesheet_path %> |
public/javascripts/chat.js
@@ -232,6 +232,7 @@ jQuery(function($) { | @@ -232,6 +232,7 @@ jQuery(function($) { | ||
232 | var name = $('#' + jid_id).data('name'); | 232 | var name = $('#' + jid_id).data('name'); |
233 | create_conversation_tab(name, jid_id); | 233 | create_conversation_tab(name, jid_id); |
234 | Jabber.show_message(jid, body, 'other'); | 234 | Jabber.show_message(jid, body, 'other'); |
235 | + $.sound.play('/sounds/receive.wav'); | ||
235 | return true; | 236 | return true; |
236 | }, | 237 | }, |
237 | 238 | ||
@@ -384,7 +385,7 @@ jQuery(function($) { | @@ -384,7 +385,7 @@ jQuery(function($) { | ||
384 | $('#chat-window #tabs').removeClass("ui-corner-all ui-widget-content"); | 385 | $('#chat-window #tabs').removeClass("ui-corner-all ui-widget-content"); |
385 | 386 | ||
386 | // positionting scrollabletab wrapper at bottom and tabs next/prev buttons | 387 | // positionting scrollabletab wrapper at bottom and tabs next/prev buttons |
387 | - $('#stTabswrapper,#tabs').css('position', 'absolute').css('top', 0).css('bottom', 0).css('left', 0).css('right', 0); | 388 | + $('#stTabswrapper,#tabs').css({'position':'absolute', 'top':0, 'bottom':0, 'left': 0, 'right': 0, 'width': 'auto'}); |
388 | $('.stNavWrapper').css('position', 'absolute').css('bottom', 0).css('left', 0).css('right', 0) | 389 | $('.stNavWrapper').css('position', 'absolute').css('bottom', 0).css('left', 0).css('right', 0) |
389 | .find('.stNav').css('top', null).css('bottom', '12px').css('height', '22px') | 390 | .find('.stNav').css('top', null).css('bottom', '12px').css('height', '22px') |
390 | .find('.ui-icon').css('margin-top', '2px'); | 391 | .find('.ui-icon').css('margin-top', '2px'); |
@@ -0,0 +1,80 @@ | @@ -0,0 +1,80 @@ | ||
1 | +/** | ||
2 | + * jQuery sound plugin (no flash) | ||
3 | + * | ||
4 | + * port of script.aculo.us' sound.js (http://script.aculo.us), based on code by Jules Gravinese (http://www.webveteran.com/) | ||
5 | + * | ||
6 | + * Copyright (c) 2007 Jörn Zaefferer (http://bassistance.de) | ||
7 | + * | ||
8 | + * Licensed under the MIT license: | ||
9 | + * http://www.opensource.org/licenses/mit-license.php | ||
10 | + * | ||
11 | + * $Id$ | ||
12 | + */ | ||
13 | + | ||
14 | +/** | ||
15 | + * API Documentation | ||
16 | + * | ||
17 | + * // play a sound from the url | ||
18 | + * $.sound.play(url) | ||
19 | + * | ||
20 | + * // play a sound from the url, on a track, stopping any sound already running on that track | ||
21 | + * $.sound.play(url, { | ||
22 | + * track: "track1" | ||
23 | + * }); | ||
24 | + * | ||
25 | + * // increase the timeout to four seconds before removing the sound object from the dom for longer sounds | ||
26 | + * $.sound.play(url, { | ||
27 | + * timeout: 4000 | ||
28 | + * }); | ||
29 | + * | ||
30 | + * // disable playing sounds | ||
31 | + * $.sound.enabled = false; | ||
32 | + * | ||
33 | + * // enable playing sounds | ||
34 | + * $.sound.enabled = true | ||
35 | + */ | ||
36 | + | ||
37 | +(function($) { | ||
38 | + | ||
39 | +$.sound = { | ||
40 | + tracks: {}, | ||
41 | + enabled: true, | ||
42 | + template: function(src) { | ||
43 | + return '<embed style="height:0" loop="false" src="' + src + '" autostart="true" hidden="true"/>'; | ||
44 | + }, | ||
45 | + play: function(url, options){ | ||
46 | + if (!this.enabled) | ||
47 | + return; | ||
48 | + var settings = $.extend({ | ||
49 | + url: url, | ||
50 | + timeout: 2000 | ||
51 | + }, options); | ||
52 | + | ||
53 | + if (settings.track) { | ||
54 | + if (this.tracks[settings.track]) { | ||
55 | + var current = this.tracks[settings.track]; | ||
56 | + current.Stop && current.Stop(); | ||
57 | + current.remove(); | ||
58 | + } | ||
59 | + } | ||
60 | + | ||
61 | + var element = $.browser.msie | ||
62 | + ? $('<bgsound/>').attr({ | ||
63 | + src: settings.url, | ||
64 | + loop: 1, | ||
65 | + autostart: true | ||
66 | + }) | ||
67 | + : $(this.template(settings.url)); | ||
68 | + element.appendTo("body"); | ||
69 | + | ||
70 | + if (settings.track) { | ||
71 | + this.tracks[settings.track] = element; | ||
72 | + } | ||
73 | + | ||
74 | + setTimeout(function() { | ||
75 | + element.remove(); | ||
76 | + }, 2000) | ||
77 | + } | ||
78 | +}; | ||
79 | + | ||
80 | +})(jQuery); |
No preview for this file type