2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
\r
3 * Copyright (C) 2003-2010 Frederico Caldeira Knabben
\r
5 * == BEGIN LICENSE ==
\r
7 * Licensed under the terms of any of the following licenses at your
\r
10 * - GNU General Public License Version 2 or later (the "GPL")
\r
11 * http://www.gnu.org/licenses/gpl.html
\r
13 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
\r
14 * http://www.gnu.org/licenses/lgpl.html
\r
16 * - Mozilla Public License Version 1.1 or later (the "MPL")
\r
17 * http://www.mozilla.org/MPL/MPL-1.1.html
\r
21 * Compatibility code for Adobe AIR.
\r
24 if ( FCKBrowserInfo.IsAIR )
\r
26 var FCKAdobeAIR = (function()
\r
29 * ### Private functions.
\r
32 var getDocumentHead = function( doc )
\r
35 var heads = doc.getElementsByTagName( 'head' ) ;
\r
37 if( heads && heads[0] )
\r
41 head = doc.createElement( 'head' ) ;
\r
42 doc.documentElement.insertBefore( head, doc.documentElement.firstChild ) ;
\r
49 * ### Public interface.
\r
52 FCKeditorAPI_Evaluate : function( parentWindow, script )
\r
54 // TODO : This one doesn't work always. The parent window will
\r
55 // point to an anonymous function in this window. If this
\r
56 // window is destroyied the parent window will be pointing to
\r
57 // an invalid reference.
\r
59 // Evaluate the script in this window.
\r
62 // Point the FCKeditorAPI property of the parent window to the
\r
64 parentWindow.FCKeditorAPI = window.FCKeditorAPI ;
\r
67 EditingArea_Start : function( doc, html )
\r
69 // Get the HTML for the <head>.
\r
70 var headInnerHtml = html.match( /<head>([\s\S]*)<\/head>/i )[1] ;
\r
72 if ( headInnerHtml && headInnerHtml.length > 0 )
\r
74 // Inject the <head> HTML inside a <div>.
\r
75 // Do that before getDocumentHead because WebKit moves
\r
76 // <link css> elements to the <head> at this point.
\r
77 var div = doc.createElement( 'div' ) ;
\r
78 div.innerHTML = headInnerHtml ;
\r
80 // Move the <div> nodes to <head>.
\r
81 FCKDomTools.MoveChildren( div, getDocumentHead( doc ) ) ;
\r
84 doc.body.innerHTML = html.match( /<body>([\s\S]*)<\/body>/i )[1] ;
\r
86 //prevent clicking on hyperlinks and navigating away
\r
87 doc.addEventListener('click', function( ev )
\r
89 ev.preventDefault() ;
\r
90 ev.stopPropagation() ;
\r
94 Panel_Contructor : function( doc, baseLocation )
\r
96 var head = getDocumentHead( doc ) ;
\r
98 // Set the <base> href.
\r
99 head.appendChild( doc.createElement('base') ).href = baseLocation ;
\r
101 doc.body.style.margin = '0px' ;
\r
102 doc.body.style.padding = '0px' ;
\r
105 ToolbarSet_GetOutElement : function( win, outMatch )
\r
107 var toolbarTarget = win.parent ;
\r
109 var targetWindowParts = outMatch[1].split( '.' ) ;
\r
110 while ( targetWindowParts.length > 0 )
\r
112 var part = targetWindowParts.shift() ;
\r
113 if ( part.length > 0 )
\r
114 toolbarTarget = toolbarTarget[ part ] ;
\r
117 toolbarTarget = toolbarTarget.document.getElementById( outMatch[2] ) ;
\r
120 ToolbarSet_InitOutFrame : function( doc )
\r
122 var head = getDocumentHead( doc ) ;
\r
124 head.appendChild( doc.createElement('base') ).href = window.document.location ;
\r
126 var targetWindow = doc.defaultView;
\r
128 targetWindow.adjust = function()
\r
130 targetWindow.frameElement.height = doc.body.scrollHeight;
\r
133 targetWindow.onresize = targetWindow.adjust ;
\r
134 targetWindow.setTimeout( targetWindow.adjust, 0 ) ;
\r
136 doc.body.style.overflow = 'hidden';
\r
137 doc.body.innerHTML = document.getElementById( 'xToolbarSpace' ).innerHTML ;
\r
147 // Save references for override reuse.
\r
148 var _Original_FCKPanel_Window_OnFocus = FCKPanel_Window_OnFocus ;
\r
149 var _Original_FCKPanel_Window_OnBlur = FCKPanel_Window_OnBlur ;
\r
150 var _Original_FCK_StartEditor = FCK.StartEditor ;
\r
152 FCKPanel_Window_OnFocus = function( e, panel )
\r
154 // Call the original implementation.
\r
155 _Original_FCKPanel_Window_OnFocus.call( this, e, panel ) ;
\r
157 if ( panel._focusTimer )
\r
158 clearTimeout( panel._focusTimer ) ;
\r
161 FCKPanel_Window_OnBlur = function( e, panel )
\r
163 // Delay the execution of the original function.
\r
164 panel._focusTimer = FCKTools.SetTimeout( _Original_FCKPanel_Window_OnBlur, 100, this, [ e, panel ] ) ;
\r
167 FCK.StartEditor = function()
\r
169 // Force pointing to the CSS files instead of using the inline CSS cached styles.
\r
170 window.FCK_InternalCSS = FCKConfig.BasePath + 'css/fck_internal.css' ;
\r
171 window.FCK_ShowTableBordersCSS = FCKConfig.BasePath + 'css/fck_showtableborders_gecko.css' ;
\r
173 _Original_FCK_StartEditor.apply( this, arguments ) ;
\r