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