diff options
| author | Christophe Matthieu <chm@odoo.com> | 2016-01-18 11:42:34 +0100 |
|---|---|---|
| committer | Christophe Matthieu <chm@odoo.com> | 2016-01-18 17:09:01 +0100 |
| commit | 4e0e376b0a2c524d99cb18a23163f52ecadd3063 (patch) | |
| tree | a73f82bc07a2fabcde14605e33c9ba9aa441bf17 /addons/web_editor/static/src/js | |
| parent | 990597ba1c41394ad23b340416266b6888edc75b (diff) | |
[FIX] web_editor: use iframe instead of direct content for preview
The preview is not equal to the real email rendering because the backend css is present.
Diffstat (limited to 'addons/web_editor/static/src/js')
| -rw-r--r-- | addons/web_editor/static/src/js/backend.js | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/addons/web_editor/static/src/js/backend.js b/addons/web_editor/static/src/js/backend.js index acf603697b8..43f411ef988 100644 --- a/addons/web_editor/static/src/js/backend.js +++ b/addons/web_editor/static/src/js/backend.js @@ -62,9 +62,15 @@ var FieldTextHtmlSimple = widget.extend({ initialize_content: function() { var self = this; this.$textarea = this.$("textarea").val(this.get('value') || "<p><br/></p>"); + this.$content = $(); if (this.get("effective_readonly")) { - this.$textarea.hide().after('<div class="note-editable o_readonly"/>'); + this.$textarea.hide().after('<iframe class="o_readonly"/>'); + setTimeout(function () { + self.$content = $("body", self.$('iframe').contents()[0]); + self.$content.html(self.text_to_html(self.get('value'))); + self.resize(); + }); } else { this.$textarea.summernote(this._config()); @@ -77,8 +83,10 @@ var FieldTextHtmlSimple = widget.extend({ var reset = _.bind(this.reset_history, this); this.view.on('load_record', this, reset); setTimeout(reset, 0); + + this.$content = this.$('.note-editable:first'); + transcoder.style_to_class(this.$content); } - this.$content = this.$('.note-editable:first'); $(".oe-view-manager-content").on("scroll", function () { $('.o_table_handler').remove(); @@ -113,10 +121,18 @@ var FieldTextHtmlSimple = widget.extend({ return this.$content.focus(); }; }, + resize: function() { + this.$('iframe').css('height', '0px').css('height', Math.max(180, Math.min(this.$content[0] ? this.$content[0].scrollHeight : 0, 500)) + 'px'); + }, render_value: function() { var value = this.get('value'); this.$textarea.val(value || ''); this.$content.html(this.text_to_html(value)); + if (this.get("effective_readonly")) { + this.resize(); + } else { + transcoder.style_to_class(this.$content); + } if (this.$content.is(document.activeElement)) { this.focus(); } |
