--- /dev/null
+/*\r
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben\r
+ *\r
+ * == BEGIN LICENSE ==\r
+ *\r
+ * Licensed under the terms of any of the following licenses at your\r
+ * choice:\r
+ *\r
+ * - GNU General Public License Version 2 or later (the "GPL")\r
+ * http://www.gnu.org/licenses/gpl.html\r
+ *\r
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
+ * http://www.gnu.org/licenses/lgpl.html\r
+ *\r
+ * - Mozilla Public License Version 1.1 or later (the "MPL")\r
+ * http://www.mozilla.org/MPL/MPL-1.1.html\r
+ *\r
+ * == END LICENSE ==\r
+ *\r
+ * Compatibility code for Adobe AIR.\r
+ */\r
+\r
+if ( FCKBrowserInfo.IsAIR )\r
+{\r
+ var FCKAdobeAIR = (function()\r
+ {\r
+ /*\r
+ * ### Private functions.\r
+ */\r
+\r
+ var getDocumentHead = function( doc )\r
+ {\r
+ var head ;\r
+ var heads = doc.getElementsByTagName( 'head' ) ;\r
+\r
+ if( heads && heads[0] )\r
+ head = heads[0] ;\r
+ else\r
+ {\r
+ head = doc.createElement( 'head' ) ;\r
+ doc.documentElement.insertBefore( head, doc.documentElement.firstChild ) ;\r
+ }\r
+\r
+ return head ;\r
+ } ;\r
+\r
+ /*\r
+ * ### Public interface.\r
+ */\r
+ return {\r
+ FCKeditorAPI_Evaluate : function( parentWindow, script )\r
+ {\r
+ // TODO : This one doesn't work always. The parent window will\r
+ // point to an anonymous function in this window. If this\r
+ // window is destroyied the parent window will be pointing to\r
+ // an invalid reference.\r
+\r
+ // Evaluate the script in this window.\r
+ eval( script ) ;\r
+\r
+ // Point the FCKeditorAPI property of the parent window to the\r
+ // local reference.\r
+ parentWindow.FCKeditorAPI = window.FCKeditorAPI ;\r
+ },\r
+\r
+ EditingArea_Start : function( doc, html )\r
+ {\r
+ // Get the HTML for the <head>.\r
+ var headInnerHtml = html.match( /<head>([\s\S]*)<\/head>/i )[1] ;\r
+\r
+ if ( headInnerHtml && headInnerHtml.length > 0 )\r
+ {\r
+ // Inject the <head> HTML inside a <div>.\r
+ // Do that before getDocumentHead because WebKit moves\r
+ // <link css> elements to the <head> at this point.\r
+ var div = doc.createElement( 'div' ) ;\r
+ div.innerHTML = headInnerHtml ;\r
+\r
+ // Move the <div> nodes to <head>.\r
+ FCKDomTools.MoveChildren( div, getDocumentHead( doc ) ) ;\r
+ }\r
+\r
+ doc.body.innerHTML = html.match( /<body>([\s\S]*)<\/body>/i )[1] ;\r
+\r
+ //prevent clicking on hyperlinks and navigating away\r
+ doc.addEventListener('click', function( ev )\r
+ {\r
+ ev.preventDefault() ;\r
+ ev.stopPropagation() ;\r
+ }, true ) ;\r
+ },\r
+\r
+ Panel_Contructor : function( doc, baseLocation )\r
+ {\r
+ var head = getDocumentHead( doc ) ;\r
+\r
+ // Set the <base> href.\r
+ head.appendChild( doc.createElement('base') ).href = baseLocation ;\r
+\r
+ doc.body.style.margin = '0px' ;\r
+ doc.body.style.padding = '0px' ;\r
+ },\r
+\r
+ ToolbarSet_GetOutElement : function( win, outMatch )\r
+ {\r
+ var toolbarTarget = win.parent ;\r
+\r
+ var targetWindowParts = outMatch[1].split( '.' ) ;\r
+ while ( targetWindowParts.length > 0 )\r
+ {\r
+ var part = targetWindowParts.shift() ;\r
+ if ( part.length > 0 )\r
+ toolbarTarget = toolbarTarget[ part ] ;\r
+ }\r
+\r
+ toolbarTarget = toolbarTarget.document.getElementById( outMatch[2] ) ;\r
+ },\r
+\r
+ ToolbarSet_InitOutFrame : function( doc )\r
+ {\r
+ var head = getDocumentHead( doc ) ;\r
+\r
+ head.appendChild( doc.createElement('base') ).href = window.document.location ;\r
+\r
+ var targetWindow = doc.defaultView;\r
+\r
+ targetWindow.adjust = function()\r
+ {\r
+ targetWindow.frameElement.height = doc.body.scrollHeight;\r
+ } ;\r
+\r
+ targetWindow.onresize = targetWindow.adjust ;\r
+ targetWindow.setTimeout( targetWindow.adjust, 0 ) ;\r
+\r
+ doc.body.style.overflow = 'hidden';\r
+ doc.body.innerHTML = document.getElementById( 'xToolbarSpace' ).innerHTML ;\r
+ }\r
+ } ;\r
+ })();\r
+\r
+ /*\r
+ * ### Overrides\r
+ */\r
+ ( function()\r
+ {\r
+ // Save references for override reuse.\r
+ var _Original_FCKPanel_Window_OnFocus = FCKPanel_Window_OnFocus ;\r
+ var _Original_FCKPanel_Window_OnBlur = FCKPanel_Window_OnBlur ;\r
+ var _Original_FCK_StartEditor = FCK.StartEditor ;\r
+\r
+ FCKPanel_Window_OnFocus = function( e, panel )\r
+ {\r
+ // Call the original implementation.\r
+ _Original_FCKPanel_Window_OnFocus.call( this, e, panel ) ;\r
+\r
+ if ( panel._focusTimer )\r
+ clearTimeout( panel._focusTimer ) ;\r
+ }\r
+\r
+ FCKPanel_Window_OnBlur = function( e, panel )\r
+ {\r
+ // Delay the execution of the original function.\r
+ panel._focusTimer = FCKTools.SetTimeout( _Original_FCKPanel_Window_OnBlur, 100, this, [ e, panel ] ) ;\r
+ }\r
+\r
+ FCK.StartEditor = function()\r
+ {\r
+ // Force pointing to the CSS files instead of using the inline CSS cached styles.\r
+ window.FCK_InternalCSS = FCKConfig.BasePath + 'css/fck_internal.css' ;\r
+ window.FCK_ShowTableBordersCSS = FCKConfig.BasePath + 'css/fck_showtableborders_gecko.css' ;\r
+\r
+ _Original_FCK_StartEditor.apply( this, arguments ) ;\r
+ }\r
+ })();\r
+}\r