Removed to_url
authorniv-openerp <nicolas.vanhoren@openerp.com>
Tue, 20 Aug 2013 14:48:43 +0000 (16:48 +0200)
committerniv-openerp <nicolas.vanhoren@openerp.com>
Tue, 20 Aug 2013 14:48:43 +0000 (16:48 +0200)
bzr revid: nicolas.vanhoren@openerp.com-20130820144843-yeny7kpv1qcqijl9

addons/im/static/src/js/im.js
addons/im/static/src/js/im_common.js
addons/im/static/src/xml/im_common.xml
addons/im_livechat/static/ext/static/js/livesupport.js

index f0f1771..8e21167 100644 (file)
@@ -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);
index d89474f..72097c3 100644 (file)
@@ -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);
index 0ef8040..4286d0c 100644 (file)
@@ -3,7 +3,7 @@
 <templates>
 <t t-name="im_common.conversation">
     <div class="oe_im_chatview_header">
-        <img t-att-src="to_url('im/static/src/img/green.png')" class="oe_im_chatview_online"/>
+        <img t-att-src="to_url('/im/static/src/img/green.png')" class="oe_im_chatview_online"/>
         <t t-esc="widget.user.get('name')"/>
         <scan class="oe_im_chatview_nbr_messages" />
         <button class="oe_im_chatview_close">×</button>
index 88ada2b..f618592 100644 (file)
@@ -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();
-        $('<link rel="stylesheet" href="' + im_common.to_url(relative_file_name) + '"></link>')
+        $('<link rel="stylesheet" href="' + im_common.connection.url(relative_file_name) + '"></link>')
                 .appendTo($("head")).ready(function() {
             css_def.resolve();
         });