From 49aa46e8f698b7dd4e38741bedb6874c2216cbb7 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 7 Feb 2013 15:45:54 +0100 Subject: [PATCH] Like previous patch on customer-side bzr revid: nicolas.vanhoren@openerp.com-20130207144554-n13eygc7775mp7e7 --- .../static/ext/static/js/livesupport.js | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/addons/live_support/static/ext/static/js/livesupport.js b/addons/live_support/static/ext/static/js/livesupport.js index e1e2a1a1ab7..35435e867f7 100644 --- a/addons/live_support/static/ext/static/js/livesupport.js +++ b/addons/live_support/static/ext/static/js/livesupport.js @@ -80,7 +80,7 @@ define(["nova", "jquery", "underscore", "oeclient", "require"], function(nova, $ return; } self.manager.ensure_users([user_id]).then(function() { - self.manager.activate_user(self.manager.get_user(user_id)); + self.manager.activate_user(self.manager.get_user(user_id), true); }); }); }, @@ -249,20 +249,22 @@ define(["nova", "jquery", "underscore", "oeclient", "require"], function(nova, $ instance.webclient.set_title_part("im_messages", this.get("waiting_messages") === 0 ? undefined : _.str.sprintf(_t("%d Messages"), this.get("waiting_messages")));*/ }, - activate_user: function(user) { - if (this.users[user.get('id')]) { - return this.users[user.get('id')]; - } - var conv = new livesupport.Conversation(this, user, this.me); - conv.appendTo($("body")); - conv.on("destroyed", this, function() { - this.conversations = _.without(this.conversations, conv); - delete this.users[conv.user.get('id')]; + activate_user: function(user, focus) { + var conv = this.users[user.get('id')]; + if (! conv) { + conv = new livesupport.Conversation(this, user, this.me); + conv.appendTo($("body")); + conv.on("destroyed", this, function() { + this.conversations = _.without(this.conversations, conv); + delete this.users[conv.user.get('id')]; + this.calc_positions(); + }); + this.conversations.push(conv); + this.users[user.get('id')] = conv; this.calc_positions(); - }); - this.conversations.push(conv); - this.users[user.get('id')] = conv; - this.calc_positions(); + } + if (focus) + conv.focus(); return conv; }, received_message: function(message, user) { @@ -392,6 +394,9 @@ define(["nova", "jquery", "underscore", "oeclient", "require"], function(nova, $ _go_bottom: function() { this.$(".oe_im_chatview_content").scrollTop($(this.$(".oe_im_chatview_content").children()[0]).height()); }, + focus: function() { + this.$(".oe_im_chatview_input").focus(); + }, destroy: function() { this.user.remove_watcher(); this.trigger("destroyed");