mailtrain/views/partials/editor-bridge.hbs

90 lines
2.8 KiB
Handlebars
Raw Normal View History

2017-03-02 17:52:40 +00:00
<style>
body.noscroll {
overflow: hidden;
}
#editor-frame,
2017-03-10 08:59:25 +00:00
#editor-frame-loader {
2017-03-02 17:52:40 +00:00
position: fixed;
z-index: 10000;
top: 0;
left: 0;
width: 100%;
height: 100%;
2017-03-10 08:59:25 +00:00
border: none;
2017-03-02 17:52:40 +00:00
}
2017-03-10 08:59:25 +00:00
#editor-frame-loader {
2017-03-02 17:52:40 +00:00
z-index: 10001;
2017-03-10 08:59:25 +00:00
background: #eaeced;
2017-03-02 17:52:40 +00:00
}
2017-03-10 08:59:25 +00:00
#editor-frame-loader div {
2017-03-02 17:52:40 +00:00
position: absolute;
top: 50%;
left: 50%;
2017-03-10 08:59:25 +00:00
width: 62px; margin-left: -31px;
height: 72px; margin-top: -36px;
background: url('/mailtrain-header.png');
-webkit-animation: pulsate 1.2s ease-out;
animation: pulsate 1.2s ease-out;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
}
@-webkit-keyframes pulsate {
0% { -webkit-transform: scale(0.1, 0.1); opacity: 0.5; }
70% { opacity: 1.0; }
100% { -webkit-transform: scale(1.2, 1.2); opacity: 0.0; }
2017-03-02 17:52:40 +00:00
}
2017-03-10 08:59:25 +00:00
@keyframes pulsate {
0% { transform: scale(0.1, 0.1); opacity: 0.5; }
70% { opacity: 1.0; }
100% { transform: scale(1.2, 1.2); opacity: 0.0; }
2017-03-02 17:52:40 +00:00
}
</style>
2017-03-10 08:59:25 +00:00
<div id="editor-frame-loader" style="display: none;">
<div></div>
2017-03-02 17:52:40 +00:00
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// campaign or template
var type = window.location.pathname.split('/')[1].slice(0, -1);
var editorWindow;
var $editorFrame = $('<iframe id="editor-frame"/>')
.attr('src', '/{{editorName}}/editor?id={{id}}&type=' + type)
.on('load', function() {
editorWindow = $editorFrame[0].contentWindow;
2017-03-02 20:53:07 +00:00
editorWindow.bridge = editorWindow.bridge || {};
2017-03-02 17:52:40 +00:00
editorWindow.bridge.exit = function() {
closeEditor();
}
setTimeout(function() {
2017-03-10 08:59:25 +00:00
$('#editor-frame-loader').hide();
}, 300);
2017-03-02 17:52:40 +00:00
});
var openEditor = function() {
$('body').addClass('noscroll');
2017-03-10 08:59:25 +00:00
$('#editor-frame-loader').show();
2017-03-02 17:52:40 +00:00
$editorFrame.appendTo($('body'));
}
var closeEditor = function() {
$('body').removeClass('noscroll');
$editorFrame = $editorFrame.detach();
if (editorWindow.bridge.lastSavedHtml) {
$('#template-html').val(editorWindow.bridge.lastSavedHtml);
$('#html-preview-frame').attr('srcdoc', editorWindow.bridge.lastSavedHtml);
2017-03-10 08:59:25 +00:00
$('#html-preview').show();
2017-03-02 17:52:40 +00:00
}
// Reload to discard unsaved changes
$editorFrame.attr('src', '/{{editorName}}/editor?id={{id}}&type=' + type + '&cb=' + Math.random());
}
$('#btn-open-{{editorName}}').on('click', function() {
openEditor();
});
});
</script>