(function () {
var preview = (function () {
'use strict';
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
var global$1 = tinymce.util.Tools.resolve('tinymce.Env');
var getPreviewDialogWidth = function (editor) {
return parseInt(editor.getParam('plugin_preview_width', '650'), 10);
};
var getPreviewDialogHeight = function (editor) {
return parseInt(editor.getParam('plugin_preview_height', '500'), 10);
};
var getContentStyle = function (editor) {
return editor.getParam('content_style', '');
};
var Settings = {
getPreviewDialogWidth: getPreviewDialogWidth,
getPreviewDialogHeight: getPreviewDialogHeight,
getContentStyle: getContentStyle
};
var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools');
var getPreviewHtml = function (editor) {
var previewHtml;
var headHtml = '';
var encode = editor.dom.encode;
var contentStyle = Settings.getContentStyle(editor);
headHtml += '';
if (contentStyle) {
headHtml += '';
}
global$2.each(editor.contentCSS, function (url) {
headHtml += '';
});
var bodyId = editor.settings.body_id || 'tinymce';
if (bodyId.indexOf('=') !== -1) {
bodyId = editor.getParam('body_id', '', 'hash');
bodyId = bodyId[editor.id] || bodyId;
}
var bodyClass = editor.settings.body_class || '';
if (bodyClass.indexOf('=') !== -1) {
bodyClass = editor.getParam('body_class', '', 'hash');
bodyClass = bodyClass[editor.id] || '';
}
var preventClicksOnLinksScript = ' ';
var dirAttr = editor.settings.directionality ? ' dir="' + editor.settings.directionality + '"' : '';
previewHtml = '' + '' + '
' + headHtml + '' + '' + editor.getContent() + preventClicksOnLinksScript + '' + '';
return previewHtml;
};
var injectIframeContent = function (editor, iframe, sandbox) {
var previewHtml = getPreviewHtml(editor);
if (!sandbox) {
var doc = iframe.contentWindow.document;
doc.open();
doc.write(previewHtml);
doc.close();
} else {
iframe.src = 'data:text/html;charset=utf-8,' + encodeURIComponent(previewHtml);
}
};
var IframeContent = {
getPreviewHtml: getPreviewHtml,
injectIframeContent: injectIframeContent
};
var open = function (editor) {
var sandbox = !global$1.ie;
var dialogHtml = '';
var dialogWidth = Settings.getPreviewDialogWidth(editor);
var dialogHeight = Settings.getPreviewDialogHeight(editor);
editor.windowManager.open({
title: 'Preview',
width: dialogWidth,
height: dialogHeight,
html: dialogHtml,
buttons: {
text: 'Close',
onclick: function (e) {
e.control.parent().parent().close();
}
},
onPostRender: function (e) {
var iframeElm = e.control.getEl('body').firstChild;
IframeContent.injectIframeContent(editor, iframeElm, sandbox);
}
});
};
var Dialog = { open: open };
var register = function (editor) {
editor.addCommand('mcePreview', function () {
Dialog.open(editor);
});
};
var Commands = { register: register };
var register$1 = function (editor) {
editor.addButton('preview', {
title: 'Preview',
cmd: 'mcePreview'
});
editor.addMenuItem('preview', {
text: 'Preview',
cmd: 'mcePreview',
context: 'view'
});
};
var Buttons = { register: register$1 };
global.add('preview', function (editor) {
Commands.register(editor);
Buttons.register(editor);
});
function Plugin () {
}
return Plugin;
}());
})();