From 90164bfc1a519cf34dec7aeb6744ca7df83cd145 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 11 Jan 2013 14:58:17 +0100 Subject: [PATCH] Play the "tink" only when the window is not active bzr revid: nicolas.vanhoren@openerp.com-20130111135817-d6orh4d4t851nra1 --- addons/web_im/static/src/js/im.js | 5 ++++- addons/web_im/static/src/xml/im.xml | 10 ++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/addons/web_im/static/src/js/im.js b/addons/web_im/static/src/js/im.js index b4f1415b1dd..c8bf0c21ff8 100644 --- a/addons/web_im/static/src/js/im.js +++ b/addons/web_im/static/src/js/im.js @@ -271,6 +271,8 @@ openerp.web_im = function(instance) { this.window_focus_change(); this.on("change:waiting_messages", this, this.messages_change); this.messages_change(); + this.$ting = $(QWeb.render("Conversation.ting")); + this.$ting.appendTo($("body")); }, window_focus_change: function() { if (this.get("window_focus")) { @@ -305,6 +307,7 @@ openerp.web_im = function(instance) { received_message: function(message, user) { if (! this.get("window_focus")) { this.set("waiting_messages", this.get("waiting_messages") + 1); + this.$ting[0].play(); } var conv = this.activate_user(user); conv.received_message(message); @@ -317,6 +320,7 @@ openerp.web_im = function(instance) { }, this); }, destroy: function() { + this.$ting.remove(); $(window).unbind("blur", this.blur_hdl); $(window).unbind("focus", this.focus_hdl); this._super(); @@ -368,7 +372,6 @@ openerp.web_im = function(instance) { }, received_message: function(message) { this._add_bubble(this.user, message.message, message.date); - this.$("audio")[0].play(); }, send_message: function(e) { if(e && e.which !== 13) { diff --git a/addons/web_im/static/src/xml/im.xml b/addons/web_im/static/src/xml/im.xml index 584eaadd8e2..2031d514365 100644 --- a/addons/web_im/static/src/xml/im.xml +++ b/addons/web_im/static/src/xml/im.xml @@ -43,10 +43,6 @@ - @@ -63,4 +59,10 @@
+ + + \ No newline at end of file