From 3e4d6ad44066690bc01caab2ed9a893f54be8fb5 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Thu, 25 Oct 2012 10:05:29 +0200 Subject: [PATCH] [IMP] mail: oppenchatter hidden attachment bzr revid: chm@openerp.com-20121025080529-p2dw63h2u2ixyt26 --- addons/mail/static/src/css/mail.css | 4 +++- addons/mail/static/src/js/mail.js | 35 +++++++++++++++-------------- addons/mail/static/src/xml/mail.xml | 14 +++--------- 3 files changed, 24 insertions(+), 29 deletions(-) diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index 4b412000a54..0221c36824c 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -158,9 +158,11 @@ padding-top: 2px; padding-bottom:6px; } -.openerp .oe_mail .oe_msg_attachments.oe_hidden{ +.openerp .oe_mail .oe_msg_attachments.oe_hidden, +.openerp .oe_mail .oe_msg_images.oe_hidden{ margin:0px; border: none; + display: none; } .openerp .oe_mail .oe_msg_attachments{ margin-bottom: 4px; diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 03c0b21da20..6ba893339fc 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -372,8 +372,9 @@ openerp.mail = function(session) { 'mail.mt_comment', this.context.default_parent_id, attachments, + // (this.options.display_indented_thread - this.thread_level), this.parent_thread.context - ]).then(function(records){ + ]).then(function(records) { self.parent_thread.switch_new_message(records); self.on_cancel(); //session.web.unblockUI(); @@ -407,7 +408,7 @@ openerp.mail = function(session) { if(this.$render_expandable.is(':hidden')){ - this.$render_expandable.show(); + this.$render_expandable.css('display', ''); this.$render_compact.hide(); this.$render_expandable.find('textarea').focus(); @@ -417,7 +418,7 @@ openerp.mail = function(session) { if(!this.$render_expandable.find('textarea').val().match(/\S+/)){ this.$render_expandable.hide(); if(this.options.show_compact_message && this.show_compact_message) { - this.$render_compact.show(); + this.$render_compact.css('display', ''); } else { this.$render_compact.hide(); } @@ -434,7 +435,7 @@ openerp.mail = function(session) { do_show_compact: function() { if(this.options.show_compact_message && (!this.$render_expandable || this.$render_expandable.is(':hidden'))) { - this.$render_compact.show(); + this.$render_compact.css('display', ''); } this.show_compact_message = true; } @@ -642,33 +643,29 @@ openerp.mail = function(session) { attach.is_image = true; attach['url'] = mail.ChatterUtils.get_image(this.session, 'ir.attachment', 'datas', attach.id); } - //To do - // if((attach.filename || attach.name).match(/[.](pdf|doc|docx|xls|xlsx|ppt|pptx|psd|tiff|dxf|svg)$/i)) { - // attach.is_document = true; - // attach.url_escape = encodeURIComponent(attach.url); - // } } - }, start: function() { this._super.apply(this, arguments); this.expender(); - this.$el.hide().fadeIn(750); + this.$el.hide().fadeIn(750, function() {$(this).css('display', '');}); this.resize_img(); this.bind_events(); this.create_thread(); + this.$('.oe_msg_attachments, .oe_msg_images').addClass("oe_hidden"); }, resize_img: function() { - this.$("img").load(function() { + var resize = function() { var h = $(this).height(); var w = $(this).width(); if( h > 100 || w >100 ) { var ratio = 100 / (h > w ? h : w); $(this).attr("width", parseInt( w*ratio )).attr("height", parseInt( h*ratio )); } - }); + }; + this.$("img").load(resize).each(resize); }, /** @@ -678,8 +675,14 @@ openerp.mail = function(session) { var self = this; // event: click on 'Attachment(s)' in msg - this.$('a.oe_msg_view_attachments:first').on('click', function (event) { - self.$('.oe_msg_attachments:first').toggle(); + this.$('.oe_mail_msg_view_attachments').on('click', function (event) { + var attach = self.$('.oe_msg_attachments:first, .oe_msg_images:first'); + if( self.$('.oe_msg_attachments:first').hasClass("oe_hidden") ) { + attach.removeClass("oe_hidden"); + } else { + attach.addClass("oe_hidden"); + } + self.resize_img(); }); // event: click on icone 'Read' in header this.$el.on('click', '.oe_read', this.on_message_read_unread); @@ -1584,8 +1587,6 @@ openerp.mail = function(session) { * @param {Array} [options.domain] domain on the Wall * @param {Object} [options.context] context, is an object. It should * contain default_model, default_res_id, to give it to the threads. - * @param {Number} [options.thread_level] number of thread levels to display - * 0 being flat. */ init: function (parent, options) { this._super(parent); diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index 59ffc93bdf4..e806cf93a22 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -70,8 +70,8 @@ Template used to display attachments in a mail.message --> - - + +
@@ -90,21 +90,13 @@
- + - - - - - - - -