Show
Ignore:
Timestamp:
2008-01-19 16:27:03 (7 months ago)
Author:
fredck
Message:
  • Various small code fixes.
  • Throbber code simplification, including changes for the CSS requirements for it, and usage of skins color scheme for the boxes.
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor/branches/features/floating_dialog/editor/fckdialog.html

    r1332 r1369  
    2828                <meta name="robots" content="noindex, nofollow" /> 
    2929                <script type="text/javascript"> 
     30 
    3031// It seems referencing to frameElement._DialogArguments directly would lead to memory leaks in IE. 
    3132// So let's use functions to access its members instead. 
     
    3738function Editor() 
    3839{ 
    39         return Args().Editor ; 
     40        return frameElement._DialogArguments.Editor ; 
    4041} 
    4142 
    4243function ParentDialog( dialog ) 
    4344{ 
    44         if ( !dialog ) 
    45                 return frameElement._ParentDialog ; 
    46         else 
    47                 return dialog._ParentDialog ; 
     45        return dialog ? dialog._ParentDialog : frameElement._ParentDialog ; 
    4846} 
    4947 
     
    5856                try 
    5957                { 
    60                         var parentDomain = Args().TopWindow ? Args().TopWindow.document.domain : Editor().document.domain ; 
     58                        var parentDomain = ( Args().TopWindow || Editor() ).document.domain ; 
    6159 
    6260                        if ( document.domain != parentDomain ) 
    6361                                document.domain = parentDomain ; 
     62 
    6463                        break ; 
    6564                } 
     
    7675})() ; 
    7776 
    78 var FCK                 = Editor().FCK ; 
     77var FCK                         = Editor().FCK ; 
    7978var FCKTools            = Editor().FCKTools ; 
    8079var FCKDomTools         = Editor().FCKDomTools ; 
     
    9089 
    9190// Sets the language direction. 
    92 window.document.dir = Editor().FCKLang.Dir ; 
    93  
    94 if ( FCKBrowserInfo.IsIE ) 
    95 { 
    96         // IE does not set the window name in showModalDialog(), let's set it here. 
    97         window.name = Args().DialogName ; 
    98  
    99         // For IE6-, the fck_dialog_ie6.js is loaded, used to fix limitations in the browser. 
    100         if ( !FCKBrowserInfo.IsIE7 ) 
    101                 document.write( '<' + 'script type="text/javascript" src="' + FCKConfig.SkinPath + 'fck_dialog_ie6.js"><' + '\/script>' ) ; 
    102 } 
     91var langDir = window.document.dir = Editor().FCKLang.Dir ; 
     92 
     93// For IE6-, the fck_dialog_ie6.js is loaded, used to fix limitations in the browser. 
     94if ( FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 ) 
     95        document.write( '<' + 'script type="text/javascript" src="' + FCKConfig.SkinPath + 'fck_dialog_ie6.js"><' + '\/script>' ) ; 
    10396 
    10497FCKTools.RegisterDollarFunction( window ) ; 
     
    108101{ 
    109102        var bAutoSize = false ; 
     103 
    110104        var retval = { 
    111105                // Sets whether the dialog should auto-resize according to its content's height. 
     
    120114                { 
    121115                        var frmMain = $( 'frmMain' ) ; 
    122                          
     116 
    123117                        if ( frmMain ) 
    124118                        { 
    125119                                // Get the container size. 
    126120                                var height = $( 'contents' ).offsetHeight ; 
    127                                  
     121 
    128122                                // Subtract the size of other elements. 
    129123                                height -= $( 'TitleArea' ).offsetHeight ; 
    130124                                height -= $( 'TabsRow' ).offsetHeight ; 
    131125                                height -= $( 'DialogButtons' ).offsetHeight ; 
    132                                  
     126 
    133127                                frmMain.style.height = Math.max( height, 0 ) + 'px' ; 
    134128                        } 
     
    168162                                // Get the current frame size. 
    169163                                var frameSize = FCKTools.GetViewPaneSize( frmMain.contentWindow ) ; 
    170                                  
     164 
    171165                                var deltaWidth  = innerWidth - frameSize.Width ; 
    172166                                var deltaHeight = innerHeight - frameSize.Height ; 
    173167 
    174                                 // If the contents fits the current size.                
     168                                // If the contents fits the current size. 
    175169                                if ( deltaWidth <= 0 && deltaHeight <= 0 ) 
    176170                                        return ; 
    177                                  
     171 
    178172                                var dialogWidth         = frameElement.offsetWidth + Math.max( deltaWidth, 0 ) ; 
    179173                                var dialogHeight        = frameElement.offsetHeight + Math.max( deltaHeight, 0 ) ; 
     
    185179        } 
    186180 
    187         /**  
     181        /** 
    188182         * Safari seems to have a bug with the time when RefreshSize() is executed - it 
    189183         * thinks frmMain's innerHeight is 0 if we query the value too soon after the 
     
    207201 
    208202        window.SetAutoSize = FCKTools.Bind( retval, retval.SetAutoSize ) ; 
     203 
    209204        return retval ; 
    210205}() ; 
     
    213208var Throbber = function() 
    214209{ 
    215         var timer = null ; 
    216         var baseIndex = 0 ; 
     210        var timer ; 
     211 
    217212        var updateThrobber = function() 
    218213        { 
    219214                var throbberParent = $( 'throbberBlock' ) ; 
    220215                var throbberBlocks = throbberParent.childNodes ; 
    221                 for ( var i = 0 ; i < throbberBlocks.length ; i++ ) 
    222                 { 
    223                         var classes = throbberBlocks[i].className.split( ' ' ) ; 
    224                         classes.pop() ; 
    225                         classes.push( 'throbber_' + ( baseIndex + i ) % 10 ) ; 
    226                         throbberBlocks[i].className = classes.join( ' ' ) ; 
    227                 } 
    228                 baseIndex-- ; 
    229                 if ( baseIndex < 0 ) 
    230                         baseIndex += 10 ; 
    231                 timer = FCKTools.SetTimeout( arguments.callee, 100, this, null, window ) ; 
    232         } 
    233  
    234         FCKTools.AddEventListener( window, 'beforeunload', function() 
    235                 { 
    236                         if ( timer ) 
    237                                 clearTimeout( timer ) ; 
    238                 } ) ; 
     216                var lastClass = throbberParent.lastChild.className ; 
     217 
     218                // From the last to the second one, copy the class from the previous one. 
     219                for ( var i = throbberBlocks.length - 1 ; i > 0 ; i-- ) 
     220                        throbberBlocks[i].className = throbberBlocks[i-1].className ; 
     221 
     222                // For the first one, copy the last class (rotation). 
     223                throbberBlocks[0].className = lastClass ; 
     224        } 
    239225 
    240226        return { 
    241227                Show : function( waitMilliseconds ) 
    242228                { 
     229                        // Auto-setup the Show function to be called again after the 
     230                        // requested amount of time. 
    243231                        if ( waitMilliseconds && waitMilliseconds > 0 ) 
    244232                        { 
     
    248236 
    249237                        var throbberParent = $( 'throbberBlock' ) ; 
    250                         for ( var i = 0 ; i < 10 ; i++) 
    251                                 throbberParent.appendChild( document.createElement( 'div' ) ).className = 'throbber_' + ( i > 0 ? 'right' : 'left' )  
    252                                         + ' throbber_' + i ; 
    253                         baseIndex = 9 ; 
    254  
     238 
     239                        // Create the throbber blocks. 
     240                        var classIds = [ 1,2,3,4,5,4,3,2 ] ; 
     241                        while ( classIds.length > 0 ) 
     242                                throbberParent.appendChild( document.createElement( 'div' ) ).className = ' throbber_' + classIds.shift() ; 
     243 
     244                        // Center the throbber. 
    255245                        var frm = $( 'contents' ) ; 
    256246                        var frmCoords = FCKTools.GetDocumentPosition( window, frm ) ; 
     
    260250                        throbberParent.style.top = parseInt( y, 10 ) + 'px' ; 
    261251 
    262                         timer = FCKTools.SetTimeout( updateThrobber, 100, this, null, window ) ; 
     252                        // Show it. 
     253                        throbberParent.style.visibility = ''  ; 
     254 
     255                        // Setup the animation interval. 
     256                        timer = setInterval( updateThrobber, 100 ) ; 
    263257                }, 
    264258 
     
    267261                        if ( timer ) 
    268262                        { 
    269                                 clearTimeout( timer ) ; 
     263                                clearInterval( timer ) ; 
    270264                                timer = null ; 
    271265                        } 
     
    284278        var lastCoords ; 
    285279        var currentPos ; 
    286          
     280 
    287281        var cleanUpHandlers = function() 
    288282        { 
     
    353347                                return ; 
    354348 
    355                         lastCoords =  
    356                         { 
    357                                 x : evt.screenX,  
     349                        lastCoords = 
     350                        { 
     351                                x : evt.screenX, 
    358352                                y : evt.screenY 
    359353                        } ; 
    360354 
    361355                        // Save the current IFRAME position. 
    362                         currentPos =  
     356                        currentPos = 
    363357                        { 
    364358                                x : parseInt( FCKDomTools.GetCurrentElementStyle( Args().TopWindow, frameElement, 'left' ) ), 
     
    507501}() ; 
    508502 
    509 // readystatechange handler for registering drag and drop handlers in cover iframes, defined out here to avoid memory leak. 
    510 // Do NOT put this function as a private function as it will induce memory leak in IE and it's not detectable with Drip or  
    511 // sIEve and undetectable leaks are really nasty (sigh). 
     503// readystatechange handler for registering drag and drop handlers in cover 
     504// iframes, defined out here to avoid memory leak. 
     505// Do NOT put this function as a private function as it will induce memory leak 
     506// in IE and it's not detectable with Drip or sIEve and undetectable leaks are 
     507// really nasty (sigh). 
    512508var onReadyRegister = function() 
    513509{ 
     
    517513} ; 
    518514 
    519 // The business logic of the dialog, dealing with operational things like dialog open/dialog close/enable/disable/etc. 
     515// The business logic of the dialog, dealing with operational things like 
     516// dialog open/dialog close/enable/disable/etc. 
    520517(function() 
    521518{ 
     
    632629                // First of all, translate the dialog box contents. 
    633630                Editor().FCKLanguageManager.TranslatePage( document ) ; 
    634                  
     631 
    635632                // Create the IFRAME that holds the dialog contents. 
    636633                $( 'innerContents' ).innerHTML = '<iframe id="frmMain" src="' + Args().Page + '" name="frmMain" frameborder="0" width="100%" height="100%" scrolling="auto" style="visibility: hidden;" allowtransparency="true"></iframe>' ; 
    637634        } ; 
    638          
     635 
    639636        window.InnerDialogLoaded = function() 
    640637        { 
     
    653650 
    654651                // Set the language direction. 
    655                 innerDoc.dir = Editor().FCKLang.Dir ; 
     652                innerDoc.dir = langDir ; 
    656653 
    657654                // Sets the Skin CSS. 
     
    664661 
    665662                DragAndDrop.RegisterHandlers( innerWindow ) ; 
    666                  
     663 
    667664                innerWindow.focus() ; 
    668665 
     
    678675        { 
    679676                Selection.EnsureSelection() ; 
    680                  
     677 
    681678                var frmMain = window.frames["frmMain"] ; 
    682679 
     
    694691        window.CloseDialog = function( dontFireChange ) 
    695692        { 
     693                Throbber.Hide() ; 
     694 
    696695                Selection.EnsureSelection() ; 
    697696 
     
    761760                                                <td width="100%">&nbsp;</td> 
    762761                                                <td nowrap="nowrap"> 
    763                                                         <input id="btnOk" style="VISIBILITY: hidden;" type="button" value="Ok" class="Button" onclick="Ok();" fckLang="DlgBtnOK" /> 
     762                                                        <input id="btnOk" style="visibility: hidden;" type="button" value="Ok" class="Button" onclick="Ok();" fckLang="DlgBtnOK" /> 
    764763                                                        &nbsp; 
    765764                                                        <input id="btnCancel" type="button" value="Cancel" class="Button" onclick="Cancel();" fckLang="DlgBtnCancel" /> 
     
    778777                <div class="br"></div> 
    779778                <div class="cover" id="cover" style="display:none"></div> 
    780                 <div id="throbberBlock" style="position: absolute; z-index: 10; text-align: center; font-size: 9px;"></div> 
     779                <div id="throbberBlock" style="position: absolute; visibility: hidden"></div> 
    781780                <script type="text/javascript"> 
    782781                        // Set the class name for language direction. 
    783                         document.body.className += ' ' + Editor().FCKLang.Dir ; 
     782                        document.body.className += ' ' + langDir ; 
    784783 
    785784                        var cover = $( 'cover' ) ;