[IMP] Thread widget: added use of expander extension instead of the custom hardcoded stuff.
bzr revid: tde@openerp.com-20120510121749-m3oq3ko5omd08puc
This commit is contained in:
@@ -88,6 +88,7 @@ The main features are:
|
||||
'static/src/css/mail_group.css',
|
||||
],
|
||||
'js': [
|
||||
'static/src/js/jquery.expander.min.js',
|
||||
'static/src/js/mail.js',
|
||||
],
|
||||
'qweb': [
|
||||
|
||||
@@ -284,24 +284,14 @@ openerp.mail = function(session) {
|
||||
else { record.mini_url = this.thread_get_avatar('res.users', 'avatar', record.user_id[0]); }
|
||||
// body text manipulation
|
||||
record.body = this.do_clean_text(record.body);
|
||||
record.tr_body = this.do_truncate_string(record.body, this.params.msg_more_limit);
|
||||
record.body = this.do_replace_internal_links(record.body);
|
||||
console.log(record.body);
|
||||
console.log(record.tr_body);
|
||||
if (record.tr_body) record.tr_body = this.do_replace_internal_links(record.tr_body);
|
||||
this.$element.find('span.oe_mail_msg_body:last').expander();
|
||||
// format date according to the user timezone
|
||||
record.date = session.web.format_value(record.date, {type:"datetime"});
|
||||
// render
|
||||
$(session.web.qweb.render('ThreadMsg', {'record': record, 'thread': this, 'params': this.params, 'display': this.display})
|
||||
).appendTo(this.$element.children('div.oe_mail_thread_display:first'));
|
||||
// truncated: hide full-text, show summary, add buttons
|
||||
if (record.tr_body) {
|
||||
var node_body = this.$element.find('span.oe_mail_msg_body:last').append(' <a href="#" class="reduce">[ ... Show less]</a>');
|
||||
var node_body_short = this.$element.find('span.oe_mail_msg_body_short:last').append(' <a href="#" class="expand">[ ... Show more]</a>');
|
||||
node_body.hide();
|
||||
node_body.find('a:last').click(function() { node_body.hide(); node_body_short.show(); return false; });
|
||||
node_body_short.find('a:last').click(function() { node_body_short.hide(); node_body.show(); return false; });
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -436,11 +426,6 @@ openerp.mail = function(session) {
|
||||
return this.session.prefix + '/web/binary/image?session_id=' + this.session.session_id + '&model=' + model + '&field=' + field + '&id=' + (id || '');
|
||||
},
|
||||
|
||||
do_truncate_string: function(string, max_length) {
|
||||
if (string.length <= (max_length * 1.2)) return false;
|
||||
else return string.slice(0, max_length);
|
||||
},
|
||||
|
||||
do_clean_text: function (string) {
|
||||
var html = $('<div/>').text(string.replace(/\s+/g, ' ')).html().replace(new RegExp('<(/)?(b|em|br|br /)\\s*>', 'gi'), '<$1$2>');
|
||||
return html;
|
||||
|
||||
@@ -84,9 +84,7 @@
|
||||
<t t-if="params.thread_level > 0">
|
||||
<a href="#" class="intlink oe_mail_oe_intlink" t-attf-data-res-model='{params.res_model}' t-attf-data-res-id='{params.res_id}'><t t-raw="record.record_name"/></a>
|
||||
</t>
|
||||
<span class="oe_mail_msg_body"><t t-raw="record.body"/></span>
|
||||
<t t-if="record.tr_body"><span class="oe_mail_msg_body_short"><t t-raw="record.tr_body"/></span></t>
|
||||
<br />
|
||||
<span class="oe_mail_msg_body"><t t-raw="record.body"/></span><br />
|
||||
<span class="oe_mail_oe_fade">
|
||||
<a href="#" class="intlink oe_mail_oe_intlink" data-res-model='res.users' t-attf-data-res-id='{record.user_id[0]}'><t t-raw="record.user_id[1]"/></a>
|
||||
on <t t-raw="record.date"/>
|
||||
@@ -107,9 +105,7 @@
|
||||
<span class="oe_mail_oe_bold">Subject:</span> <t t-esc="record.subject"/><br />
|
||||
</p>
|
||||
<p class="oe_mail_msg">
|
||||
<span class="oe_mail_msg_body"><t t-raw="record.body"/></span>
|
||||
<t t-if="record.tr_body"><span class="oe_mail_msg_body_short"><t t-raw="record.tr_body"/></span></t>
|
||||
<br />
|
||||
<span class="oe_mail_msg_body"><t t-raw="record.body"/></span><br />
|
||||
<span class="oe_mail_oe_right">
|
||||
<t t-call="MessageDisplayManageLinks"/>
|
||||
</span>
|
||||
|
||||
Reference in New Issue
Block a user