1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-05-14 14:25:29 +02:00

focus detached window if already present and size it same as iframe. fixes #92

This commit is contained in:
Kushagra Gour 2017-09-16 19:27:28 +05:30
parent afd491b543
commit 748c8a0b00

View File

@ -1856,11 +1856,19 @@ customEditorFontInput, cssSettingsModal, cssSettingsBtn, acssSettingsTextarea
}
scope.openDetachedPreview = function() {
if (scope.detachedWindow) {
scope.detachedWindow.focus();
return;
}
var iframeBounds = frame.getBoundingClientRect();
const iframeWidth = iframeBounds.width;
const iframeHeight = iframeBounds.height;
document.body.classList.add('is-detached-mode');
scope.detachedWindow = window.open(
'./preview.html',
'Web Maker',
'width=420,height=230,resizable,scrollbars=yes,status=1'
`width=${iframeWidth},height=${iframeHeight},resizable,scrollbars=yes,status=1`
);
setTimeout(() => {
scope.detachedWindow.postMessage(frame.src, '*');