fix field iframe wysiwyg height

This commit is contained in:
yuri
2015-02-17 14:57:17 +02:00
parent 20db3b0bd2
commit 2f8e1aeaf2
+11 -12
View File
@@ -64,18 +64,22 @@ Espo.define('Views.Fields.Wysiwyg', ['Views.Fields.Text', 'lib!Summernote'], fun
if (!this.model.has('isHtml') || this.model.get('isHtml')) {
this.$el.find('iframe').removeClass('hidden');
var iframe = this.iframe = this.$el.find('iframe').get(0);
var iframeDocument = this.iframeDocument = iframe.contentWindow.document;
var link = '<link href="client/css/iframe.css" rel="stylesheet" type="text/css"></link>'
iframe.onload = function () {
var height = $(iframe).contents().find('html body').height();
iframe.style.height = height + 'px';
};
iframeDocument.open('text/html', 'replace');
var doc = iframe.contentWindow.document;
var link = '<link href="client/css/iframe.css" rel="stylesheet" type="text/css"></link>';
doc.open('text/html', 'replace');
var body = this.model.get('body');
body += link;
iframeDocument.write(body);
iframeDocument.close();
this.handleIframeHeight();
doc.write(body);
doc.close();
} else {
this.$el.find('.plain').removeClass('hidden');
@@ -83,11 +87,6 @@ Espo.define('Views.Fields.Wysiwyg', ['Views.Fields.Text', 'lib!Summernote'], fun
}
},
handleIframeHeight: function () {
console.log(this.iframeDocument.body.scrollHeight);
this.iframe.style.height = this.iframeDocument.body.scrollHeight + 'px';
},
enableWysiwygMode: function () {
this.$summernote = this.$element.summernote({
height: 250,