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);
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");
},
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)
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")
));
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);
<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>
});
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);
}));
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();
});