diff --git a/addons/im/static/src/js/im.js b/addons/im/static/src/js/im.js index f0f1771537b..8e21167cc9a 100644 --- a/addons/im/static/src/js/im.js +++ b/addons/im/static/src/js/im.js @@ -13,9 +13,6 @@ openerp.im = function(instance) { im_common.notification = function(message) { instance.client.do_warn(message); }; - im_common.to_url = function(file) { - return "/" + file; - }; im_common.connection = openerp.session; var im = new instance.im.InstantMessaging(self); diff --git a/addons/im/static/src/js/im_common.js b/addons/im/static/src/js/im_common.js index d89474f32f5..72097c35f79 100644 --- a/addons/im/static/src/js/im_common.js +++ b/addons/im/static/src/js/im_common.js @@ -19,9 +19,6 @@ function declare($, _, openerp) { All of this must be defined to use this module */ _.extend(im_common, { - to_url: function(file) { - throw new Error("Not implemented"); - }, notification: function(message) { throw new Error("Not implemented"); }, @@ -37,7 +34,7 @@ function declare($, _, openerp) { im_common.ImUser = openerp.Class.extend(openerp.PropertiesMixin, { init: function(parent, user_rec) { openerp.PropertiesMixin.init.call(this, parent); - user_rec.image_url = im_common.to_url("im/static/src/img/avatar/avatar.jpeg"); + user_rec.image_url = im_common.connection.url("/im/static/src/img/avatar/avatar.jpeg"); // TODO : check it works correctly if (user_rec.user) @@ -215,8 +212,8 @@ function declare($, _, openerp) { return; } var kitten = jQuery.deparam !== undefined && jQuery.deparam(jQuery.param.querystring()).kitten !== undefined; - this.ting = new Audio(im_common.to_url( - "im/static/src/audio/" + + this.ting = new Audio(im_common.connection.url( + "/im/static/src/audio/" + (kitten ? "purr" : "Ting") + (new Audio().canPlayType("audio/ogg; codecs=vorbis") ? ".ogg": ".mp3") )); @@ -293,7 +290,7 @@ function declare($, _, openerp) { this.inputPlaceholder = this.options.defaultInputPlaceholder; }, start: function() { - this.$().append(openerp.qweb.render("im_common.conversation", {widget: this, to_url: im_common.to_url})); + this.$().append(openerp.qweb.render("im_common.conversation", {widget: this, to_url: _.bind(im_common.connection.url, im_common.connection)})); var change_status = function() { this.$().toggleClass("oe_im_chatview_disconnected_status", this.user.get("im_status") === false); this.$(".oe_im_chatview_online").toggle(this.user.get("im_status") === true); diff --git a/addons/im/static/src/xml/im_common.xml b/addons/im/static/src/xml/im_common.xml index 0ef8040d8c5..4286d0c9710 100644 --- a/addons/im/static/src/xml/im_common.xml +++ b/addons/im/static/src/xml/im_common.xml @@ -3,7 +3,7 @@
- + diff --git a/addons/im_livechat/static/ext/static/js/livesupport.js b/addons/im_livechat/static/ext/static/js/livesupport.js index 88ada2b6b20..f61859200e3 100644 --- a/addons/im_livechat/static/ext/static/js/livesupport.js +++ b/addons/im_livechat/static/ext/static/js/livesupport.js @@ -24,17 +24,13 @@ define(["openerp", "im_common", "underscore", "require", "jquery", }); im_common.notification = notification; - //im_common.to_url = require.toUrl; console.log("starting live support customer app"); im_common.connection = new openerp.Session(null, server_url, { override_session: true }); return im_common.connection.session_authenticate(db, login, password).then(function() { - im_common.to_url = function(file) { - return im_common.connection.url("/" + file); - }; var defs = []; - defs.push(add_css("im/static/src/css/im_common.css")); - defs.push(add_css("im_livechat/static/ext/static/lib/jquery-achtung/src/ui.achtung.css")); + defs.push(add_css("/im/static/src/css/im_common.css")); + defs.push(add_css("/im_livechat/static/ext/static/lib/jquery-achtung/src/ui.achtung.css")); defs.push(im_common.connection.rpc('/web/proxy/load', {path: '/im_livechat/static/ext/static/js/livechat.xml'}).then(function(xml) { openerp.qweb.add_template(xml); })); @@ -56,7 +52,7 @@ define(["openerp", "im_common", "underscore", "require", "jquery", var add_css = function(relative_file_name) { var css_def = $.Deferred(); - $('') + $('') .appendTo($("head")).ready(function() { css_def.resolve(); });