From 123740e9f7243601824304b37f71bafad8205d8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 14 May 2012 16:53:59 +0200 Subject: [PATCH] [REF] _get_image out of widgets and become tools_get_image, because it was defined twice for the same behavior. bzr revid: tde@openerp.com-20120514145359-7xdt3qqtwbhhvzyp --- addons/mail/static/src/js/mail.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index f9e97010978..2e1b5605400 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -271,7 +271,7 @@ openerp.mail = function(session) { display_comment: function (record) { record.body = this.do_text_nl2br(record.body, true); if (record.type == 'email') { record.mini_url = ('/mail/static/src/img/email_icon.png'); } - else { record.mini_url = this._get_image('res.users', 'avatar', record.user_id[0]); } + else { record.mini_url = tools_get_image(this.session.prefix, this.session.session_id, 'res.users', 'avatar', record.user_id[0]); } // body text manipulation record.body = this.do_clean_text(record.body); record.body = this.do_replace_internal_links(record.body); @@ -292,7 +292,7 @@ openerp.mail = function(session) { }, display_current_user: function () { - return this.$element.find('img.oe_mail_msg_image').attr('src', this._get_image('res.users', 'avatar', this.params.uid)); + return this.$element.find('img.oe_mail_msg_image').attr('src', tools_get_image(this.session.prefix, this.session.session_id, 'res.users', 'avatar', this.params.uid)); }, do_comment: function () { @@ -413,11 +413,6 @@ openerp.mail = function(session) { * MISC TOOLS METHODS */ - /** get an image in /web/binary/image?... */ - _get_image: function(model, field, id) { - return this.session.prefix + '/web/binary/image?session_id=' + this.session.session_id + '&model=' + model + '&field=' + field + '&id=' + (id || ''); - }, - /** checks if tue current user is the message author */ _is_author: function (id) { return (this.session.uid == id); @@ -501,7 +496,7 @@ openerp.mail = function(session) { $('

').html('Followers (' + records.length + ')').appendTo(sub_node); _(records).each(function (record) { if (record.id == self.session.uid) { self.is_subscriber = true; } - var mini_url = self._get_image('res.users', 'avatar', record.id); + var mini_url = tools_get_image(self.session.prefix, self.session.session_id, 'res.users', 'avatar', record.id); $('' + record.name + '').appendTo(sub_node); }); if (self.is_subscriber) { @@ -529,10 +524,6 @@ openerp.mail = function(session) { else { this.$element.find('button.oe_mail_button_followers').html('Display followers'); } this.$element.find('div.oe_mail_recthread_followers').toggle(); }, - - _get_image: function(model, field, id) { - return this.session.prefix + '/web/binary/image?session_id=' + this.session.session_id + '&model=' + model + '&field=' + field + '&id=' + (id || ''); - }, }); @@ -795,6 +786,12 @@ openerp.mail = function(session) { } return cs; } + + /** get an image in /web/binary/image?... */ + function tools_get_image(session_prefix, session_id, model, field, id) { + return session_prefix + '/web/binary/image?session_id=' + session_id + '&model=' + model + '&field=' + field + '&id=' + (id || ''); + } + }; // vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax: