[IMP] mail: preview image on openchatter

bzr revid: chm@openerp.com-20121024134819-5gf165nf6cc21601
This commit is contained in:
Christophe Matthieu
2012-10-24 15:48:19 +02:00
parent 69a2a3180a
commit fc34572ee3
2 changed files with 32 additions and 9 deletions
+17 -3
View File
@@ -175,7 +175,6 @@ openerp.mail = function(session) {
} else {
this.$render_compact.hide();
}
this.bind_events();
},
@@ -198,7 +197,6 @@ openerp.mail = function(session) {
/* when a user click on the upload button, send file read on_attachment_loaded
*/
on_attachment_change: function (event) {
console.log('attach');
event.stopPropagation();
var self = this;
var $target = $(event.target);
@@ -347,7 +345,6 @@ openerp.mail = function(session) {
/*post a message and fetch the message*/
on_message_post: function (body) {
console.log('post');
var self = this;
if (! body) {
@@ -639,18 +636,35 @@ openerp.mail = function(session) {
}
for (var l in this.attachment_ids) {
var attach = this.attachment_ids[l];
if((attach.filename || attach.name).match(/[.](jpg|jpg|gif|png|tif|svg)$/i)) {
attach.is_image = true;
}
attach['url'] = mail.ChatterUtils.get_attachment_url(this.session, attach);
}
},
start: function() {
this._super.apply(this, arguments);
this.expender();
this.$el.hide().fadeIn(750);
this.resize_img();
this.bind_events();
this.create_thread();
},
resize_img: function() {
this.$("img").load(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 ));
}
});
},
/**
* Bind events in the widget. Each event is slightly described
* in the function. */
+15 -6
View File
@@ -70,8 +70,8 @@
Template used to display attachments in a mail.message
-->
<t t-name="mail.thread.message.attachments">
<div t-attf-class="oe_msg_attachments #{widget.attachment_ids[0]?'':'oe_hidden'}">
<t t-foreach="widget.attachment_ids" t-as="attachment">
<span t-attf-class="oe_msg_attachments">
<t t-foreach="widget.attachment_ids" t-as="attachment" t-if="!attachment.is_image">
<div class="oe_attachment">
<span t-if="(attachment.upload or attachment.percent_loaded&lt;100)" t-attf-title="{(attachment.name || attachment.filename) + (attachment.date?' \n('+attachment.date+')':'' )}" t-attf-name="{attachment.name || attachment.filename}">
<div class="oe_upload_in_process">
@@ -79,15 +79,24 @@
</div>
<t t-raw="attachment.name || attachment.filename"/>
</span>
<a t-if="(!attachment.upload or attachment.percent_loaded&gt;=100)" t-att-href="attachment.url" t-attf-title="{(attachment.name || attachment.filename) + (attachment.date?' \n('+attachment.date+')':'' )}">
<t t-raw="attachment.name || attachment.filename"/>
</a>
<t t-if="(!attachment.upload or attachment.percent_loaded&gt;=100)">
<a t-att-href="attachment.url" t-attf-title="{(attachment.name || attachment.filename) + (attachment.date?' \n('+attachment.date+')':'' )}">
<t t-raw="attachment.name || attachment.filename"/>
</a>
</t>
<t t-if="(widget.show_delete_attachment and (!attachment.upload or attachment.percent_loaded&gt;=100))">
<a class="oe_right oe_mail_attachment_delete oe_e" title="Delete this attachment" t-attf-data-id="{attachment.id}">[</a>
</t>
</div>
</t>
</div>
</span>
<span t-attf-class="oe_msg_images">
<t t-foreach="widget.attachment_ids" t-as="attachment" t-if="attachment.is_image">
<a t-att-href="attachment.url" t-attf-title="{(attachment.name || attachment.filename) + (attachment.date?' \n('+attachment.date+')':'' )}">
<img t-if="attachment.is_image" t-attf-title="{(attachment.name || attachment.filename) + (attachment.date?' \n('+attachment.date+')':'' )}" t-att-src="attachment.url"/>
</a>
</t>
</span>
</t>
<t t-name="mail.thread.message.private">