more font size tweaks.
[citadel.git] / webcit / tiny_mce / plugins / paste / js / pasteword.js
index 6701b99fc8ccf78b843c25a7bf9a4b923106c68b..a52731c368e4db331e36cd11e691731d98dfc91b 100644 (file)
@@ -1,56 +1,51 @@
 tinyMCEPopup.requireLangPack();\r
 \r
-function saveContent() {\r
-       var html = document.getElementById("frmData").contentWindow.document.body.innerHTML;\r
-\r
-       if (html == ''){\r
+var PasteWordDialog = {\r
+       init : function() {\r
+               var ed = tinyMCEPopup.editor, el = document.getElementById('iframecontainer'), ifr, doc, css, cssHTML = '';\r
+\r
+               // Create iframe\r
+               el.innerHTML = '<iframe id="iframe" src="javascript:\'\';" frameBorder="0" style="border: 1px solid gray"></iframe>';\r
+               ifr = document.getElementById('iframe');\r
+               doc = ifr.contentWindow.document;\r
+\r
+               // Force absolute CSS urls\r
+               css = [ed.baseURI.toAbsolute("themes/" + ed.settings.theme + "/skins/" + ed.settings.skin + "/content.css")];\r
+               css = css.concat(tinymce.explode(ed.settings.content_css) || []);\r
+               tinymce.each(css, function(u) {\r
+                       cssHTML += '<link href="' + ed.documentBaseURI.toAbsolute('' + u) + '" rel="stylesheet" type="text/css" />';\r
+               });\r
+\r
+               // Write content into iframe\r
+               doc.open();\r
+               doc.write('<html><head>' + cssHTML + '</head><body class="mceContentBody" spellcheck="false"></body></html>');\r
+               doc.close();\r
+\r
+               doc.designMode = 'on';\r
+               this.resize();\r
+\r
+               window.setTimeout(function() {\r
+                       ifr.contentWindow.focus();\r
+               }, 10);\r
+       },\r
+\r
+       insert : function() {\r
+               var h = document.getElementById('iframe').contentWindow.document.body.innerHTML;\r
+\r
+               tinyMCEPopup.editor.execCommand('mceInsertClipboardContent', false, {content : h, wordContent : true});\r
                tinyMCEPopup.close();\r
-               return false;\r
-       }\r
-\r
-       tinyMCEPopup.execCommand('mcePasteWord', false, html);\r
-       tinyMCEPopup.close();\r
-}\r
-\r
-function onLoadInit() {\r
-       tinyMCEPopup.resizeToInnerSize();\r
-\r
-       // Fix for endless reloading in FF\r
-       window.setTimeout(createIFrame, 10);\r
-}\r
-\r
-function createIFrame() {\r
-       document.getElementById('iframecontainer').innerHTML = '<iframe id="frmData" name="frmData" class="sourceIframe" src="blank.htm" height="280" width="400" frameborder="0" style="background-color:#FFFFFF; width:100%;" dir="ltr" wrap="soft"></iframe>';\r
-}\r
+       },\r
 \r
-var wHeight=0, wWidth=0, owHeight=0, owWidth=0;\r
+       resize : function() {\r
+               var vp = tinyMCEPopup.dom.getViewPort(window), el;\r
 \r
-function initIframe(doc) {\r
-       var dir = tinyMCEPopup.editor.settings.directionality;\r
-\r
-       doc.body.dir = dir;\r
-\r
-       // Remove Gecko spellchecking\r
-       if (tinymce.isGecko)\r
-               doc.body.spellcheck = tinyMCEPopup.getParam("gecko_spellcheck");\r
-\r
-       resizeInputs();\r
-}\r
-\r
-function resizeInputs() {\r
-       if (!tinymce.isIE) {\r
-               wHeight = self.innerHeight - 80;\r
-               wWidth = self.innerWidth - 18;\r
-       } else {\r
-               wHeight = document.body.clientHeight - 80;\r
-               wWidth = document.body.clientWidth - 18;\r
-       }\r
+               el = document.getElementById('iframe');\r
 \r
-       var elm = document.getElementById('frmData');\r
-       if (elm) {\r
-               elm.style.height = Math.abs(wHeight) + 'px';\r
-               elm.style.width  = Math.abs(wWidth) + 'px';\r
+               if (el) {\r
+                       el.style.width  = (vp.w - 20) + 'px';\r
+                       el.style.height = (vp.h - 90) + 'px';\r
+               }\r
        }\r
-}\r
+};\r
 \r
-tinyMCEPopup.onInit.add(onLoadInit);\r
+tinyMCEPopup.onInit.add(PasteWordDialog.init, PasteWordDialog);\r