PageRenderTime 30ms CodeModel.GetById 13ms app.highlight 11ms RepoModel.GetById 2ms app.codeStats 0ms

/BlogEngine/BlogEngine.NET/editors/tiny_mce_3_4_3_1/plugins/paste/js/pasteword.js

#
JavaScript | 51 lines | 36 code | 12 blank | 3 comment | 2 complexity | 112504d12e971e4d32f17a59c5616c36 MD5 | raw file
 1tinyMCEPopup.requireLangPack();
 2
 3var PasteWordDialog = {
 4	init : function() {
 5		var ed = tinyMCEPopup.editor, el = document.getElementById('iframecontainer'), ifr, doc, css, cssHTML = '';
 6
 7		// Create iframe
 8		el.innerHTML = '<iframe id="iframe" src="javascript:\'\';" frameBorder="0" style="border: 1px solid gray"></iframe>';
 9		ifr = document.getElementById('iframe');
10		doc = ifr.contentWindow.document;
11
12		// Force absolute CSS urls
13		css = [ed.baseURI.toAbsolute("themes/" + ed.settings.theme + "/skins/" + ed.settings.skin + "/content.css")];
14		css = css.concat(tinymce.explode(ed.settings.content_css) || []);
15		tinymce.each(css, function(u) {
16			cssHTML += '<link href="' + ed.documentBaseURI.toAbsolute('' + u) + '" rel="stylesheet" type="text/css" />';
17		});
18
19		// Write content into iframe
20		doc.open();
21		doc.write('<html><head>' + cssHTML + '</head><body class="mceContentBody" spellcheck="false"></body></html>');
22		doc.close();
23
24		doc.designMode = 'on';
25		this.resize();
26
27		window.setTimeout(function() {
28			ifr.contentWindow.focus();
29		}, 10);
30	},
31
32	insert : function() {
33		var h = document.getElementById('iframe').contentWindow.document.body.innerHTML;
34
35		tinyMCEPopup.editor.execCommand('mceInsertClipboardContent', false, {content : h, wordContent : true});
36		tinyMCEPopup.close();
37	},
38
39	resize : function() {
40		var vp = tinyMCEPopup.dom.getViewPort(window), el;
41
42		el = document.getElementById('iframe');
43
44		if (el) {
45			el.style.width  = (vp.w - 20) + 'px';
46			el.style.height = (vp.h - 90) + 'px';
47		}
48	}
49};
50
51tinyMCEPopup.onInit.add(PasteWordDialog.init, PasteWordDialog);