Ticket #135: fcktools_gecko.js.patch

File fcktools_gecko.js.patch, 1.6 KB (added by Geir Helge Tjøstolvsen-Schmidt, 17 years ago)

fcktools_gecko.js - Added section to loop through the parent chain and a parameter to exclude it for panel children

  • fcktools_gecko.js

    old new  
    189189// Get the coordinates of an element.
    190190//              @el : The element to get the position.
    191191//              @relativeWindow: The window to which we want the coordinates relative to.
    192 FCKTools.GetElementPosition = function( el, relativeWindow )
     192FCKTools.GetElementPosition = function( el, relativeWindow, excludeParentChain )
    193193{
    194194        // Initializes the Coordinates object that will be returned by the function.
    195195        var c = { X:0, Y:0 } ;
     
    197197        var oWindow = relativeWindow || window ;
    198198
    199199        var oOwnerWindow = FCKTools.GetElementWindow( el ) ;
     200       
     201        var elOrig = el;
    200202
    201203        // Loop throw the offset chain.
    202204        while ( el )
     
    229231                        }
    230232                }
    231233        }
     234       
     235        if (excludeParentChain == null){
     236            excludeParentChain = true;
     237        }
     238       
     239        // Loop through the parent chain.
     240        if (excludeParentChain && elOrig) {
     241        var oOwnerWindow = FCKTools.GetElementWindow( elOrig ) ;
     242            while(elOrig){
     243            if (elOrig.parentNode) {
     244                if (elOrig.parentNode.scrollTop)
     245                    c.Y -= elOrig.parentNode.scrollTop;
     246                if (elOrig.parentNode.scrollLeft)
     247                    c.X -= elOrig.parentNode.scrollLeft;
     248                elOrig = elOrig.parentNode;
     249            } else {
     250                        if ( oOwnerWindow != oWindow ){
     251                                elOrig = oOwnerWindow.frameElement;
     252                                if ( elOrig )
     253                                        oOwnerWindow = FCKTools.GetElementWindow( elOrig );
     254                        } else {
     255                                break ;
     256                        }
     257            }
     258        }
     259    }
    232260
    233261        // Return the Coordinates object
    234262        return c ;
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy