Ticket #123: 123.patch

File 123.patch, 33.7 KB (added by Frederico Caldeira Knabben, 17 years ago)

Proposal patch

  • editor/_source/classes/fckeditingarea.js

     
    5757
    5858        if ( this.Mode == FCK_EDITMODE_WYSIWYG )
    5959        {
    60                 // Create the editing area IFRAME.
    61                 var oIFrame = this.IFrame = oTargetDocument.createElement( 'iframe' ) ;
    62                
    63                 // Firefox will render the tables inside the body in Quirks mode if the
    64                 // source of the iframe is set to javascript. see #515
    65                 if ( !FCKBrowserInfo.IsGecko )
    66                         oIFrame.src = 'javascript:void(0)' ;
    67                
    68                 oIFrame.frameBorder = 0 ;
    69                 oIFrame.width = oIFrame.height = '100%' ;
     60                // For FF, document.domain must be set only when different, otherwhise
     61                // we'll strangely have "Permission denied" issues.
     62                if ( FCK_IS_CUSTOM_DOMAIN )
     63                        html = '<script>document.domain="' + FCK_RUNTIME_DOMAIN + '";</script>' + html ;
    7064
    71                 // Append the new IFRAME to the target.
    72                 eTargetElement.appendChild( oIFrame ) ;
    73 
    7465                // IE has a bug with the <base> tag... it must have a </base> closer,
    7566                // otherwise the all successive tags will be set as children nodes of the <base>.
    7667                if ( FCKBrowserInfo.IsIE )
     
    10596                                this._BodyHTML = html ;                 // Invalid HTML input.
    10697                }
    10798
     99                // Create the editing area IFRAME.
     100                var oIFrame = this.IFrame = oTargetDocument.createElement( 'iframe' ) ;
     101
     102                oIFrame.frameBorder = 0 ;
     103                oIFrame.width = oIFrame.height = '100%' ;
     104
     105                if ( FCK_IS_CUSTOM_DOMAIN && FCKBrowserInfo.IsIE )
     106                {
     107                        window._FCKHtmlToLoad = html ;
     108                        oIFrame.src = 'javascript:void( (function(){' +
     109                                'document.open() ;' +
     110                                'document.domain="' + document.domain + '" ;' +
     111                                'document.write( window.parent._FCKHtmlToLoad );' +
     112                                'document.close() ;' +
     113                                'window.parent._FCKHtmlToLoad = null ;' +
     114                                '})() )' ;
     115                }
     116                else if ( !FCKBrowserInfo.IsGecko )
     117                {
     118                        // Firefox will render the tables inside the body in Quirks mode if the
     119                        // source of the iframe is set to javascript. see #515
     120                        oIFrame.src = 'javascript:void(0)' ;
     121                }
     122
     123                // Append the new IFRAME to the target. For IE, it must be done after
     124                // setting the "src", to avoid the "secure/unsecure" message under HTTPS.
     125                eTargetElement.appendChild( oIFrame ) ;
     126
    108127                // Get the window and document objects used to interact with the newly created IFRAME.
    109128                this.Window = oIFrame.contentWindow ;
    110129
     
    112131                // TODO: This error handler is not being fired.
    113132                // this.Window.onerror = function() { alert( 'Error!' ) ; return true ; }
    114133
    115                 var oDoc = this.Document = this.Window.document ;
     134                if ( !FCK_IS_CUSTOM_DOMAIN || !FCKBrowserInfo.IsIE )
     135                {
     136                        var oDoc = this.Window.document ;
    116137
    117                 oDoc.open() ;
    118                 oDoc.write( html ) ;
    119                 oDoc.close() ;
     138                        oDoc.open() ;
     139                        oDoc.write( html ) ;
     140                        oDoc.close() ;
     141                }
    120142
    121143                // Firefox 1.0.x is buggy... ohh yes... so let's do it two times and it
    122144                // will magically work.
     
    126148                        return ;
    127149                }
    128150
    129                 this.Window._FCKEditingArea = this ;
     151                if ( oIFrame.readyState && oIFrame.readyState != 'completed' )
     152                {
     153                        var editArea = this ;
     154                        ( oIFrame.onreadystatechange = function()
     155                        {
     156                                if ( oIFrame.readyState == 'complete' )
     157                                {
     158                                        oIFrame.onreadystatechange = null ;
     159                                        editArea.Window._FCKEditingArea = editArea ;
     160                                        FCKEditingArea_CompleteStart.call( editArea.Window ) ;
     161                                }
     162                        // It happened that IE changed the state to "complete" after the
     163                        // "if" and before the "onreadystatechange" assignement, making we
     164                        // lost the event call, so we do a manual call just to be sure.
     165                        } )() ;
     166                }
     167                else
     168                {
     169                        this.Window._FCKEditingArea = this ;
    130170
    131                 // FF 1.0.x is buggy... we must wait a lot to enable editing because
    132                 // sometimes the content simply disappears, for example when pasting
    133                 // "bla1!<img src='some_url'>!bla2" in the source and then switching
    134                 // back to design.
    135                 if ( FCKBrowserInfo.IsGecko10 )
    136                         this.Window.setTimeout( FCKEditingArea_CompleteStart, 500 ) ;
    137                 else
    138                         FCKEditingArea_CompleteStart.call( this.Window ) ;
     171                        // FF 1.0.x is buggy... we must wait a lot to enable editing because
     172                        // sometimes the content simply disappears, for example when pasting
     173                        // "bla1!<img src='some_url'>!bla2" in the source and then switching
     174                        // back to design.
     175                        if ( FCKBrowserInfo.IsGecko10 )
     176                                this.Window.setTimeout( FCKEditingArea_CompleteStart, 500 ) ;
     177                        else
     178                                FCKEditingArea_CompleteStart.call( this.Window ) ;
     179                }
    139180        }
    140181        else
    141182        {
    142183                var eTextarea = this.Textarea = oTargetDocument.createElement( 'textarea' ) ;
    143184                eTextarea.className = 'SourceField' ;
    144185                eTextarea.dir = 'ltr' ;
    145                 FCKDomTools.SetElementStyles( eTextarea, 
    146                         { 
    147                                 width   : '100%', 
    148                                 height  : '100%', 
    149                                 border  : 'none', 
     186                FCKDomTools.SetElementStyles( eTextarea,
     187                        {
     188                                width   : '100%',
     189                                height  : '100%',
     190                                border  : 'none',
    150191                                resize  : 'none',
    151192                                outline : 'none'
    152193                        } ) ;
     
    170211        }
    171212
    172213        var oEditorArea = this._FCKEditingArea ;
    173        
     214
     215        // Save this reference to be re-used later.
     216        oEditorArea.Document = oEditorArea.Window.document ;
     217
    174218        oEditorArea.MakeEditable() ;
    175219
    176220        // Fire the "OnLoad" event.
     
    232276                        // Disable the standard table editing features of Firefox.
    233277                        oDoc.execCommand( 'enableInlineTableEditing', false, !FCKConfig.DisableFFTableHandles ) ;
    234278                }
    235                 catch (e) 
     279                catch (e)
    236280                {
    237281                        // In Firefox if the iframe is initially hidden it can't be set to designMode and it raises an exception
    238282                        // So we set up a DOM Mutation event Listener on the HTML, as it will raise several events when the document is  visible again
     
    247291function FCKEditingArea_Document_AttributeNodeModified( evt )
    248292{
    249293        var editingArea = evt.currentTarget.contentWindow._FCKEditingArea ;
    250        
     294
    251295        // We want to run our function after the events no longer fire, so we can know that it's a stable situation
    252296        if ( editingArea._timer )
    253297                window.clearTimeout( editingArea._timer ) ;
    254298
    255         editingArea._timer = FCKTools.SetTimeout( FCKEditingArea_MakeEditableByMutation, 1000, editingArea ) ; 
     299        editingArea._timer = FCKTools.SetTimeout( FCKEditingArea_MakeEditableByMutation, 1000, editingArea ) ;
    256300}
    257301
    258302// This function ideally should be called after the document is visible, it does clean up of the
     
    313357        // Only apply the fix when in a block and the block is empty.
    314358        var parentNode = range.parentElement() ;
    315359
    316         if ( ! ( parentNode.childNodes.length == 0 && ( 
    317                                         FCKListsLib.BlockElements[parentNode.nodeName.toLowerCase()] || 
     360        if ( ! ( parentNode.childNodes.length == 0 && (
     361                                        FCKListsLib.BlockElements[parentNode.nodeName.toLowerCase()] ||
    318362                                        FCKListsLib.NonEmptyBlockElements[parentNode.nodeName.toLowerCase()] ) ) )
    319363                return ;
    320364
  • editor/_source/classes/fckpanel.js

     
    3434
    3535        if ( FCKBrowserInfo.IsIE )
    3636        {
     37                // This is a trick to IE6 (not IE7). The original domain must be set
     38                // before creating the popup, so we are able to take a refence to the
     39                // document inside of it, and the set the proper domain for it. (#123)
     40                if ( FCK_IS_CUSTOM_DOMAIN )
     41                        document.domain = FCK_ORIGINAL_DOMAIN ;
     42               
    3743                // Create the Popup that will hold the panel.
    3844                this._Popup     = this._Window.createPopup() ;
    3945                oDocument = this.Document = this._Popup.document ;
    4046
     47                // Set the proper domain inside the popup.
     48                if ( FCK_IS_CUSTOM_DOMAIN )
     49                        document.domain = oDocument.domain = FCK_RUNTIME_DOMAIN ;
     50
    4151                FCK.IECleanup.AddItem( this, FCKPanel_Cleanup ) ;
    4252        }
    4353        else
  • editor/_source/classes/fckxml_gecko.js

     
    2626        LoadUrl : function( urlToCall )
    2727        {
    2828                this.Error = false ;
    29                 var oFCKXml = this ;
    3029
     30                var oXml ;
    3131                var oXmlHttp = FCKTools.CreateXmlObject( 'XmlHttp' ) ;
    32                 oXmlHttp.open( "GET", urlToCall, false ) ;
     32                oXmlHttp.open( 'GET', urlToCall, false ) ;
    3333                oXmlHttp.send( null ) ;
    3434
    3535                if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 )
    36                         this.DOMDocument = oXmlHttp.responseXML ;
     36                        oXml = oXmlHttp.responseXML ;
    3737                else if ( oXmlHttp.status == 0 && oXmlHttp.readyState == 4 )
    38                         this.DOMDocument = oXmlHttp.responseXML ;
     38                        oXml = oXmlHttp.responseXML ;
    3939                else
    40                         this.DOMDocument = null ;
     40                        oXml = null ;
    4141
    42                 if ( this.DOMDocument == null || this.DOMDocument.firstChild == null )
     42                if ( oXml )
    4343                {
     44                        // Try to access something on it.
     45                        try
     46                        {
     47                                var test = oXml.firstChild ;
     48                        }
     49                        catch (e)
     50                        {
     51                                // If document.domain has been changed (#123), we'll have a security
     52                                // error at this point. The workaround here is parsing the responseText:
     53                                // http://alexander.kirk.at/2006/07/27/firefox-15-xmlhttprequest-reqresponsexml-and-documentdomain/
     54                                oXml = (new DOMParser()).parseFromString( oXmlHttp.responseText, 'text/xml' ) ;
     55                        }
     56                }
     57
     58                if ( !oXml || !oXml.firstChild )
     59                {
    4460                        this.Error = true ;
    45                         if (window.confirm( 'Error loading "' + urlToCall + '"\r\nDo you want to see more info?' ) )
    46                                 alert( 'URL requested: "' + urlToCall + '"\r\n' +
    47                                                         'Server response:\r\nStatus: ' + oXmlHttp.status + '\r\n' +
    48                                                         'Response text:\r\n' + oXmlHttp.responseText ) ;
    49 
     61                        if ( window.confirm( 'Error loading "' + urlToCall + '" (HTTP Status: ' + oXmlHttp.status + ').\r\nDo you want to see the server response dump?' ) )
     62                                alert( oXmlHttp.responseText ) ;
    5063                }
     64               
     65                this.DOMDocument = oXml ;
    5166        },
    5267
    5368        SelectNodes : function( xpath, contextNode )
  • editor/_source/internals/fck.js

     
    507507
    508508        Preview : function()
    509509        {
    510                 var iWidth      = FCKConfig.ScreenWidth * 0.8 ;
    511                 var iHeight     = FCKConfig.ScreenHeight * 0.7 ;
    512                 var iLeft       = ( FCKConfig.ScreenWidth - iWidth ) / 2 ;
    513                 var oWindow = window.open( '', null, 'toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=' + iWidth + ',height=' + iHeight + ',left=' + iLeft ) ;
    514 
    515510                var sHTML ;
    516511
    517512                if ( FCKConfig.FullPage )
     
    535530                                '</body></html>' ;
    536531                }
    537532
    538                 oWindow.document.write( sHTML );
    539                 oWindow.document.close();
     533                var iWidth      = FCKConfig.ScreenWidth * 0.8 ;
     534                var iHeight     = FCKConfig.ScreenHeight * 0.7 ;
     535                var iLeft       = ( FCKConfig.ScreenWidth - iWidth ) / 2 ;
     536               
     537                var sOpenUrl = '' ;
     538                if ( FCK_IS_CUSTOM_DOMAIN && FCKBrowserInfo.IsIE)
     539                {
     540                        window._FCKHtmlToLoad = sHTML ;
     541                        sOpenUrl = 'javascript:void( (function(){' +
     542                                'document.open() ;' +
     543                                'document.domain="' + document.domain + '" ;' +
     544                                'document.write( window.opener._FCKHtmlToLoad );' +
     545                                'document.close() ;' +
     546                                'window.opener._FCKHtmlToLoad = null ;' +
     547                                '})() )' ;
     548                }
     549               
     550                var oWindow = window.open( sOpenUrl, null, 'toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=' + iWidth + ',height=' + iHeight + ',left=' + iLeft ) ;
     551
     552                if ( !FCK_IS_CUSTOM_DOMAIN || !FCKBrowserInfo.IsIE)
     553                {
     554                        oWindow.document.write( sHTML );
     555                        oWindow.document.close();
     556                }
     557
    540558        },
    541559
    542560        SwitchEditMode : function( noUndo )
  • editor/_source/internals/fcktools_gecko.js

     
    111111        {
    112112                case 'XmlHttp' :
    113113                        return new XMLHttpRequest() ;
     114
    114115                case 'DOMDocument' :
    115                         return document.implementation.createDocument( '', '', null ) ;
     116                        // Originaly, we were had the following here:
     117                        // return document.implementation.createDocument( '', '', null ) ;
     118                        //
     119                        // But, when manipulating document.domain (#123), we had
     120                        // "Permission denied" errors when trying to call methods inside
     121                        // the returned object. To avoid it, we have to change to the
     122                        // following, by implementing a "custom" DOM document object, which
     123                        // includes the methods that are useful for us.
     124
     125                        var domDoc = document.createDocumentFragment() ;
     126
     127                        domDoc.createElement = function( name )
     128                        {
     129                                return document.createElement( name ) ;
     130                        }
     131
     132                        domDoc.createTextNode = function( text )
     133                        {
     134                                return document.createTextNode( text ) ;
     135                        }
     136
     137                        domDoc.createAttribute = function( attName )
     138                        {
     139                                return document.createAttribute( attName ) ;
     140                        }
     141
     142                        domDoc.createComment = function( text )
     143                        {
     144                                return document.createComment( text ) ;
     145                        }
     146
     147                        return domDoc ;
    116148        }
    117149        return null ;
    118150}
     
    224256                        break ;
    225257
    226258                /*
    227                 FCKDebug.Output( el.tagName + ":" + "offset=" + el.offsetLeft + "," + el.offsetTop + "  " 
     259                FCKDebug.Output( el.tagName + ":" + "offset=" + el.offsetLeft + "," + el.offsetTop + "  "
    228260                                + "scroll=" + el.scrollLeft + "," + el.scrollTop ) ;
    229261                */
    230262
  • editor/_source/internals/fckxhtml.js

     
    4343
    4444        // Create the XML DOMDocument object.
    4545        this.XML = FCKTools.CreateXmlObject( 'DOMDocument' ) ;
    46 
     46       
    4747        // Add a root element that holds all child nodes.
    4848        this.MainNode = this.XML.appendChild( this.XML.createElement( 'xhtml' ) ) ;
    4949
  • editor/_source/internals/fckxhtml_gecko.js

     
    2424
    2525FCKXHtml._GetMainXmlString = function()
    2626{
    27         // Create the XMLSerializer.
    28         var oSerializer = new XMLSerializer() ;
    29 
    30         // Return the serialized XML as a string.
    31         return oSerializer.serializeToString( this.MainNode ) ;
     27        return '<xhtml>' + this.MainNode.innerHTML + '</xhtml>' ;
    3228}
    3329
    3430FCKXHtml._AppendAttributes = function( xmlNode, htmlNode, node )
  • editor/dialog/common/fck_dialog_common.js

     
    1919 * == END LICENSE ==
    2020 *
    2121 * Useful functions used by almost all dialog window pages.
     22 * Dialogs should link to this file as the very first script on the page.
    2223 */
    2324
     25// Automatically detect the correct document.domain (#123).
     26(function()
     27{
     28        var d = document.domain ;
     29
     30        while ( true )
     31        {
     32                // Test if we can access a parent property.
     33                try
     34                {
     35                        var test = window.parent.document.domain ;
     36                        break ;
     37                }
     38                catch( e ) {}
     39               
     40                // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...
     41                d = d.replace( /.*?(?:\.|$)/, '' ) ;
     42
     43                if ( d.length == 0 )
     44                        break ;         // It was not able to detect the domain.
     45               
     46                try
     47                {
     48                        document.domain = d ;
     49                }
     50                catch (e)
     51                {
     52                        break ;
     53                }
     54        }
     55})() ;
     56
    2457// Gets a element by its Id. Used for shorter coding.
    2558function GetE( elementId )
    2659{
  • editor/dialog/fck_colorselector.html

     
    3434                        #btnClear               { width: 75px ; height: 22px ; margin-bottom: 6px ; }
    3535                        .ColorCell              { height: 15px ; width: 15px ; }
    3636                </style>
     37                <script src="common/fck_dialog_common.js" type="text/javascript"></script>
    3738                <script type="text/javascript">
    3839
    3940var oEditor = window.parent.InnerDialogLoaded() ;
     
    135136
    136137function Ok()
    137138{
    138         if ( typeof(window.parent.dialogArguments.CustomValue) == 'function' )
    139                 window.parent.dialogArguments.CustomValue( document.getElementById('selcolor').value ) ;
     139        if ( typeof(window.parent.args.CustomValue) == 'function' )
     140                window.parent.args.CustomValue( document.getElementById('selcolor').value ) ;
    140141
    141142        return true ;
    142143}
  • editor/dialog/fck_find.html

     
    1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
     1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    22<!--
    33 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
    44 * Copyright (C) 2003-2007 Frederico Caldeira Knabben
     
    2626        <title></title>
    2727        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    2828        <meta content="noindex, nofollow" name="robots" />
     29        <script src="common/fck_dialog_common.js" type="text/javascript"></script>
    2930        <script type="text/javascript">
    3031
    3132var oEditor = window.parent.InnerDialogLoaded() ;
  • editor/dialog/fck_flash/fck_flash_preview.html

     
    2727                <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    2828                <meta name="robots" content="noindex, nofollow">
    2929                <link href="../common/fck_dialog_common.css" rel="stylesheet" type="text/css" />
     30                <script src="../common/fck_dialog_common.js" type="text/javascript"></script>
    3031                <script language="javascript">
    3132
    3233// Sets the Skin CSS
  • editor/dialog/fck_image/fck_image_preview.html

     
    2929        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    3030        <meta name="robots" content="noindex, nofollow" />
    3131        <link href="../common/fck_dialog_common.css" rel="stylesheet" type="text/css" />
     32        <script src="../common/fck_dialog_common.js" type="text/javascript"></script>
    3233        <script type="text/javascript">
    3334
    3435// Sets the Skin CSS
     
    4748        </script>
    4849</head>
    4950<body style="color: #000000; background-color: #ffffff">
    50         <a id="lnkPreview" onclick="return false;" style="cursor: default">
    51                 <img id="imgPreview" onload="window.parent.UpdateOriginal();" style="display: none" /></a>Lorem
    52         ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas feugiat consequat diam.
    53         Maecenas metus. Vivamus diam purus, cursus a, commodo non, facilisis vitae, nulla.
    54         Aenean dictum lacinia tortor. Nunc iaculis, nibh non iaculis aliquam, orci felis
    55         euismod neque, sed ornare massa mauris sed velit. Nulla pretium mi et risus. Fusce
    56         mi pede, tempor id, cursus ac, ullamcorper nec, enim. Sed tortor. Curabitur molestie.
    57         Duis velit augue, condimentum at, ultrices a, luctus ut, orci. Donec pellentesque
    58         egestas eros. Integer cursus, augue in cursus faucibus, eros pede bibendum sem,
    59         in tempus tellus justo quis ligula. Etiam eget tortor. Vestibulum rutrum, est ut
    60         placerat elementum, lectus nisl aliquam velit, tempor aliquam eros nunc nonummy
    61         metus. In eros metus, gravida a, gravida sed, lobortis id, turpis. Ut ultrices,
    62         ipsum at venenatis fringilla, sem nulla lacinia tellus, eget aliquet turpis mauris
    63         non enim. Nam turpis. Suspendisse lacinia. Curabitur ac tortor ut ipsum egestas
    64         elementum. Nunc imperdiet gravida mauris.
     51        <div>
     52                <a id="lnkPreview" onclick="return false;" style="cursor: default">
     53                        <img id="imgPreview" src="javascript:void(0)" onload="window.parent.UpdateOriginal();"
     54                                style="display: none" alt="" /></a>Lorem ipsum dolor sit amet, consectetuer adipiscing
     55                elit. Maecenas feugiat consequat diam. Maecenas metus. Vivamus diam purus, cursus
     56                a, commodo non, facilisis vitae, nulla. Aenean dictum lacinia tortor. Nunc iaculis,
     57                nibh non iaculis aliquam, orci felis euismod neque, sed ornare massa mauris sed
     58                velit. Nulla pretium mi et risus. Fusce mi pede, tempor id, cursus ac, ullamcorper
     59                nec, enim. Sed tortor. Curabitur molestie. Duis velit augue, condimentum at, ultrices
     60                a, luctus ut, orci. Donec pellentesque egestas eros. Integer cursus, augue in cursus
     61                faucibus, eros pede bibendum sem, in tempus tellus justo quis ligula. Etiam eget
     62                tortor. Vestibulum rutrum, est ut placerat elementum, lectus nisl aliquam velit,
     63                tempor aliquam eros nunc nonummy metus. In eros metus, gravida a, gravida sed, lobortis
     64                id, turpis. Ut ultrices, ipsum at venenatis fringilla, sem nulla lacinia tellus,
     65                eget aliquet turpis mauris non enim. Nam turpis. Suspendisse lacinia. Curabitur
     66                ac tortor ut ipsum egestas elementum. Nunc imperdiet gravida mauris.
     67        </div>
    6568</body>
    6669</html>
  • editor/dialog/fck_paste.html

     
    2828        <title></title>
    2929        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    3030        <meta name="robots" content="noindex, nofollow" />
    31 
     31        <script src="common/fck_dialog_common.js" type="text/javascript"></script>
    3232        <script type="text/javascript">
    3333var oEditor = window.parent.InnerDialogLoaded() ;
    3434var FCK = oEditor.FCK;
    3535var FCKTools    = oEditor.FCKTools ;
    3636var FCKConfig   = oEditor.FCKConfig ;
     37var FCKBrowserInfo = oEditor.FCKBrowserInfo ;
    3738
    3839window.onload = function ()
    3940{
    4041        // First of all, translate the dialog box texts
    4142        oEditor.FCKLanguageManager.TranslatePage(document) ;
    4243
    43         var sPastingType = window.parent.dialogArguments.CustomValue ;
     44        var sPastingType = window.parent.args.CustomValue ;
    4445
    4546        if ( sPastingType == 'Word' || sPastingType == 'Security' )
    4647        {
    4748                if ( sPastingType == 'Security' )
    4849                        document.getElementById( 'xSecurityMsg' ).style.display = '' ;
    4950
    50                 var oFrame = document.getElementById('frmData') ;
    51                 oFrame.style.display = '' ;
    52 
    53                 // Avoid errors if the pasted content has any script that fails: #389
    54                 var oDoc = oFrame.contentWindow.document ;
    55                 oDoc.open() ;
    56                 oDoc.write('<html><head><script>window.onerror = function() { return true ; };<\/script><\/head><body><\/body><\/html>') ;
    57                 oDoc.close() ;
     51                // For document.domain compatibility (#123) we must do all the magic in
     52                // the URL for IE.
     53                var sFrameUrl = !oEditor.FCK_IS_CUSTOM_DOMAIN || !FCKBrowserInfo.IsIE ?
     54                        'javascript:void(0)' :
     55                        'javascript:void( (function(){' +
     56                                'document.open() ;' +
     57                                'document.domain=\'' + document.domain + '\' ;' +
     58                                'document.write(\'<html><head><script>window.onerror = function() { return true ; };<\/script><\/head><body><\/body><\/html>\') ;' +
     59                                'document.close() ;' +
     60                                'document.body.contentEditable = true ;' +
     61                                'window.focus() ;' +
     62                                '})() )' ;
     63                       
     64                var eFrameSpace = document.getElementById( 'xFrameSpace' ) ;
     65                eFrameSpace.innerHTML = '<iframe id="frmData" src="' + sFrameUrl + '" ' +
     66                                        'height="98%" width="99%" frameborder="0" style="border: #000000 1px; background-color: #ffffff"></iframe>' ;
    5867               
    59                 if ( oFrame.contentDocument )
    60                         oFrame.contentDocument.designMode = 'on' ;
    61                 else
    62                         oFrame.contentWindow.document.body.contentEditable = true ;
     68                var oFrame = eFrameSpace.firstChild ;
    6369
    64                 // Set the focus on the pasting area
    65                 oFrame.contentWindow.focus();
     70                if ( !oEditor.FCK_IS_CUSTOM_DOMAIN || !FCKBrowserInfo.IsIE )
     71                {
     72                        // Avoid errors if the pasted content has any script that fails: #389
     73                        var oDoc = oFrame.contentWindow.document ;
     74                        oDoc.open() ;
     75                        oDoc.write('<html><head><script>window.onerror = function() { return true ; };<\/script><\/head><body><\/body><\/html>') ;
     76                        oDoc.close() ;
     77
     78                        if ( FCKBrowserInfo.IsIE )
     79                                oDoc.body.contentEditable = true ;
     80                        else
     81                                oDoc.designMode = 'on' ;
     82
     83                        oFrame.contentWindow.focus();
     84                }
    6685        }
    6786        else
    6887        {
     
    83102
    84103        var sHtml ;
    85104
    86         var sPastingType = window.parent.dialogArguments.CustomValue ;
     105        var sPastingType = window.parent.args.CustomValue ;
    87106
    88107        if ( sPastingType == 'Word' || sPastingType == 'Security' )
    89108        {
     
    306325                        </td>
    307326                </tr>
    308327                <tr>
    309                         <td valign="top" height="100%" style="border-right: #000000 1px solid; border-top: #000000 1px solid;
    310                                 border-left: #000000 1px solid; border-bottom: #000000 1px solid">
     328                        <td id="xFrameSpace" valign="top" height="100%" style="border: #000000 1px solid">
    311329                                <textarea id="txtData" cols="80" rows="5" style="border: #000000 1px; display: none;
    312330                                        width: 99%; height: 98%"></textarea>
    313                                 <iframe id="frmData" src="javascript:void(0)" height="98%" width="99%" frameborder="0"
    314                                         style="border-right: #000000 1px; border-top: #000000 1px; display: none; border-left: #000000 1px;
    315                                         border-bottom: #000000 1px; background-color: #ffffff"></iframe>
    316331                        </td>
    317332                </tr>
    318333                <tr id="oWordCommands">
  • editor/dialog/fck_smiley.html

     
    3333                        cursor: hand;
    3434                }
    3535        </style>
     36        <script src="common/fck_dialog_common.js" type="text/javascript"></script>
    3637        <script type="text/javascript">
    3738
    3839var oEditor = window.parent.InnerDialogLoaded() ;
  • editor/dialog/fck_specialchar.html

     
    3333                                }
    3434                                .Sample { font-size: 24px; }
    3535                </style>
     36                <script src="common/fck_dialog_common.js" type="text/javascript"></script>
    3637                <script type="text/javascript">
    3738
    3839var oEditor = window.parent.InnerDialogLoaded() ;
  • editor/dialog/fck_spellerpages.html

     
    2626                <title>Spell Check</title>
    2727                <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    2828                <meta content="noindex, nofollow" name="robots">
     29                <script src="common/fck_dialog_common.js" type="text/javascript"></script>
    2930                <script src="fck_spellerpages/spellerpages/spellChecker.js"></script>
    3031                <script type="text/javascript">
    3132
  • editor/fckdialog.html

     
    1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
     1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    22<!--
    33 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
    44 * Copyright (C) 2003-2007 Frederico Caldeira Knabben
     
    2727                <meta name="robots" content="noindex, nofollow" />
    2828                <script type="text/javascript">
    2929
     30var args = window.dialogArguments ;
     31
     32// Automatically detect the correct document.domain (#123).
     33(function()
     34{
     35        var d = document.domain ;
     36
     37        while ( true )
     38        {
     39                // Test if we can access a parent property.
     40                try
     41                {
     42                        var parentDomain = window.opener ? window.opener.document.domain : args.Editor.document.domain ;
     43                       
     44                        if ( document.domain != parentDomain )
     45                                document.domain = parentDomain ;
     46                        break ;
     47                }
     48                catch( e ) {}
     49               
     50                // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...
     51                d = d.replace( /.*?(?:\.|$)/, '' ) ;
     52
     53                if ( d.length == 0 )
     54                        break ;         // It was not able to detect the domain.
     55               
     56                document.domain = d ;
     57        }
     58})() ;
     59
    3060// On some Gecko browsers (probably over slow connections) the
    3161// "dialogArguments" are not set so we must get it from the opener window.
    32 if ( !window.dialogArguments )
    33         window.dialogArguments = window.opener.FCKLastDialogInfo ;
     62if ( !args )
     63        args = window.dialogArguments = window.opener.FCKLastDialogInfo ;
    3464
    3565// Sets the Skin CSS
    36 document.write( '<link href="' + window.dialogArguments.Editor.FCKConfig.SkinPath + 'fck_dialog.css" type="text/css" rel="stylesheet">' ) ;
     66document.write( '<link href="' + args.Editor.FCKConfig.SkinPath + 'fck_dialog.css" type="text/css" rel="stylesheet">' ) ;
    3767
    3868// Sets the language direction.
    39 window.document.dir = window.dialogArguments.Editor.FCKLang.Dir ;
     69window.document.dir = args.Editor.FCKLang.Dir ;
    4070
    41 var sTitle = window.dialogArguments.Title ;
     71var sTitle = args.Title ;
    4272document.write( '<title>' + sTitle + '<\/title>' ) ;
    4373
    4474function LoadInnerDialog()
     
    4777                window.onresize() ;
    4878
    4979        // First of all, translate the dialog box contents.
    50         window.dialogArguments.Editor.FCKLanguageManager.TranslatePage( document ) ;
     80        args.Editor.FCKLanguageManager.TranslatePage( document ) ;
    5181
    52         window.frames["frmMain"].document.location.href = window.dialogArguments.Page ;
     82        document.getElementById( 'FrameCell' ).innerHTML = '<iframe id="frmMain" src="' + args.Page + '" name="frmMain" frameborder="0" height="100%" width="100%" scrolling="auto"></iframe>' ;
    5383}
    5484
    5585function InnerDialogLoaded()
     
    5787        var oInnerDoc = document.getElementById('frmMain').contentWindow.document ;
    5888
    5989        // Set the language direction.
    60         oInnerDoc.dir = window.dialogArguments.Editor.FCKLang.Dir ;
     90        oInnerDoc.dir = args.Editor.FCKLang.Dir ;
    6191
    6292        // Sets the Skin CSS.
    63         oInnerDoc.write( '<link href="' + window.dialogArguments.Editor.FCKConfig.SkinPath + 'fck_dialog.css" type="text/css" rel="stylesheet">' ) ;
     93        oInnerDoc.write( '<link href="' + args.Editor.FCKConfig.SkinPath + 'fck_dialog.css" type="text/css" rel="stylesheet">' ) ;
    6494
    6595        SetOnKeyDown( oInnerDoc ) ;
    6696        DisableContextMenu( oInnerDoc ) ;
    6797
    68         return window.dialogArguments.Editor ;
     98        return args.Editor ;
    6999}
    70100
    71101function SetOkButton( showIt )
     
    109139
    110140// Kludge for #1316: Safari seems to have a bug with the time when RefreshSize() is executed - it thinks frmMain's innerHeight
    111141// is 0 if we query the value too soon after the page is loaded in some circumstances.
    112 if ( window.dialogArguments.Editor.FCKBrowserInfo.IsSafari )
     142if ( args.Editor.FCKBrowserInfo.IsSafari )
    113143{
    114144        window.OriginalRefreshSize = RefreshSize ;
    115145
     
    127157
    128158function Cancel( dontFireChange )
    129159{
    130         if ( !dontFireChange && !window.dialogArguments.Editor.FCK.EditMode )
     160        if ( !dontFireChange && !args.Editor.FCK.EditMode )
    131161        {
    132162                // All dialog windows, by default, will fire the "OnSelectionChange"
    133163                // event, no matter the Ok or Cancel button has been pressed.
    134                 window.dialogArguments.Editor.FCK.Events.FireEvent( 'OnSelectionChange' ) ;
     164                args.Editor.FCK.Events.FireEvent( 'OnSelectionChange' ) ;
    135165        }
    136166        window.close() ;
    137167}
     
    175205                oDiv.className = 'PopupTabSelected' ;
    176206                eTabsRow.style.display = '' ;
    177207
    178                 if ( ! window.dialogArguments.Editor.FCKBrowserInfo.IsIE )
     208                if ( ! args.Editor.FCKBrowserInfo.IsIE )
    179209                        window.onresize() ;
    180210        }
    181211
     
    239269
    240270function DisableContextMenu( targetDocument )
    241271{
    242         if ( window.dialogArguments.Editor.FCKBrowserInfo.IsIE ) return ;
     272        if ( args.Editor.FCKBrowserInfo.IsIE ) return ;
    243273
    244274        // Disable Right-Click
    245275        var oOnContextMenu = function( e )
     
    252282}
    253283DisableContextMenu( document ) ;
    254284
    255 if ( ! window.dialogArguments.Editor.FCKBrowserInfo.IsIE )
     285if ( ! args.Editor.FCKBrowserInfo.IsIE )
    256286{
    257287        window.onresize = function()
    258288        {
     
    270300        }
    271301}
    272302
    273 if ( window.dialogArguments.Editor.FCKBrowserInfo.IsIE )
     303if ( args.Editor.FCKBrowserInfo.IsIE )
    274304{
    275305        function Window_OnBeforeUnload()
    276306        {
    277307                for ( var t in oTabs )
    278308                        oTabs[t] = null ;
    279309
    280                 window.dialogArguments.Editor = null ;
     310                args.Editor = null ;
    281311        }
    282312        window.attachEvent( "onbeforeunload", Window_OnBeforeUnload ) ;
    283313}
    284314
    285315function Window_OnClose()
    286316{
    287         window.dialogArguments.Editor.FCKFocusManager.Unlock() ;
     317        args.Editor.FCKFocusManager.Unlock() ;
    288318}
    289319
    290320if ( window.addEventListener )
     
    313343                        </tr>
    314344                        <tr>
    315345                                <td id="FrameCell" height="100%" valign="top">
    316                                         <iframe id="frmMain" src="javascript:void(0)" name="frmMain" frameborder="0" height="100%" width="100%" scrolling="auto">
    317                                         </iframe>
     346                                        &nbsp;
    318347                                </td>
    319348                        </tr>
    320349                        <tr>
  • editor/fckeditor.html

     
    3131        @Packager.RemoveLine -->
    3232        <script type="text/javascript">
    3333
     34// Save a reference to the default domain.
     35var FCK_ORIGINAL_DOMAIN ;
     36
     37// Automatically detect the correct document.domain (#123).
     38(function()
     39{
     40        var d = FCK_ORIGINAL_DOMAIN = document.domain ;
     41
     42        while ( true )
     43        {
     44                // Test if we can access a parent property.
     45                try
     46                {
     47                        var test = window.parent.document.domain ;
     48                        break ;
     49                }
     50                catch( e ) {}
     51               
     52                // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...
     53                d = d.replace( /.*?(?:\.|$)/, '' ) ;
     54
     55                if ( d.length == 0 )
     56                        break ;         // It was not able to detect the domain.
     57               
     58                try
     59                {
     60                        document.domain = d ;
     61                }
     62                catch (e)
     63                {
     64                        break ;
     65                }
     66        }
     67})() ;
     68
     69// Save a reference to the detected runtime domain.
     70var FCK_RUNTIME_DOMAIN = document.domain ;
     71
     72var FCK_IS_CUSTOM_DOMAIN = ( FCK_ORIGINAL_DOMAIN != FCK_RUNTIME_DOMAIN ) ;
     73
    3474// Instead of loading scripts and CSSs using inline tags, all scripts are
    3575// loaded by code. In this way we can guarantee the correct processing order,
    3676// otherwise external scripts and inline scripts could be executed in an
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy