1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-13 10:06:23 +02:00

add basic detached preview mode. fixes #92

This commit is contained in:
Kushagra Gour
2017-09-04 03:17:26 +05:30
parent 83e28635d0
commit 90f50f5502
5 changed files with 59 additions and 0 deletions

View File

@ -1038,6 +1038,9 @@ customEditorFontInput
chrome.i18n.getMessage('@@extension_id') +
'/temporary/' +
'preview.html';
if (scope.detachedWindow) {
scope.detachedWindow.postMessage(frame.src, '*');
}
});
});
}
@ -1805,6 +1808,25 @@ customEditorFontInput
});
}
scope.openDetachedPreview = function() {
document.body.classList.add('is-detached-mode');
scope.detachedWindow = window.open(
'./preview.html',
'Web Maker',
'width=420,height=230,resizable,scrollbars=yes,status=1'
);
setTimeout(() => {
scope.detachedWindow.postMessage(frame.src, '*');
}, 1000);
function checkWindow() {
if (scope.detachedWindow && scope.detachedWindow.closed) {
clearInterval(intervalID);
document.body.classList.remove('is-detached-mode');
}
}
var intervalID = window.setInterval(checkWindow, 500);
};
function init() {
var lastCode;