annotate WebContent/jscripts/tiny_mce/plugins/paste/js/pasteword.js @ 5:0be9d53a6967

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