Play the "tink" only when the window is not active
bzr revid: nicolas.vanhoren@openerp.com-20130111135817-d6orh4d4t851nra1
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -43,10 +43,6 @@
|
||||
<div class="oe_im_chatview_footer">
|
||||
<input class="oe_im_chatview_input" t-att-placeholder="_t('Say something...')" />
|
||||
</div>
|
||||
<audio>
|
||||
<source t-att-src="_s + '/web_im/static/src/audio/Ting.ogg'" />
|
||||
<source t-att-src="_s + '/web_im/static/src/audio/Ting.mp3'" />
|
||||
</audio>
|
||||
</div>
|
||||
</t>
|
||||
<t t-name="Conversation.bubble">
|
||||
@@ -63,4 +59,10 @@
|
||||
<div class="oe_im_chatview_time"><t t-esc="time"/></div>
|
||||
</div>
|
||||
</t>
|
||||
<t t-name="Conversation.ting">
|
||||
<audio>
|
||||
<source t-att-src="_s + '/web_im/static/src/audio/Ting.ogg'" />
|
||||
<source t-att-src="_s + '/web_im/static/src/audio/Ting.mp3'" />
|
||||
</audio>
|
||||
</t>
|
||||
</templates>
|
||||
Reference in New Issue
Block a user