[MERGE] Merged with addons/trunk.
[odoo/odoo.git] / addons / mail / static / src / js / mail.js
index 3946547..da54130 100644 (file)
@@ -302,17 +302,20 @@ openerp.mail = function(session) {
             record.body = this.do_clean_text(record.body);
             record.body = this.do_replace_internal_links(record.body);
 
-            // split for see more
-            var split = this.do_truncate_string(record.body, this.params.msg_more_limit);
-            record.body_head = split[0];
-            record.body_tail = split[1];
-
             // format date according to the user timezone
             record.date = session.web.format_value(record.date, {type:"datetime"});
 
-
             var rendered = session.web.qweb.render('mail.Thread.message', {'record': record, 'thread': this, 'params': this.params, 'display': this.display});
-            $( rendered).appendTo(this.$element.children('div.oe_mail_thread_display:first'));
+            $(rendered).appendTo(this.$element.children('div.oe_mail_thread_display:first'));
+            // expand feature
+            this.$element.find('div.oe_mail_msg_body:last').expander({
+                slicePoint: this.params.msg_more_limit,
+                expandText: 'see more',
+                userCollapseText: 'see less',
+                detailClass: 'oe_mail_msg_tail',
+                moreClass: 'oe_mail_expand',
+                lesClass: 'oe_mail_reduce',
+                });
         },
        
         /**
@@ -447,20 +450,6 @@ openerp.mail = function(session) {
             return this.session.prefix + '/web/binary/image?session_id=' + this.session.session_id + '&model=' + model + '&field=' + field + '&id=' + (id || '');
         },
         
-        /**
-         * @param {String} string to truncate
-         * @param {Number} max number of chars to display 
-         * @returns {String} truncated string
-         */
-        do_truncate_string: function(string, max_length) {
-            // multiply by 1.2: prevent truncating an just too little long string
-            if (string.length <= (max_length * 1.2)) {
-                return [string, ""];
-            } else {
-                return [string.slice(0, max_length), string.slice(max_length)];
-            }
-        },
-        
         /** Removes html tags, except b, em, br */
         do_clean_text: function (string) {
             var html = $('<div/>').text(string.replace(/\s+/g, ' ')).html().replace(new RegExp('&lt;(/)?(b|em|br|br /)\\s*&gt;', 'gi'), '<$1$2>');