Some cleaning
authorniv-openerp <nicolas.vanhoren@openerp.com>
Tue, 20 Aug 2013 12:15:22 +0000 (14:15 +0200)
committerniv-openerp <nicolas.vanhoren@openerp.com>
Tue, 20 Aug 2013 12:15:22 +0000 (14:15 +0200)
bzr revid: nicolas.vanhoren@openerp.com-20130820121522-en3bft0wotfnsozm

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 e9226e4..2768627 100644 (file)
@@ -25,8 +25,6 @@ function declare($, _, openerp) {
         notification: function(message) {
             throw new Error("Not implemented");
         },
-        defaultInputPlaceholder: null,
-        userName: null,
         connection: null
     });
 
@@ -62,8 +60,9 @@ function declare($, _, openerp) {
     });
 
     im_common.ConversationManager = openerp.Class.extend(openerp.PropertiesMixin, {
-        init: function(parent) {
+        init: function(parent, options) {
             openerp.PropertiesMixin.init.call(this, parent);
+            this.options = options;
             this.set("right_offset", 0);
             this.conversations = [];
             this.users = {};
@@ -102,7 +101,7 @@ function declare($, _, openerp) {
                 return im_common.connection.model("im.user").call("get_by_user_id", [uuid]);
             }).then(function(my_id) {
                 self.my_id = my_id["id"];
-                return im_common.connection.model("im.user").call("assign_name", [uuid, im_common.userName]);
+                return im_common.connection.model("im.user").call("assign_name", [uuid, self.options.userName]);
             }).then(function() {
                 return self.ensure_users([self.my_id]);
             }).then(function() {
@@ -210,7 +209,7 @@ function declare($, _, openerp) {
         activate_user: function(user, focus) {
             var conv = this.users[user.get('id')];
             if (! conv) {
-                conv = new im_common.Conversation(this, user, this.me);
+                conv = new im_common.Conversation(this, user, this.me, this.options);
                 conv.appendTo($("body"));
                 conv.on("destroyed", this, function() {
                     this.conversations = _.without(this.conversations, conv);
@@ -256,18 +255,19 @@ function declare($, _, openerp) {
             "click .oe_im_chatview_close": "destroy",
             "click .oe_im_chatview_header": "show_hide"
         },
-        init: function(parent, user, me) {
+        init: function(parent, user, me, options) {
             this._super(parent);
+            this.options = options
             this.me = me;
             this.user = user;
             this.user.add_watcher();
             this.set("right_position", 0);
             this.shown = true;
             this.set("pending", 0);
-            this.inputPlaceholder = im_common.defaultInputPlaceholder;
+            this.inputPlaceholder = this.options.defaultInputPlaceholder;
         },
         start: function() {
-            this.$().append(openerp.qweb.render("conversation", {widget: this, to_url: im_common.to_url}));
+            this.$().append(openerp.qweb.render("im_common.conversation", {widget: this, to_url: im_common.to_url}));
             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);
@@ -349,7 +349,7 @@ function declare($, _, openerp) {
             };
             date = "" + zpad(date.getHours(), 2) + ":" + zpad(date.getMinutes(), 2);
             
-            this.last_bubble = $(openerp.qweb.render("conversation_bubble", {"items": items, "user": user, "time": date}));
+            this.last_bubble = $(openerp.qweb.render("im_common.conversation_bubble", {"items": items, "user": user, "time": date}));
             $(this.$(".oe_im_chatview_content").children()[0]).append(this.last_bubble);
             this._go_bottom();
         },
index f4acd67..c842155 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <templates>
-<t t-name="conversation">
+<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"/>
         <t t-esc="widget.user.get('name') || _t('You')"/>
@@ -18,7 +18,7 @@
     </div>
 </t>
 
-<t t-name="conversation_bubble">
+<t t-name="im_common.conversation_bubble">
     <div class="oe_im_chatview_bubble">
         <div class="oe_im_chatview_clip">
             <img class="oe_im_chatview_avatar" t-att-src="user.get('image_url')"/>
index d238014..0e13c23 100644 (file)
@@ -25,8 +25,6 @@ define(["openerp", "im_common", "underscore", "require", "jquery",
 
         im_common.notification = notification;
         im_common.to_url = require.toUrl;
-        im_common.defaultInputPlaceholder = options.inputPlaceholder;
-        im_common.userName = options.userName;
         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"));
 
@@ -83,7 +81,7 @@ define(["openerp", "im_common", "underscore", "require", "jquery",
         },
         click: function() {
             if (! this.manager) {
-                this.manager = new im_common.ConversationManager(null);
+                this.manager = new im_common.ConversationManager(this, this.options);
                 this.activated_def = this.manager.start_polling();
             }
             var def = $.Deferred();