Ticket #1514: 1514_2.patch

File 1514_2.patch, 6.8 KB (added by martinkou, 2 years ago)

Revised patch which fixes both #1514 and #538.

  • editor/_source/internals/fck.js

     
    3232        HasFocus                : false, 
    3333        DataProcessor   : new FCKDataProcessor(), 
    3434 
     35        GetInstanceObject       : (function() 
     36        { 
     37                var w = window ; 
     38                return function( name ) 
     39                { 
     40                        return w[name] ; 
     41                } 
     42        })(), 
     43 
    3544        AttachToOnSelectionChange : function( functionPointer ) 
    3645        { 
    3746                this.Events.AttachEvent( 'OnSelectionChange', functionPointer ) ; 
  • editor/_source/internals/fcktoolbarset.js

     
    107107        } 
    108108 
    109109        oToolbarSet.CurrentInstance = FCK ; 
     110        if ( !oToolbarSet.ToolbarItems ) 
     111                oToolbarSet.ToolbarItems = FCKToolbarItems ; 
    110112 
    111113        FCK.AttachToOnSelectionChange( oToolbarSet.RefreshItemsState ) ; 
    112114 
  • editor/_source/commandclasses/fcktextcolorcommand.js

     
    4242        this._Panel.AppendStyleSheet( FCKConfig.SkinPath + 'fck_editor.css' ) ; 
    4343        this._Panel.MainNode.className = 'FCK_Panel' ; 
    4444        this._CreatePanelBody( this._Panel.Document, this._Panel.MainNode ) ; 
     45        FCK.ToolbarSet.ToolbarItems.GetItem( this.Name ).RegisterPanel( this._Panel ) ; 
    4546 
    4647        FCKTools.DisableSelection( this._Panel.Document.body ) ; 
    4748} 
  • editor/_source/classes/fcktoolbarpanelbutton.js

     
    4848        this._UIButton.Create( parentElement ) ; 
    4949 
    5050        var oPanel = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName )._Panel ; 
     51        this.RegisterPanel( oPanel ) ; 
     52} 
     53 
     54FCKToolbarPanelButton.prototype.RegisterPanel = function( oPanel ) 
     55{ 
     56        if ( oPanel._FCKToolbarPanelButton ) 
     57                return ; 
     58 
    5159        oPanel._FCKToolbarPanelButton = this ; 
    5260 
    5361        var eLineDiv = oPanel.Document.body.appendChild( oPanel.Document.createElement( 'div' ) ) ; 
    5462        eLineDiv.style.position = 'absolute' ; 
    5563        eLineDiv.style.top = '0px' ; 
    5664 
    57         var eLine = this.LineImg = eLineDiv.appendChild( oPanel.Document.createElement( 'IMG' ) ) ; 
     65        var eLine = oPanel._FCKToolbarPanelButtonLineDiv = eLineDiv.appendChild( oPanel.Document.createElement( 'IMG' ) ) ; 
    5866        eLine.className = 'TB_ConnectionLine' ; 
    5967        eLine.style.position = 'absolute' ; 
    6068//      eLine.style.backgroundColor = 'Red' ; 
     
    7482 
    7583        oButton._UIButton.ChangeState( FCK_TRISTATE_ON ) ; 
    7684 
    77         oButton.LineImg.style.width = ( e.offsetWidth - 2 ) + 'px' ; 
     85        // oButton.LineImg.style.width = ( e.offsetWidth - 2 ) + 'px' ; 
    7886 
    79         FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( oButton.CommandName ).Execute( 0, e.offsetHeight - 1, e ) ; // -1 to be over the border 
     87        var oCommand = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( oButton.CommandName ) ; 
     88        var oPanel = oCommand._Panel ; 
     89        oPanel._FCKToolbarPanelButtonLineDiv.style.width = ( e.offsetWidth - 2 ) + 'px' ; 
     90        oCommand.Execute( 0, e.offsetHeight - 1, e ) ; // -1 to be over the border 
    8091} 
    8192 
    8293function FCKToolbarPanelButton_OnPanelHide() 
  • editor/_source/classes/fckpanel.js

     
    6464                                zIndex          : FCKConfig.FloatingPanelsZIndex 
    6565                        } ) ; 
    6666 
    67                 if ( this._Window == window.parent && window.frameElement ) 
    68                 { 
    69                         var scrollPos = null ; 
    70                         if ( FCKBrowserInfo.IsGecko && FCK && FCK.EditorDocument ) 
    71                                 scrollPos = [ FCK.EditorDocument.body.scrollLeft, FCK.EditorDocument.body.scrollTop ] ; 
    72                         window.frameElement.parentNode.insertBefore( oIFrame, window.frameElement ) ; 
    73                         if ( scrollPos ) 
    74                         { 
    75                                 var restoreFunc = function() 
    76                                 { 
    77                                         FCK.EditorDocument.body.scrollLeft = scrollPos[0] ; 
    78                                         FCK.EditorDocument.body.scrollTop = scrollPos[1] ; 
    79                                 } 
    80                                 setTimeout( restoreFunc, 500 ) ; 
    81                         } 
    82                 } 
    83                 else 
    84                         this._Window.document.body.appendChild( oIFrame ) ; 
     67                this._Window.document.body.appendChild( oIFrame ) ; 
    8568 
    8669                var oIFrameWindow = oIFrame.contentWindow ; 
    8770 
     
    187170                } 
    188171 
    189172                // Be sure we'll not have more than one Panel opened at the same time. 
    190                 if ( FCKPanel._OpenedPanel ) 
    191                         FCKPanel._OpenedPanel.Hide() ; 
     173                // Do not unlock focus manager here because we're displaying another floating panel 
     174                // instead of returning the editor to a "no panel" state (Bug #1514). 
     175                if ( FCK.ToolbarSet.CurrentInstance.GetInstanceObject( 'FCKPanel' )._OpenedPanel &&  
     176                                FCK.ToolbarSet.CurrentInstance.GetInstanceObject( 'FCKPanel' )._OpenedPanel != this ) 
     177                        FCK.ToolbarSet.CurrentInstance.GetInstanceObject( 'FCKPanel' )._OpenedPanel.Hide( false, true ) ; 
    192178 
    193179                FCKDomTools.SetElementStyles( eMainNode, 
    194180                        { 
     
    253239                                y -= y + eMainNode.offsetHeight - iViewPaneHeight ; 
    254240                } 
    255241 
    256                 if ( x < 0 ) 
    257                          x = 0 ; 
    258  
    259242                // Set the context menu DIV in the specified location. 
    260243                FCKDomTools.SetElementStyles( this._IFrame, 
    261244                        { 
     
    263246                                top             : y + 'px' 
    264247                        } ) ; 
    265248 
    266                 var iWidth      = iMainWidth ; 
    267                 var iHeight     = eMainNode.offsetHeight ; 
     249                var me = this ; 
     250                var resizeFunc = function() 
     251                { 
     252                        var iWidth = eMainNode.offsetWidth || eMainNode.firstChild.offsetWidth ; 
     253                        var iHeight = eMainNode.offsetHeight ; 
     254                        me._IFrame.width = iWidth ; 
     255                        me._IFrame.height = iHeight ; 
     256                 
     257                        // Move the focus to the IFRAME so we catch the "onblur". 
     258                        me._IFrame.contentWindow.focus() ; 
     259                        me._IsOpened = true ; 
     260                } 
     261                setTimeout( resizeFunc, 1 ) ; 
    268262 
    269                 this._IFrame.width      = iWidth ; 
    270                 this._IFrame.height = iHeight ; 
    271  
    272                 // Move the focus to the IFRAME so we catch the "onblur". 
    273                 this._IFrame.contentWindow.focus() ; 
    274  
    275                 FCKPanel._OpenedPanel = this ; 
     263                FCK.ToolbarSet.CurrentInstance.GetInstanceObject( 'FCKPanel' )._OpenedPanel = this ; 
    276264        } 
    277265 
    278         this._IsOpened = true ; 
    279  
    280266        FCKTools.RunFunction( this.OnShow, this ) ; 
    281267} 
    282268 
    283 FCKPanel.prototype.Hide = function( ignoreOnHide ) 
     269FCKPanel.prototype.Hide = function( ignoreOnHide, ignoreFocusManagerUnlock ) 
    284270{ 
    285271        if ( this._Popup ) 
    286272                this._Popup.hide() ; 
     
    290276                        return ; 
    291277 
    292278                // Enable the editor to fire the "OnBlur". 
    293                 if ( typeof( FCKFocusManager ) != 'undefined' ) 
     279                if ( typeof( FCKFocusManager ) != 'undefined' && !ignoreFocusManagerUnlock ) 
    294280                        FCKFocusManager.Unlock() ; 
    295281 
    296282                // It is better to set the sizes to 0, otherwise Firefox would have