+++ /dev/null
-/*\r
- * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
- * Copyright (C) 2003-2009 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
- * Creation and initialization of the "FCK" object. This is the main\r
- * object that represents an editor instance.\r
- * (IE specific implementations)\r
- */\r
-\r
-FCK.Description = "FCKeditor for Internet Explorer 5.5+" ;\r
-\r
-FCK._GetBehaviorsStyle = function()\r
-{\r
- if ( !FCK._BehaviorsStyle )\r
- {\r
- var sBasePath = FCKConfig.BasePath ;\r
- var sTableBehavior = '' ;\r
- var sStyle ;\r
-\r
- // The behaviors should be pointed using the BasePath to avoid security\r
- // errors when using a different BaseHref.\r
- sStyle = '<style type="text/css" _fcktemp="true">' ;\r
-\r
- if ( FCKConfig.ShowBorders )\r
- sTableBehavior = 'url(' + sBasePath + 'css/behaviors/showtableborders.htc)' ;\r
-\r
- // Disable resize handlers.\r
- sStyle += 'INPUT,TEXTAREA,SELECT,.FCK__Anchor,.FCK__PageBreak,.FCK__InputHidden' ;\r
-\r
- if ( FCKConfig.DisableObjectResizing )\r
- {\r
- sStyle += ',IMG' ;\r
- sTableBehavior += ' url(' + sBasePath + 'css/behaviors/disablehandles.htc)' ;\r
- }\r
-\r
- sStyle += ' { behavior: url(' + sBasePath + 'css/behaviors/disablehandles.htc) ; }' ;\r
-\r
- if ( sTableBehavior.length > 0 )\r
- sStyle += 'TABLE { behavior: ' + sTableBehavior + ' ; }' ;\r
-\r
- sStyle += '</style>' ;\r
- FCK._BehaviorsStyle = sStyle ;\r
- }\r
-\r
- return FCK._BehaviorsStyle ;\r
-}\r
-\r
-function Doc_OnMouseUp()\r
-{\r
- if ( FCK.EditorWindow.event.srcElement.tagName == 'HTML' )\r
- {\r
- FCK.Focus() ;\r
- FCK.EditorWindow.event.cancelBubble = true ;\r
- FCK.EditorWindow.event.returnValue = false ;\r
- }\r
-}\r
-\r
-function Doc_OnPaste()\r
-{\r
- var body = FCK.EditorDocument.body ;\r
-\r
- body.detachEvent( 'onpaste', Doc_OnPaste ) ;\r
-\r
- var ret = FCK.Paste( !FCKConfig.ForcePasteAsPlainText && !FCKConfig.AutoDetectPasteFromWord ) ;\r
-\r
- body.attachEvent( 'onpaste', Doc_OnPaste ) ;\r
-\r
- return ret ;\r
-}\r
-\r
-function Doc_OnDblClick()\r
-{\r
- FCK.OnDoubleClick( FCK.EditorWindow.event.srcElement ) ;\r
- FCK.EditorWindow.event.cancelBubble = true ;\r
-}\r
-\r
-function Doc_OnSelectionChange()\r
-{\r
- // Don't fire the event if no document is loaded.\r
- if ( !FCK.IsSelectionChangeLocked && FCK.EditorDocument )\r
- FCK.Events.FireEvent( "OnSelectionChange" ) ;\r
-}\r
-\r
-function Doc_OnDrop()\r
-{\r
- if ( FCK.MouseDownFlag )\r
- {\r
- FCK.MouseDownFlag = false ;\r
- return ;\r
- }\r
-\r
- if ( FCKConfig.ForcePasteAsPlainText )\r
- {\r
- var evt = FCK.EditorWindow.event ;\r
-\r
- if ( FCK._CheckIsPastingEnabled() || FCKConfig.ShowDropDialog )\r
- FCK.PasteAsPlainText( evt.dataTransfer.getData( 'Text' ) ) ;\r
-\r
- evt.returnValue = false ;\r
- evt.cancelBubble = true ;\r
- }\r
-}\r
-\r
-FCK.InitializeBehaviors = function( dontReturn )\r
-{\r
- // Set the focus to the editable area when clicking in the document area.\r
- // TODO: The cursor must be positioned at the end.\r
- this.EditorDocument.attachEvent( 'onmouseup', Doc_OnMouseUp ) ;\r
-\r
- // Intercept pasting operations\r
- this.EditorDocument.body.attachEvent( 'onpaste', Doc_OnPaste ) ;\r
-\r
- // Intercept drop operations\r
- this.EditorDocument.body.attachEvent( 'ondrop', Doc_OnDrop ) ;\r
-\r
- // Reset the context menu.\r
- FCK.ContextMenu._InnerContextMenu.AttachToElement( FCK.EditorDocument.body ) ;\r
-\r
- this.EditorDocument.attachEvent("onkeydown", FCK._KeyDownListener ) ;\r
-\r
- this.EditorDocument.attachEvent("ondblclick", Doc_OnDblClick ) ;\r
-\r
- this.EditorDocument.attachEvent("onbeforedeactivate", function(){ FCKSelection.Save() ; } ) ;\r
-\r
- // Catch cursor selection changes.\r
- this.EditorDocument.attachEvent("onselectionchange", Doc_OnSelectionChange ) ;\r
-\r
- FCKTools.AddEventListener( FCK.EditorDocument, 'mousedown', Doc_OnMouseDown ) ;\r
-}\r
-\r
-FCK.InsertHtml = function( html )\r
-{\r
- html = FCKConfig.ProtectedSource.Protect( html ) ;\r
- html = FCK.ProtectEvents( html ) ;\r
- html = FCK.ProtectUrls( html ) ;\r
- html = FCK.ProtectTags( html ) ;\r
-\r
-// FCK.Focus() ;\r
- FCKSelection.Restore() ;\r
- FCK.EditorWindow.focus() ;\r
-\r
- FCKUndo.SaveUndoStep() ;\r
-\r
- // Gets the actual selection.\r
- var oSel = FCKSelection.GetSelection() ;\r
-\r
- // Deletes the actual selection contents.\r
- if ( oSel.type.toLowerCase() == 'control' )\r
- oSel.clear() ;\r
-\r
- // Using the following trick, any comment in the beginning of the HTML will\r
- // be preserved.\r
- html = '<span id="__fakeFCKRemove__" style="display:none;">fakeFCKRemove</span>' + html ;\r
-\r
- // Insert the HTML.\r
- oSel.createRange().pasteHTML( html ) ;\r
-\r
- // Remove the fake node\r
- FCK.EditorDocument.getElementById('__fakeFCKRemove__').removeNode( true ) ;\r
-\r
- FCKDocumentProcessor.Process( FCK.EditorDocument ) ;\r
-\r
- // For some strange reason the SaveUndoStep() call doesn't activate the undo button at the first InsertHtml() call.\r
- this.Events.FireEvent( "OnSelectionChange" ) ;\r
-}\r
-\r
-FCK.SetInnerHtml = function( html ) // IE Only\r
-{\r
- var oDoc = FCK.EditorDocument ;\r
- // Using the following trick, any comment in the beginning of the HTML will\r
- // be preserved.\r
- oDoc.body.innerHTML = '<div id="__fakeFCKRemove__"> </div>' + html ;\r
- oDoc.getElementById('__fakeFCKRemove__').removeNode( true ) ;\r
-}\r
-\r
-function FCK_PreloadImages()\r
-{\r
- var oPreloader = new FCKImagePreloader() ;\r
-\r
- // Add the configured images.\r
- oPreloader.AddImages( FCKConfig.PreloadImages ) ;\r
-\r
- // Add the skin icons strip.\r
- oPreloader.AddImages( FCKConfig.SkinPath + 'fck_strip.gif' ) ;\r
-\r
- oPreloader.OnComplete = LoadToolbarSetup ;\r
- oPreloader.Start() ;\r
-}\r
-\r
-// Disable the context menu in the editor (outside the editing area).\r
-function Document_OnContextMenu()\r
-{\r
- return ( event.srcElement._FCKShowContextMenu == true ) ;\r
-}\r
-document.oncontextmenu = Document_OnContextMenu ;\r
-\r
-function FCK_Cleanup()\r
-{\r
- this.LinkedField = null ;\r
- this.EditorWindow = null ;\r
- this.EditorDocument = null ;\r
-}\r
-\r
-FCK._ExecPaste = function()\r
-{\r
- // As we call ExecuteNamedCommand('Paste'), it would enter in a loop. So, let's use a semaphore.\r
- if ( FCK._PasteIsRunning )\r
- return true ;\r
-\r
- if ( FCKConfig.ForcePasteAsPlainText )\r
- {\r
- FCK.PasteAsPlainText() ;\r
- return false ;\r
- }\r
-\r
- var sHTML = FCK._CheckIsPastingEnabled( true ) ;\r
-\r
- if ( sHTML === false )\r
- FCKTools.RunFunction( FCKDialog.OpenDialog, FCKDialog, ['FCKDialog_Paste', FCKLang.Paste, 'dialog/fck_paste.html', 400, 330, 'Security'] ) ;\r
- else\r
- {\r
- if ( FCKConfig.AutoDetectPasteFromWord && sHTML.length > 0 )\r
- {\r
- var re = /<\w[^>]*(( class="?MsoNormal"?)|(="mso-))/gi ;\r
- if ( re.test( sHTML ) )\r
- {\r
- if ( confirm( FCKLang.PasteWordConfirm ) )\r
- {\r
- FCK.PasteFromWord() ;\r
- return false ;\r
- }\r
- }\r
- }\r
-\r
- // Instead of inserting the retrieved HTML, let's leave the OS work for us,\r
- // by calling FCK.ExecuteNamedCommand( 'Paste' ). It could give better results.\r
-\r
- // Enable the semaphore to avoid a loop.\r
- FCK._PasteIsRunning = true ;\r
-\r
- FCK.ExecuteNamedCommand( 'Paste' ) ;\r
-\r
- // Removes the semaphore.\r
- delete FCK._PasteIsRunning ;\r
- }\r
-\r
- // Let's always make a custom implementation (return false), otherwise\r
- // the new Keyboard Handler may conflict with this code, and the CTRL+V code\r
- // could result in a simple "V" being pasted.\r
- return false ;\r
-}\r
-\r
-FCK.PasteAsPlainText = function( forceText )\r
-{\r
- if ( !FCK._CheckIsPastingEnabled() )\r
- {\r
- FCKDialog.OpenDialog( 'FCKDialog_Paste', FCKLang.PasteAsText, 'dialog/fck_paste.html', 400, 330, 'PlainText' ) ;\r
- return ;\r
- }\r
-\r
- // Get the data available in the clipboard in text format.\r
- var sText = null ;\r
- if ( ! forceText )\r
- sText = clipboardData.getData("Text") ;\r
- else\r
- sText = forceText ;\r
-\r
- if ( sText && sText.length > 0 )\r
- {\r
- // Replace the carriage returns with <BR>\r
- sText = FCKTools.HTMLEncode( sText ) ;\r
- sText = FCKTools.ProcessLineBreaks( window, FCKConfig, sText ) ;\r
-\r
- var closeTagIndex = sText.search( '</p>' ) ;\r
- var startTagIndex = sText.search( '<p>' ) ;\r
-\r
- if ( ( closeTagIndex != -1 && startTagIndex != -1 && closeTagIndex < startTagIndex )\r
- || ( closeTagIndex != -1 && startTagIndex == -1 ) )\r
- {\r
- var prefix = sText.substr( 0, closeTagIndex ) ;\r
- sText = sText.substr( closeTagIndex + 4 ) ;\r
- this.InsertHtml( prefix ) ;\r
- }\r
-\r
- // Insert the resulting data in the editor.\r
- FCKUndo.SaveLocked = true ;\r
- this.InsertHtml( sText ) ;\r
- FCKUndo.SaveLocked = false ;\r
- }\r
-}\r
-\r
-FCK._CheckIsPastingEnabled = function( returnContents )\r
-{\r
- // The following seams to be the only reliable way to check is script\r
- // pasting operations are enabled in the security settings of IE6 and IE7.\r
- // It adds a little bit of overhead to the check, but so far that's the\r
- // only way, mainly because of IE7.\r
-\r
- FCK._PasteIsEnabled = false ;\r
-\r
- document.body.attachEvent( 'onpaste', FCK_CheckPasting_Listener ) ;\r
-\r
- // The execCommand in GetClipboardHTML will fire the "onpaste", only if the\r
- // security settings are enabled.\r
- var oReturn = FCK.GetClipboardHTML() ;\r
-\r
- document.body.detachEvent( 'onpaste', FCK_CheckPasting_Listener ) ;\r
-\r
- if ( FCK._PasteIsEnabled )\r
- {\r
- if ( !returnContents )\r
- oReturn = true ;\r
- }\r
- else\r
- oReturn = false ;\r
-\r
- delete FCK._PasteIsEnabled ;\r
-\r
- return oReturn ;\r
-}\r
-\r
-function FCK_CheckPasting_Listener()\r
-{\r
- FCK._PasteIsEnabled = true ;\r
-}\r
-\r
-FCK.GetClipboardHTML = function()\r
-{\r
- var oDiv = document.getElementById( '___FCKHiddenDiv' ) ;\r
-\r
- if ( !oDiv )\r
- {\r
- oDiv = document.createElement( 'DIV' ) ;\r
- oDiv.id = '___FCKHiddenDiv' ;\r
-\r
- var oDivStyle = oDiv.style ;\r
- oDivStyle.position = 'absolute' ;\r
- oDivStyle.visibility = oDivStyle.overflow = 'hidden' ;\r
- oDivStyle.width = oDivStyle.height = 1 ;\r
-\r
- document.body.appendChild( oDiv ) ;\r
- }\r
-\r
- oDiv.innerHTML = '' ;\r
-\r
- var oTextRange = document.body.createTextRange() ;\r
- oTextRange.moveToElementText( oDiv ) ;\r
- oTextRange.execCommand( 'Paste' ) ;\r
-\r
- var sData = oDiv.innerHTML ;\r
- oDiv.innerHTML = '' ;\r
-\r
- return sData ;\r
-}\r
-\r
-FCK.CreateLink = function( url, noUndo )\r
-{\r
- // Creates the array that will be returned. It contains one or more created links (see #220).\r
- var aCreatedLinks = new Array() ;\r
-\r
- // Remove any existing link in the selection.\r
- FCK.ExecuteNamedCommand( 'Unlink', null, false, !!noUndo ) ;\r
-\r
- if ( url.length > 0 )\r
- {\r
- // If there are several images, and you try to link each one, all the images get inside the link:\r
- // <img><img> -> <a><img></a><img> -> <a><img><img></a> due to the call to 'CreateLink' (bug in IE)\r
- if (FCKSelection.GetType() == 'Control')\r
- {\r
- // Create a link\r
- var oLink = this.EditorDocument.createElement( 'A' ) ;\r
- oLink.href = url ;\r
-\r
- // Get the selected object\r
- var oControl = FCKSelection.GetSelectedElement() ;\r
- // Put the link just before the object\r
- oControl.parentNode.insertBefore(oLink, oControl) ;\r
- // Move the object inside the link\r
- oControl.parentNode.removeChild( oControl ) ;\r
- oLink.appendChild( oControl ) ;\r
-\r
- return [ oLink ] ;\r
- }\r
-\r
- // Generate a temporary name for the link.\r
- var sTempUrl = 'javascript:void(0);/*' + ( new Date().getTime() ) + '*/' ;\r
-\r
- // Use the internal "CreateLink" command to create the link.\r
- FCK.ExecuteNamedCommand( 'CreateLink', sTempUrl, false, !!noUndo ) ;\r
-\r
- // Look for the just create link.\r
- var oLinks = this.EditorDocument.links ;\r
-\r
- for ( i = 0 ; i < oLinks.length ; i++ )\r
- {\r
- var oLink = oLinks[i] ;\r
-\r
- // Check it this a newly created link.\r
- // getAttribute must be used. oLink.url may cause problems with IE7 (#555).\r
- if ( oLink.getAttribute( 'href', 2 ) == sTempUrl )\r
- {\r
- var sInnerHtml = oLink.innerHTML ; // Save the innerHTML (IE changes it if it is like an URL).\r
- oLink.href = url ;\r
- oLink.innerHTML = sInnerHtml ; // Restore the innerHTML.\r
-\r
- // If the last child is a <br> move it outside the link or it\r
- // will be too easy to select this link again #388.\r
- var oLastChild = oLink.lastChild ;\r
- if ( oLastChild && oLastChild.nodeName == 'BR' )\r
- {\r
- // Move the BR after the link.\r
- FCKDomTools.InsertAfterNode( oLink, oLink.removeChild( oLastChild ) ) ;\r
- }\r
-\r
- aCreatedLinks.push( oLink ) ;\r
- }\r
- }\r
- }\r
-\r
- return aCreatedLinks ;\r
-}\r
-\r
-function _FCK_RemoveDisabledAtt()\r
-{\r
- this.removeAttribute( 'disabled' ) ;\r
-}\r
-\r
-function Doc_OnMouseDown( evt )\r
-{\r
- var e = evt.srcElement ;\r
-\r
- // Radio buttons and checkboxes should not be allowed to be triggered in IE\r
- // in editable mode. Otherwise the whole browser window may be locked by\r
- // the buttons. (#1782)\r
- if ( e.nodeName.IEquals( 'input' ) && e.type.IEquals( ['radio', 'checkbox'] ) && !e.disabled )\r
- {\r
- e.disabled = true ;\r
- FCKTools.SetTimeout( _FCK_RemoveDisabledAtt, 1, e ) ;\r
- }\r
-}\r