| @@ 9512-9560 (lines=49) @@ | ||
| 9509 | } |
|
| 9510 | ||
| 9511 | jQuery.offset = { |
|
| 9512 | setOffset: function( elem, options, i ) { |
|
| 9513 | var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition, |
|
| 9514 | position = jQuery.css( elem, "position" ), |
|
| 9515 | curElem = jQuery( elem ), |
|
| 9516 | props = {}; |
|
| 9517 | ||
| 9518 | // Set position first, in-case top/left are set even on static elem |
|
| 9519 | if ( position === "static" ) { |
|
| 9520 | elem.style.position = "relative"; |
|
| 9521 | } |
|
| 9522 | ||
| 9523 | curOffset = curElem.offset(); |
|
| 9524 | curCSSTop = jQuery.css( elem, "top" ); |
|
| 9525 | curCSSLeft = jQuery.css( elem, "left" ); |
|
| 9526 | calculatePosition = ( position === "absolute" || position === "fixed" ) && |
|
| 9527 | ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1; |
|
| 9528 | ||
| 9529 | // Need to be able to calculate position if either |
|
| 9530 | // top or left is auto and position is either absolute or fixed |
|
| 9531 | if ( calculatePosition ) { |
|
| 9532 | curPosition = curElem.position(); |
|
| 9533 | curTop = curPosition.top; |
|
| 9534 | curLeft = curPosition.left; |
|
| 9535 | ||
| 9536 | } else { |
|
| 9537 | curTop = parseFloat( curCSSTop ) || 0; |
|
| 9538 | curLeft = parseFloat( curCSSLeft ) || 0; |
|
| 9539 | } |
|
| 9540 | ||
| 9541 | if ( jQuery.isFunction( options ) ) { |
|
| 9542 | ||
| 9543 | // Use jQuery.extend here to allow modification of coordinates argument (gh-1848) |
|
| 9544 | options = options.call( elem, i, jQuery.extend( {}, curOffset ) ); |
|
| 9545 | } |
|
| 9546 | ||
| 9547 | if ( options.top != null ) { |
|
| 9548 | props.top = ( options.top - curOffset.top ) + curTop; |
|
| 9549 | } |
|
| 9550 | if ( options.left != null ) { |
|
| 9551 | props.left = ( options.left - curOffset.left ) + curLeft; |
|
| 9552 | } |
|
| 9553 | ||
| 9554 | if ( "using" in options ) { |
|
| 9555 | options.using.call( elem, props ); |
|
| 9556 | ||
| 9557 | } else { |
|
| 9558 | curElem.css( props ); |
|
| 9559 | } |
|
| 9560 | } |
|
| 9561 | }; |
|
| 9562 | ||
| 9563 | jQuery.fn.extend( { |
|
| @@ 8905-8950 (lines=46) @@ | ||
| 8902 | } |
|
| 8903 | ||
| 8904 | jQuery.offset = { |
|
| 8905 | setOffset: function( elem, options, i ) { |
|
| 8906 | var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition, |
|
| 8907 | position = jQuery.css( elem, "position" ), |
|
| 8908 | curElem = jQuery( elem ), |
|
| 8909 | props = {}; |
|
| 8910 | ||
| 8911 | // Set position first, in-case top/left are set even on static elem |
|
| 8912 | if ( position === "static" ) { |
|
| 8913 | elem.style.position = "relative"; |
|
| 8914 | } |
|
| 8915 | ||
| 8916 | curOffset = curElem.offset(); |
|
| 8917 | curCSSTop = jQuery.css( elem, "top" ); |
|
| 8918 | curCSSLeft = jQuery.css( elem, "left" ); |
|
| 8919 | calculatePosition = ( position === "absolute" || position === "fixed" ) && |
|
| 8920 | ( curCSSTop + curCSSLeft ).indexOf("auto") > -1; |
|
| 8921 | ||
| 8922 | // Need to be able to calculate position if either top or left is auto and position is either absolute or fixed |
|
| 8923 | if ( calculatePosition ) { |
|
| 8924 | curPosition = curElem.position(); |
|
| 8925 | curTop = curPosition.top; |
|
| 8926 | curLeft = curPosition.left; |
|
| 8927 | ||
| 8928 | } else { |
|
| 8929 | curTop = parseFloat( curCSSTop ) || 0; |
|
| 8930 | curLeft = parseFloat( curCSSLeft ) || 0; |
|
| 8931 | } |
|
| 8932 | ||
| 8933 | if ( jQuery.isFunction( options ) ) { |
|
| 8934 | options = options.call( elem, i, curOffset ); |
|
| 8935 | } |
|
| 8936 | ||
| 8937 | if ( options.top != null ) { |
|
| 8938 | props.top = ( options.top - curOffset.top ) + curTop; |
|
| 8939 | } |
|
| 8940 | if ( options.left != null ) { |
|
| 8941 | props.left = ( options.left - curOffset.left ) + curLeft; |
|
| 8942 | } |
|
| 8943 | ||
| 8944 | if ( "using" in options ) { |
|
| 8945 | options.using.call( elem, props ); |
|
| 8946 | ||
| 8947 | } else { |
|
| 8948 | curElem.css( props ); |
|
| 8949 | } |
|
| 8950 | } |
|
| 8951 | }; |
|
| 8952 | ||
| 8953 | jQuery.fn.extend({ |
|