From f41cea02299dc41dcc1f934d57430b564cf708ef Mon Sep 17 00:00:00 2001 From: Felix Hammerl Date: Fri, 1 Apr 2016 14:51:27 +0200 Subject: Run event test async with source passed to iframe via Blob URI --- web-ui/app/js/mixins/with_mail_sandbox.js | 58 ++++++++++++++++--------------- 1 file changed, 30 insertions(+), 28 deletions(-) (limited to 'web-ui/app/js') diff --git a/web-ui/app/js/mixins/with_mail_sandbox.js b/web-ui/app/js/mixins/with_mail_sandbox.js index c292cb70..1a51840d 100644 --- a/web-ui/app/js/mixins/with_mail_sandbox.js +++ b/web-ui/app/js/mixins/with_mail_sandbox.js @@ -34,41 +34,43 @@ define( }); iframe.onload = function() { - // use iframe-resizer to dynamically adapt iframe size to its content - var config = { - resizedCallback: scaleToFit, - checkOrigin: false - }; - $iframe.iFrameResize(config); + if ($iframe.iFrameResize) { + // use iframe-resizer to dynamically adapt iframe size to its content + var config = { + resizedCallback: scaleToFit, + checkOrigin: false + }; + $iframe.iFrameResize(config); + } + + iframe.contentWindow.postMessage({ + html: content + }, '*'); // transform scale iframe to fit container width // necessary if iframe is wider than container function scaleToFit() { - var parentWidth = $iframe.parent().width(); - var w = $iframe.width(); - var scale = 'none'; + var parentWidth = $iframe.parent().width(); + var w = $iframe.width(); + var scale = 'none'; - // only scale html mails - if (mail && mail.htmlBody && (w > parentWidth)) { - scale = parentWidth / w; - scale = 'scale(' + scale + ',' + scale + ')'; - } + // only scale html mails + if (mail && mail.htmlBody && (w > parentWidth)) { + scale = parentWidth / w; + scale = 'scale(' + scale + ',' + scale + ')'; + } - $iframe.css({ - '-webkit-transform-origin': '0 0', - '-moz-transform-origin': '0 0', - '-ms-transform-origin': '0 0', - 'transform-origin': '0 0', - '-webkit-transform': scale, - '-moz-transform': scale, - '-ms-transform': scale, - 'transform': scale - }); + $iframe.css({ + '-webkit-transform-origin': '0 0', + '-moz-transform-origin': '0 0', + '-ms-transform-origin': '0 0', + 'transform-origin': '0 0', + '-webkit-transform': scale, + '-moz-transform': scale, + '-ms-transform': scale, + 'transform': scale + }); } - - iframe.contentWindow.postMessage({ - html: content - }, '*'); }; }; } -- cgit v1.2.3