diff options
| author | Christophe Simonis <chs@odoo.com> | 2016-01-27 12:24:04 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2016-01-27 12:24:04 +0100 |
| commit | 78d20b552b4374b94aec7097c0e6a48a3dd2d961 (patch) | |
| tree | 5acd7cbf1cc9e2f277034f44fc0ebebaa3a1a79c /addons/web_editor/static/src/js/backend.js | |
| parent | 740a6eadd379cc3fa26aefb9350f1c95b3e05ebd (diff) | |
| parent | 7e44ddcda3f21c7e6401173539dc0fe93f9a7dd2 (diff) | |
[MERGE] forward port of branch saas-8 up to 7e44ddc
Diffstat (limited to 'addons/web_editor/static/src/js/backend.js')
| -rw-r--r-- | addons/web_editor/static/src/js/backend.js | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/addons/web_editor/static/src/js/backend.js b/addons/web_editor/static/src/js/backend.js index eca913e1309..becd0fe4769 100644 --- a/addons/web_editor/static/src/js/backend.js +++ b/addons/web_editor/static/src/js/backend.js @@ -62,9 +62,20 @@ 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"/>'); + if (this.options['style-inline']) { + 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.$content = $('<div class="note-editable o_readonly"/>'); + this.$textarea.hide().after(this.$content); + } } else { this.$textarea.summernote(this._config()); @@ -77,8 +88,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(); @@ -98,7 +111,7 @@ var FieldTextHtmlSimple = widget.extend({ value = '<p><br/></p>'; } else { value = "<p>"+value.split(/<br\/?>/).join("<br/></p><p>")+"</p>"; - value = value.replace(/<p><\/p>/g, '').replace('<p><p>', '<p>').replace('</p></p>', '</p>'); + value = value.replace(/<p><\/p>/g, '').replace('<p><p>', '<p>').replace('<p><p ', '<p ').replace('</p></p>', '</p>'); } return value; }, @@ -111,12 +124,20 @@ var FieldTextHtmlSimple = widget.extend({ return this.$content.focusInEnd(); } catch (e) { return this.$content.focus(); - }; + } + }, + resize: function() { + this.$('iframe').css('height', '0px').css('height', Math.max(30, 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(); } |
