Changeset 487

Show
Ignore:
Timestamp:
2007-07-20 12:58:11 (17 months ago)
Author:
martinkou
Message:

Deleted _GetWindowScrollX() and _GetWindowScrollY() from dragresizetable plugin, since those two functions exist in FCKTools already.
Refactored _GetDocumentPosition() and _GetWindowPosition() from dragresizetable plugin to core, since they are now used by core components.
Fixed #174 : Incorrect positioning of FCKeditor widget in full screen mode.

Location:
FCKeditor/trunk/editor
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor/trunk/editor/plugins/dragresizetable/fckplugin.js

    r480 r487  
    1010        "_MaximumX" : null, 
    1111        "_LastX" : null, 
    12         "_GetWindowScrollX" : function( w ) 
    13         { 
    14                 var scrollX = 0 ; 
    15                 if ( w.document.documentElement && w.document.documentElement.scrollLeft )  
    16                         scrollX = w.document.documentElement.scrollLeft ; 
    17                 else if ( w.document.body && w.document.body.scrollLeft ) 
    18                         scrollX = w.document.body.scrollLeft ; 
    19                 else if ( w.scrollX ) 
    20                         scrollX = w.scrollX ; 
    21                 return scrollX ; 
    22         }, 
    23         "_GetWindowScrollY" : function( w ) 
    24         { 
    25                 var scrollY = 0 ; 
    26                 if ( w.document.documentElement && w.document.documentElement.scrollTop ) 
    27                         scrollY = w.document.documentElement.scrollTop ; 
    28                 else if ( w.document.body && w.document.body.scrollTop ) 
    29                         scrollY = w.document.body.scrollTop ; 
    30                 else if ( w.scrollY ) 
    31                         scrollY = w.scrollY ; 
    32                 return scrollY ; 
    33         }, 
    34         "_GetDocumentPosition" : function( w, node ) 
    35         { 
    36                 var x = 0 ; 
    37                 var y = 0 ; 
    38                 var curNode = node ; 
    39                 while ( curNode && curNode != w.document.body ) 
    40                 { 
    41                         x += curNode.offsetLeft - curNode.scrollLeft ; 
    42                         y += curNode.offsetTop - curNode.scrollTop ; 
    43                         curNode = curNode.offsetParent ; 
    44                 } 
    45                 return { "x" : x, "y" : y } ; 
    46         }, 
    47         "_GetWindowPosition" : function( w, node ) 
    48         { 
    49                 var pos = this._GetDocumentPosition( w, node ) ; 
    50                 pos.x -= this._GetWindowScrollX( w ) ; 
    51                 pos.y -= this._GetWindowScrollY( w ) ; 
    52                 return pos ; 
    53         }, 
    5412        "_IsInsideNode" : function( w, domNode, pos ) 
    5513        { 
    56                 var myCoords = this._GetWindowPosition( w, domNode ) ;  
     14                var myCoords = FCKTools.GetWindowPosition( w, domNode ) ;  
    5715                var xMin = myCoords.x ; 
    5816                var yMin = myCoords.y ; 
     
    8543                for ( var i = 0 ; i < cells.length ; i++ ) 
    8644                { 
    87                         var pos = this._GetWindowPosition( w, cells[i] ) ; 
     45                        var pos = FCKTools.GetWindowPosition( w, cells[i] ) ; 
    8846                        var rightX = pos.x + parseInt( cells[i].clientWidth ) ; 
    8947                        var rxDist = mouse.x - rightX ; 
     
    10563 
    10664                // Abort if too far from the border. 
    107                 lxDist = mouse.x - this._GetWindowPosition( w, lbCell ).x ; 
     65                lxDist = mouse.x - FCKTools.GetWindowPosition( w, lbCell ).x ; 
    10866                if ( lxDist < 0 && minRxDist < 0 && minRxDist < -2 ) 
    10967                        return null ;  
     
    14098                // Calculate maximum and minimum x-coordinate delta. 
    14199                var borderIndex = FCKDragTableHandler._GetResizeBarPosition() ; 
    142                 var offset = FCKDragTableHandler._GetDocumentPosition( window, FCK.EditingArea.IFrame ) ; 
     100                var offset = FCKTools.GetDocumentPosition( window, FCK.EditingArea.IFrame ) ; 
    143101                var table = FCKTools.GetElementAscensor( FCKDragTableHandler._LeftCell, "table" ); 
    144102                var minX = null ; 
     
    151109                        { 
    152110                                var cell = row.cells.item( c ) ; 
    153                                 var cellPosition = FCKDragTableHandler._GetWindowPosition( FCK.EditorWindow, cell ) ; 
     111                                var cellPosition = FCKTools.GetWindowPosition( FCK.EditorWindow, cell ) ; 
    154112                                var cellPadding = FCKDragTableHandler._GetCellPadding( table, cell ) ; 
    155113                                var cellMinX = cellPosition.x + cellPadding ; 
     
    365323                if ( node.ownerDocument == document ) 
    366324                { 
    367                         var offset = this._GetDocumentPosition( window, FCK.EditingArea.IFrame ) ; 
     325                        var offset = FCKTools.GetDocumentPosition( window, FCK.EditingArea.IFrame ) ; 
    368326                        mouseX -= offset.x ; 
    369327                        mouseY -= offset.y ; 
     
    373331                if ( this._ResizeBar && this._LeftCell ) 
    374332                { 
    375                         var leftPos = this._GetWindowPosition( FCK.EditorWindow, this._LeftCell ) ; 
    376                         var rightPos = this._GetWindowPosition( FCK.EditorWindow, this._RightCell ) ;  
     333                        var leftPos = FCKTools.GetWindowPosition( FCK.EditorWindow, this._LeftCell ) ; 
     334                        var rightPos = FCKTools.GetWindowPosition( FCK.EditorWindow, this._RightCell ) ;  
    377335                        var rxDist = mouseX - ( leftPos.x + this._LeftCell.clientWidth ) ; 
    378336                        var lxDist = mouseX - rightPos.x ; 
     
    427385                if ( node.ownerDocument == FCK.EditorDocument ) 
    428386                { 
    429                         var offset = this._GetDocumentPosition( window, FCK.EditingArea.IFrame ) ; 
     387                        var offset = FCKTools.GetDocumentPosition( window, FCK.EditingArea.IFrame ) ; 
    430388                        mouse.x += offset.x ; 
    431389                        mouse.y += offset.y ; 
     
    438396                        mouse.x = this._MinimumX + 5 ; 
    439397 
    440                 var docX = mouse.x + this._GetWindowScrollX( window ) ; 
     398                var docX = mouse.x + FCKTools.GetScrollPosition( window ).X ; 
    441399                this._ResizeBar.style.left = ( docX - this._ResizeBar.offsetWidth / 2 ) + "px" ; 
    442400                this._LastX = mouse.x ; 
     
    487445                else 
    488446                        paddingBar.style.opacity = 0.1 ; 
    489                 var offset = this._GetDocumentPosition( window, FCK.EditingArea.IFrame ) ; 
    490                 var tablePos = this._GetWindowPosition( w, table ) ; 
     447                var offset = FCKTools.GetDocumentPosition( window, FCK.EditingArea.IFrame ) ; 
     448                var tablePos = FCKTools.GetWindowPosition( w, table ) ; 
    491449                var barHeight = table.offsetHeight ; 
    492450                var barTop = offset.y + tablePos.y ; 
     
    507465                var barWidth = Math.max( bw+100, cs+100 ) ; 
    508466                paddingBar.style.width = barWidth + "px" ; 
    509                 paddingBar.style.left = ( offset.x + mouse.x + this._GetWindowScrollX( w ) - barWidth / 2 ) +  "px" ; 
     467                paddingBar.style.left = ( offset.x + mouse.x + FCKTools.GetScrollPosition( w ).X - barWidth / 2 ) +  "px" ; 
    510468                var filler = paddingBar.getElementsByTagName( "img" )[0] ; 
    511469                filler.style.width = paddingBar.offsetWidth + "px" ; 
  • FCKeditor/trunk/editor/_source/commandclasses/fckfitwindow.js

    r132 r487  
    103103                eMainWindow.scrollTo(0, 0); 
    104104 
     105                // Is the editor still not on the top left? Let's find out and fix that as well. (Bug #174) 
     106                var editorPos = FCKTools.GetWindowPosition( eMainWindow, eEditorFrame ) ; 
     107                if ( editorPos.x != 0 ) 
     108                        eEditorFrameStyle.left = ( -1 * editorPos.x ) + "px" ; 
     109                if ( editorPos.y != 0 ) 
     110                        eEditorFrameStyle.top = ( -1 * editorPos.y ) + "px" ; 
     111 
    105112                this.IsMaximized = true ; 
    106113        } 
  • FCKeditor/trunk/editor/_source/internals/fcktools.js

    r480 r487  
    446446        return output.join( "" ) ; 
    447447} 
     448 
     449FCKTools.GetDocumentPosition = function( w, node ) 
     450{ 
     451        var x = 0 ; 
     452        var y = 0 ; 
     453        var curNode = node ; 
     454        while ( curNode && curNode != w.document.body ) 
     455        { 
     456                x += curNode.offsetLeft - curNode.scrollLeft ; 
     457                y += curNode.offsetTop - curNode.scrollTop ; 
     458                curNode = curNode.offsetParent ; 
     459        } 
     460        return { "x" : x, "y" : y } ; 
     461} 
     462 
     463FCKTools.GetWindowPosition = function( w, node ) 
     464{ 
     465        var pos = this.GetDocumentPosition( w, node ) ; 
     466        var scroll = FCKTools.GetScrollPosition( w ) ; 
     467        pos.x -= scroll.X ; 
     468        pos.y -= scroll.Y ; 
     469        return pos ; 
     470}