2
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
3
* Copyright (C) 2003-2007 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
* Creation and initialization of the "FCK" object. This is the main object
22
* that represents an editor instance.
25
// FCK represents the active editor instance.
28
Name : FCKURLParams[ 'InstanceName' ],
29
Status : FCK_STATUS_NOTLOADED,
30
EditMode : FCK_EDITMODE_WYSIWYG,
34
AttachToOnSelectionChange : function( functionPointer )
36
this.Events.AttachEvent( 'OnSelectionChange', functionPointer ) ;
39
GetLinkedFieldValue : function()
41
return this.LinkedField.value ;
44
GetParentForm : function()
46
return this.LinkedField.form ;
49
// # START : IsDirty implementation
55
if ( this.EditMode == FCK_EDITMODE_SOURCE )
56
return ( this.StartupValue != this.EditingArea.Textarea.value ) ;
58
return ( this.StartupValue != this.EditorDocument.body.innerHTML ) ;
61
ResetIsDirty : function()
63
if ( this.EditMode == FCK_EDITMODE_SOURCE )
64
this.StartupValue = this.EditingArea.Textarea.value ;
65
else if ( this.EditorDocument.body )
66
this.StartupValue = this.EditorDocument.body.innerHTML ;
69
// # END : IsDirty implementation
71
StartEditor : function()
73
this.TempBaseTag = FCKConfig.BaseHref.length > 0 ? '<base href="' + FCKConfig.BaseHref + '" _fcktemp="true"></base>' : '' ;
75
// Setup the keystroke handler.
76
var oKeystrokeHandler = FCK.KeystrokeHandler = new FCKKeystrokeHandler() ;
77
oKeystrokeHandler.OnKeystroke = _FCK_KeystrokeHandler_OnKeystroke ;
79
oKeystrokeHandler.SetKeystrokes( FCKConfig.Keystrokes ) ;
81
// In IE7, if the editor tries to access the clipboard by code, a dialog is
82
// shown to the user asking if the application is allowed to access or not.
83
// Due to the IE implementation of it, the KeystrokeHandler will not work
84
//well in this case, so we must leave the pasting keys to have their default behavior.
85
if ( FCKBrowserInfo.IsIE7 )
87
if ( ( CTRL + 86 /*V*/ ) in oKeystrokeHandler.Keystrokes )
88
oKeystrokeHandler.SetKeystrokes( [ CTRL + 86, true ] ) ;
90
if ( ( SHIFT + 45 /*INS*/ ) in oKeystrokeHandler.Keystrokes )
91
oKeystrokeHandler.SetKeystrokes( [ SHIFT + 45, true ] ) ;
94
this.EditingArea = new FCKEditingArea( document.getElementById( 'xEditingArea' ) ) ;
95
this.EditingArea.FFSpellChecker = FCKConfig.FirefoxSpellChecker ;
97
// Final setup of the lists lib.
100
// Set the editor's startup contents
101
this.SetHTML( this.GetLinkedFieldValue(), true ) ;
106
FCK.EditingArea.Focus() ;
109
SetStatus : function( newStatus )
111
this.Status = newStatus ;
113
if ( newStatus == FCK_STATUS_ACTIVE )
115
FCKFocusManager.AddWindow( window, true ) ;
117
if ( FCKBrowserInfo.IsIE )
118
FCKFocusManager.AddWindow( window.frameElement, true ) ;
120
// Force the focus in the editor.
121
if ( FCKConfig.StartupFocus )
125
this.Events.FireEvent( 'OnStatusChange', newStatus ) ;
128
// Fixes the body by moving all inline and text nodes to appropriate block
132
var sBlockTag = FCKConfig.EnterMode ;
134
// In 'br' mode, no fix must be done.
135
if ( sBlockTag != 'p' && sBlockTag != 'div' )
138
var oDocument = this.EditorDocument ;
143
var oBody = oDocument.body ;
148
FCKDomTools.TrimNode( oBody ) ;
150
var oNode = oBody.firstChild ;
155
var bMoveNode = false ;
157
switch ( oNode.nodeType )
161
if ( !FCKListsLib.BlockElements[ oNode.nodeName.toLowerCase() ] )
167
// Ignore space only or empty text.
168
if ( oNewBlock || oNode.nodeValue.Trim().length > 0 )
174
var oParent = oNode.parentNode ;
177
oNewBlock = oParent.insertBefore( oDocument.createElement( sBlockTag ), oNode ) ;
179
oNewBlock.appendChild( oParent.removeChild( oNode ) ) ;
181
oNode = oNewBlock.nextSibling ;
187
FCKDomTools.TrimNode( oNewBlock ) ;
190
oNode = oNode.nextSibling ;
195
FCKDomTools.TrimNode( oNewBlock ) ;
198
GetXHTML : function( format )
200
// We assume that if the user is in source editing, the editor value must
201
// represent the exact contents of the source, as the user wanted it to be.
202
if ( FCK.EditMode == FCK_EDITMODE_SOURCE )
203
return FCK.EditingArea.Textarea.value ;
208
var oDoc = FCK.EditorDocument ;
213
if ( FCKConfig.FullPage )
215
sXHTML = FCKXHtml.GetXHTML( oDoc.getElementsByTagName( 'html' )[0], true, format ) ;
217
if ( FCK.DocTypeDeclaration && FCK.DocTypeDeclaration.length > 0 )
218
sXHTML = FCK.DocTypeDeclaration + '\n' + sXHTML ;
220
if ( FCK.XmlDeclaration && FCK.XmlDeclaration.length > 0 )
221
sXHTML = FCK.XmlDeclaration + '\n' + sXHTML ;
225
sXHTML = FCKXHtml.GetXHTML( oDoc.body, false, format ) ;
227
if ( FCKConfig.IgnoreEmptyParagraphValue && FCKRegexLib.EmptyOutParagraph.test( sXHTML ) )
231
// Restore protected attributes.
232
sXHTML = FCK.ProtectEventsRestore( sXHTML ) ;
234
if ( FCKBrowserInfo.IsIE )
235
sXHTML = sXHTML.replace( FCKRegexLib.ToReplace, '$1' ) ;
237
return FCKConfig.ProtectedSource.Revert( sXHTML ) ;
240
UpdateLinkedField : function()
242
FCK.LinkedField.value = FCK.GetXHTML( FCKConfig.FormatOutput ) ;
243
FCK.Events.FireEvent( 'OnAfterLinkedFieldUpdate' ) ;
246
RegisteredDoubleClickHandlers : new Object(),
248
OnDoubleClick : function( element )
250
var oHandler = FCK.RegisteredDoubleClickHandlers[ element.tagName ] ;
252
oHandler( element ) ;
255
// Register objects that can handle double click operations.
256
RegisterDoubleClickHandler : function( handlerFunction, tag )
258
FCK.RegisteredDoubleClickHandlers[ tag.toUpperCase() ] = handlerFunction ;
261
OnAfterSetHTML : function()
263
FCKDocumentProcessor.Process( FCK.EditorDocument ) ;
264
FCKUndo.SaveUndoStep() ;
266
FCK.Events.FireEvent( 'OnSelectionChange' ) ;
267
FCK.Events.FireEvent( 'OnAfterSetHTML' ) ;
270
// Saves URLs on links and images on special attributes, so they don't change when
272
ProtectUrls : function( html )
275
html = html.replace( FCKRegexLib.ProtectUrlsA , '$& _fcksavedurl=$1' ) ;
278
html = html.replace( FCKRegexLib.ProtectUrlsImg , '$& _fcksavedurl=$1' ) ;
283
// Saves event attributes (like onclick) so they don't get executed while
285
ProtectEvents : function( html )
287
return html.replace( FCKRegexLib.TagsWithEvent, _FCK_ProtectEvents_ReplaceTags ) ;
290
ProtectEventsRestore : function( html )
292
return html.replace( FCKRegexLib.ProtectedEvents, _FCK_ProtectEvents_RestoreEvents ) ;
295
ProtectTags : function( html )
297
var sTags = FCKConfig.ProtectedTags ;
299
// IE doesn't support <abbr> and it breaks it. Let's protect it.
300
if ( FCKBrowserInfo.IsIE )
301
sTags += sTags.length > 0 ? '|ABBR|XML' : 'ABBR|XML' ;
304
if ( sTags.length > 0 )
306
oRegex = new RegExp( '<(' + sTags + ')(?!\w|:)', 'gi' ) ;
307
html = html.replace( oRegex, '<FCK:$1' ) ;
309
oRegex = new RegExp( '<\/(' + sTags + ')>', 'gi' ) ;
310
html = html.replace( oRegex, '<\/FCK:$1>' ) ;
313
// Protect some empty elements. We must do it separately becase the
314
// original tag may not contain the closing slash, like <hr>:
315
// - <meta> tags get executed, so if you have a redirect meta, the
316
// content will move to the target page.
317
// - <hr> may destroy the document structure if not well
318
// positioned. The trick is protect it here and restore them in
319
// the FCKDocumentProcessor.
321
if ( FCKBrowserInfo.IsIE )
324
oRegex = new RegExp( '<((' + sTags + ')(?=\\s|>|/)[\\s\\S]*?)/?>', 'gi' ) ;
325
html = html.replace( oRegex, '<FCK:$1 />' ) ;
330
SetHTML : function( html, resetIsDirty )
332
this.EditingArea.Mode = FCK.EditMode ;
334
if ( FCK.EditMode == FCK_EDITMODE_WYSIWYG )
336
html = FCKConfig.ProtectedSource.Protect( html ) ;
338
// Fix for invalid self-closing tags (see #152).
339
html = html.replace( FCKRegexLib.InvalidSelfCloseTags, '$1></$2>' ) ;
341
html = FCK.ProtectEvents( html ) ;
342
html = FCK.ProtectUrls( html ) ;
343
html = FCK.ProtectTags( html ) ;
345
// Firefox can't handle correctly the editing of the STRONG and EM tags.
346
// We must replace them with B and I.
347
if ( FCKBrowserInfo.IsGecko )
349
html = html.replace( FCKRegexLib.StrongOpener, '<b$1' ) ;
350
html = html.replace( FCKRegexLib.StrongCloser, '<\/b>' ) ;
351
html = html.replace( FCKRegexLib.EmOpener, '<i$1' ) ;
352
html = html.replace( FCKRegexLib.EmCloser, '<\/i>' ) ;
355
this._ForceResetIsDirty = ( resetIsDirty === true ) ;
359
if ( FCKConfig.FullPage )
361
// The HTML must be fixed if the <head> is not available.
362
if ( !FCKRegexLib.HeadOpener.test( html ) )
364
// Check if the <html> is available.
365
if ( !FCKRegexLib.HtmlOpener.test( html ) )
366
html = '<html dir="' + FCKConfig.ContentLangDirection + '">' + html + '</html>' ;
369
html = html.replace( FCKRegexLib.HtmlOpener, '$&<head></head>' ) ;
373
FCK.DocTypeDeclaration = html.match( FCKRegexLib.DocTypeTag ) ;
375
if ( FCKBrowserInfo.IsIE )
376
sHtml = FCK._GetBehaviorsStyle() ;
377
else if ( FCKConfig.ShowBorders )
378
sHtml = '<link href="' + FCKConfig.FullBasePath + 'css/fck_showtableborders_gecko.css" rel="stylesheet" type="text/css" _fcktemp="true" />' ;
380
sHtml += '<link href="' + FCKConfig.FullBasePath + 'css/fck_internal.css' + '" rel="stylesheet" type="text/css" _fcktemp="true" />' ;
382
// Attention: do not change it before testing it well (sample07)!
383
// This is tricky... if the head ends with <meta ... content type>,
384
// Firefox will break. But, it works if we include the temporary
385
// links as the last elements in the HEAD.
386
sHtml = html.replace( FCKRegexLib.HeadCloser, sHtml + '$&' ) ;
388
// Insert the base tag (FCKConfig.BaseHref), if not exists in the source.
389
// The base must be the first tag in the HEAD, to get relative
390
// links on styles, for example.
391
if ( FCK.TempBaseTag.length > 0 && !FCKRegexLib.HasBaseTag.test( html ) )
392
sHtml = sHtml.replace( FCKRegexLib.HeadOpener, '$&' + FCK.TempBaseTag ) ;
398
'<html dir="' + FCKConfig.ContentLangDirection + '"' ;
400
// On IE, if you are use a DOCTYPE differenft of HTML 4 (like
401
// XHTML), you must force the vertical scroll to show, otherwise
402
// the horizontal one may appear when the page needs vertical scrolling.
403
if ( FCKBrowserInfo.IsIE && !FCKRegexLib.Html4DocType.test( FCKConfig.DocType ) )
404
sHtml += ' style="overflow-y: scroll"' ;
407
'><head><title></title>' +
408
_FCK_GetEditorAreaStyleTags() +
409
'<link href="' + FCKConfig.FullBasePath + 'css/fck_internal.css' + '" rel="stylesheet" type="text/css" _fcktemp="true" />' ;
411
if ( FCKBrowserInfo.IsIE )
412
sHtml += FCK._GetBehaviorsStyle() ;
413
else if ( FCKConfig.ShowBorders )
414
sHtml += '<link href="' + FCKConfig.FullBasePath + 'css/fck_showtableborders_gecko.css" rel="stylesheet" type="text/css" _fcktemp="true" />' ;
416
sHtml += FCK.TempBaseTag ;
418
// Add ID and Class to the body
419
var sBodyTag = '<body' ;
420
if ( FCKConfig.BodyId && FCKConfig.BodyId.length > 0 )
421
sBodyTag += ' id="' + FCKConfig.BodyId + '"' ;
422
if ( FCKConfig.BodyClass && FCKConfig.BodyClass.length > 0 )
423
sBodyTag += ' class="' + FCKConfig.BodyClass + '"' ;
424
sHtml += '</head>' + sBodyTag + '>' ;
426
if ( FCKBrowserInfo.IsGecko && ( html.length == 0 || FCKRegexLib.EmptyParagraph.test( html ) ) )
427
sHtml += GECKO_BOGUS ;
431
sHtml += '</body></html>' ;
434
this.EditingArea.OnLoad = _FCK_EditingArea_OnLoad ;
435
this.EditingArea.Start( sHtml ) ;
439
// Remove the references to the following elements, as the editing area
440
// IFRAME will be removed.
441
FCK.EditorWindow = null ;
442
FCK.EditorDocument = null ;
444
this.EditingArea.OnLoad = null ;
445
this.EditingArea.Start( html ) ;
447
// Enables the context menu in the textarea.
448
this.EditingArea.Textarea._FCKShowContextMenu = true ;
450
// Removes the enter key handler.
451
FCK.EnterKeyHandler = null ;
454
this.ResetIsDirty() ;
456
// Listen for keystroke events.
457
FCK.KeystrokeHandler.AttachToElement( this.EditingArea.Textarea ) ;
459
this.EditingArea.Textarea.focus() ;
461
FCK.Events.FireEvent( 'OnAfterSetHTML' ) ;
464
if ( FCKBrowserInfo.IsGecko )
468
// For the FocusManager
472
// This collection is used by the browser specific implementations to tell
473
// wich named commands must be handled separately.
474
RedirectNamedCommands : new Object(),
476
ExecuteNamedCommand : function( commandName, commandParameter, noRedirect )
478
FCKUndo.SaveUndoStep() ;
480
if ( !noRedirect && FCK.RedirectNamedCommands[ commandName ] != null )
481
FCK.ExecuteRedirectedNamedCommand( commandName, commandParameter ) ;
485
FCK.EditorDocument.execCommand( commandName, false, commandParameter ) ;
486
FCK.Events.FireEvent( 'OnSelectionChange' ) ;
489
FCKUndo.SaveUndoStep() ;
492
GetNamedCommandState : function( commandName )
497
if ( !FCK.EditorDocument.queryCommandEnabled( commandName ) )
498
return FCK_TRISTATE_DISABLED ;
500
return FCK.EditorDocument.queryCommandState( commandName ) ? FCK_TRISTATE_ON : FCK_TRISTATE_OFF ;
504
return FCK_TRISTATE_OFF ;
508
GetNamedCommandValue : function( commandName )
511
var eState = FCK.GetNamedCommandState( commandName ) ;
513
if ( eState == FCK_TRISTATE_DISABLED )
518
sValue = this.EditorDocument.queryCommandValue( commandName ) ;
522
return sValue ? sValue : '' ;
525
PasteFromWord : function()
527
FCKDialog.OpenDialog( 'FCKDialog_Paste', FCKLang.PasteFromWord, 'dialog/fck_paste.html', 400, 330, 'Word' ) ;
532
var iWidth = FCKConfig.ScreenWidth * 0.8 ;
533
var iHeight = FCKConfig.ScreenHeight * 0.7 ;
534
var iLeft = ( FCKConfig.ScreenWidth - iWidth ) / 2 ;
535
var oWindow = window.open( '', null, 'toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=' + iWidth + ',height=' + iHeight + ',left=' + iLeft ) ;
539
if ( FCKConfig.FullPage )
541
if ( FCK.TempBaseTag.length > 0 )
542
sHTML = FCK.TempBaseTag + FCK.GetXHTML() ;
544
sHTML = FCK.GetXHTML() ;
550
'<html dir="' + FCKConfig.ContentLangDirection + '">' +
553
'<title>' + FCKLang.Preview + '</title>' +
554
_FCK_GetEditorAreaStyleTags() +
560
oWindow.document.write( sHTML );
561
oWindow.document.close();
564
SwitchEditMode : function( noUndo )
566
var bIsWysiwyg = ( FCK.EditMode == FCK_EDITMODE_WYSIWYG ) ;
568
// Save the current IsDirty state, so we may restore it after the switch.
569
var bIsDirty = FCK.IsDirty() ;
573
// Update the HTML in the view output to show.
576
if ( !noUndo && FCKBrowserInfo.IsIE )
577
FCKUndo.SaveUndoStep() ;
579
sHtml = FCK.GetXHTML( FCKConfig.FormatSource ) ;
585
sHtml = this.EditingArea.Textarea.value ;
587
FCK.EditMode = bIsWysiwyg ? FCK_EDITMODE_SOURCE : FCK_EDITMODE_WYSIWYG ;
589
FCK.SetHTML( sHtml, !bIsDirty ) ;
594
// Update the toolbar (Running it directly causes IE to fail).
595
FCKTools.RunFunction( FCK.ToolbarSet.RefreshModeState, FCK.ToolbarSet ) ;
600
CreateElement : function( tag )
602
var e = FCK.EditorDocument.createElement( tag ) ;
603
return FCK.InsertElementAndGetIt( e ) ;
606
InsertElementAndGetIt : function( e )
608
e.setAttribute( 'FCKTempLabel', 'true' ) ;
610
this.InsertElement( e ) ;
612
var aEls = FCK.EditorDocument.getElementsByTagName( e.tagName ) ;
614
for ( var i = 0 ; i < aEls.length ; i++ )
616
if ( aEls[i].getAttribute( 'FCKTempLabel' ) )
618
aEls[i].removeAttribute( 'FCKTempLabel' ) ;
627
FCK.Events = new FCKEvents( FCK ) ;
628
// GetHTML is Deprecated : returns the same value as GetXHTML.
629
FCK.GetHTML = FCK.GetXHTML ;
631
// Replace all events attributes (like onclick).
632
function _FCK_ProtectEvents_ReplaceTags( tagMatch )
634
return tagMatch.replace( FCKRegexLib.EventAttributes, _FCK_ProtectEvents_ReplaceEvents ) ;
637
// Replace an event attribute with its respective __fckprotectedatt attribute.
638
// The original event markup will be encoded and saved as the value of the new
640
function _FCK_ProtectEvents_ReplaceEvents( eventMatch, attName )
642
return ' ' + attName + '_fckprotectedatt="' + eventMatch.ReplaceAll( [/&/g,/'/g,/"/g,/=/g,/</g,/>/g,/\r/g,/\n/g], [''',''','"','=','<','>',' ',' '] ) + '"' ;
645
function _FCK_ProtectEvents_RestoreEvents( match, encodedOriginal )
647
return encodedOriginal.ReplaceAll( [/'/g,/"/g,/=/g,/</g,/>/g,/ /g,/ /g,/'/g], ["'",'"','=','<','>','\r','\n','&'] ) ;
650
function _FCK_EditingArea_OnLoad()
652
// Get the editor's window and document (DOM)
653
FCK.EditorWindow = FCK.EditingArea.Window ;
654
FCK.EditorDocument = FCK.EditingArea.Document ;
656
FCK.InitializeBehaviors() ;
658
// Create the enter key handler
659
if ( !FCKConfig.DisableEnterKeyHandler )
660
FCK.EnterKeyHandler = new FCKEnterKey( FCK.EditorWindow, FCKConfig.EnterMode, FCKConfig.ShiftEnterMode ) ;
662
// Listen for keystroke events.
663
FCK.KeystrokeHandler.AttachToElement( FCK.EditorDocument ) ;
665
if ( FCK._ForceResetIsDirty )
668
// This is a tricky thing for IE. In some cases, even if the cursor is
669
// blinking in the editing, the keystroke handler doesn't catch keyboard
670
// events. We must activate the editing area to make it work. (#142).
671
if ( FCKBrowserInfo.IsIE && FCK.HasFocus )
672
FCK.EditorDocument.body.setActive() ;
674
FCK.OnAfterSetHTML() ;
676
// Check if it is not a startup call, otherwise complete the startup.
677
if ( FCK.Status != FCK_STATUS_NOTLOADED )
680
FCK.SetStatus( FCK_STATUS_ACTIVE ) ;
683
function _FCK_GetEditorAreaStyleTags()
686
var aCSSs = FCKConfig.EditorAreaCSS ;
688
for ( var i = 0 ; i < aCSSs.length ; i++ )
689
sTags += '<link href="' + aCSSs[i] + '" rel="stylesheet" type="text/css" />' ;
694
function _FCK_KeystrokeHandler_OnKeystroke( keystroke, keystrokeValue )
696
if ( FCK.Status != FCK_STATUS_COMPLETE )
699
if ( FCK.EditMode == FCK_EDITMODE_WYSIWYG )
701
if ( keystrokeValue == 'Paste' )
702
return !FCK.Events.FireEvent( 'OnPaste' ) ;
706
// In source mode, some actions must have their default behavior.
707
if ( keystrokeValue.Equals( 'Paste', 'Undo', 'Redo', 'SelectAll' ) )
711
// The return value indicates if the default behavior of the keystroke must
712
// be cancelled. Let's do that only if the Execute() call explicitelly returns "false".
713
var oCommand = FCK.Commands.GetCommand( keystrokeValue ) ;
714
return ( oCommand.Execute.apply( oCommand, FCKTools.ArgumentsToArray( arguments, 2 ) ) !== false ) ;
717
// Set the FCK.LinkedField reference to the field that will be used to post the
721
// There is a bug on IE... getElementById returns any META tag that has the
722
// name set to the ID you are looking for. So the best way in to get the array
723
// by names and look for the correct one.
724
// As ASP.Net generates a ID that is different from the Name, we must also
725
// look for the field based on the ID (the first one is the ID).
727
var oDocument = window.parent.document ;
729
// Try to get the field using the ID.
730
var eLinkedField = oDocument.getElementById( FCK.Name ) ;
733
while ( eLinkedField || i == 0 )
735
if ( eLinkedField && eLinkedField.tagName.toLowerCase().Equals( 'input', 'textarea' ) )
737
FCK.LinkedField = eLinkedField ;
741
eLinkedField = oDocument.getElementsByName( FCK.Name )[i++] ;
747
Elements : new Array(),
749
AddElement : function( element )
751
var iIndex = this.Elements.length ;
752
this.Elements[ iIndex ] = element ;
756
RemoveElement : function( index )
758
var e = this.Elements[ index ] ;
759
this.Elements[ index ] = null ;
766
while ( i < this.Elements.length )
767
this.Elements[ i++ ] = null ;
768
this.Elements.length = 0 ;
774
// # Focus Manager: Manages the focus in the editor.
775
var FCKFocusManager = FCK.FocusManager =
779
AddWindow : function( win, sendToEditingArea )
783
if ( FCKBrowserInfo.IsIE )
784
oTarget = win.nodeType == 1 ? win : win.frameElement ? win.frameElement : win.document ;
786
oTarget = win.document ;
788
FCKTools.AddEventListener( oTarget, 'blur', FCKFocusManager_Win_OnBlur ) ;
789
FCKTools.AddEventListener( oTarget, 'focus', sendToEditingArea ? FCKFocusManager_Win_OnFocus_Area : FCKFocusManager_Win_OnFocus ) ;
792
RemoveWindow : function( win )
794
if ( FCKBrowserInfo.IsIE )
795
oTarget = win.nodeType == 1 ? win : win.frameElement ? win.frameElement : win.document ;
797
oTarget = win.document ;
799
FCKTools.RemoveEventListener( oTarget, 'blur', FCKFocusManager_Win_OnBlur ) ;
800
FCKTools.RemoveEventListener( oTarget, 'focus', FCKFocusManager_Win_OnFocus_Area ) ;
801
FCKTools.RemoveEventListener( oTarget, 'focus', FCKFocusManager_Win_OnFocus ) ;
806
this.IsLocked = true ;
811
if ( this._HasPendingBlur )
812
FCKFocusManager._Timer = window.setTimeout( FCKFocusManager_FireOnBlur, 100 ) ;
814
this.IsLocked = false ;
817
_ResetTimer : function()
819
this._HasPendingBlur = false ;
823
window.clearTimeout( this._Timer ) ;
829
function FCKFocusManager_Win_OnBlur()
831
if ( typeof(FCK) != 'undefined' && FCK.HasFocus )
833
FCKFocusManager._ResetTimer() ;
834
FCKFocusManager._Timer = window.setTimeout( FCKFocusManager_FireOnBlur, 100 ) ;
838
function FCKFocusManager_FireOnBlur()
840
if ( FCKFocusManager.IsLocked )
841
FCKFocusManager._HasPendingBlur = true ;
844
FCK.HasFocus = false ;
845
FCK.Events.FireEvent( "OnBlur" ) ;
849
function FCKFocusManager_Win_OnFocus_Area()
852
FCKFocusManager_Win_OnFocus() ;
855
function FCKFocusManager_Win_OnFocus()
857
FCKFocusManager._ResetTimer() ;
859
if ( !FCK.HasFocus && !FCKFocusManager.IsLocked )
861
FCK.HasFocus = true ;
862
FCK.Events.FireEvent( "OnFocus" ) ;