diff options
author | Matthieu Aubry <mattab@users.noreply.github.com> | 2016-06-28 08:50:40 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-28 08:50:40 +0300 |
commit | 02daed6db8fb7269d1b3a466cbb32ed7fab76e85 (patch) | |
tree | a534b2905593d44eece6a9f896522e524cb0d28f /libs/bower_components/jquery/src/offset.js | |
parent | f981b2579a95ce60a2b7d2aa146925b4d2222e0a (diff) |
Update JQuery to the latest 1.12.4 version (#10260)
* Update JQuery to the latest 1.* version
* UI tests: Updated Jquery to latest version
Diffstat (limited to 'libs/bower_components/jquery/src/offset.js')
-rw-r--r-- | libs/bower_components/jquery/src/offset.js | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/libs/bower_components/jquery/src/offset.js b/libs/bower_components/jquery/src/offset.js index 42d07eb4f5..3e5bb97b53 100644 --- a/libs/bower_components/jquery/src/offset.js +++ b/libs/bower_components/jquery/src/offset.js @@ -1,7 +1,8 @@ -define([ +define( [ "./core", - "./var/strundefined", "./core/access", + "./var/document", + "./var/documentElement", "./css/var/rnumnonpx", "./css/curCSS", "./css/addGetHookIf", @@ -10,13 +11,11 @@ define([ "./core/init", "./css", "./selector" // contains -], function( jQuery, strundefined, access, rnumnonpx, curCSS, addGetHookIf, support ) { +], function( jQuery, access, document, documentElement, rnumnonpx, curCSS, addGetHookIf, support ) { // BuildExclude curCSS = curCSS.curCSS; -var docElem = window.document.documentElement; - /** * Gets a window from an element */ @@ -44,9 +43,10 @@ jQuery.offset = { curCSSTop = jQuery.css( elem, "top" ); curCSSLeft = jQuery.css( elem, "left" ); calculatePosition = ( position === "absolute" || position === "fixed" ) && - jQuery.inArray("auto", [ curCSSTop, curCSSLeft ] ) > -1; + jQuery.inArray( "auto", [ curCSSTop, curCSSLeft ] ) > -1; - // need to be able to calculate position if either top or left is auto and position is either absolute or fixed + // need to be able to calculate position if either top or left + // is auto and position is either absolute or fixed if ( calculatePosition ) { curPosition = curElem.position(); curTop = curPosition.top; @@ -57,7 +57,9 @@ jQuery.offset = { } if ( jQuery.isFunction( options ) ) { - options = options.call( elem, i, curOffset ); + + // Use jQuery.extend here to allow modification of coordinates argument (gh-1848) + options = options.call( elem, i, jQuery.extend( {}, curOffset ) ); } if ( options.top != null ) { @@ -75,14 +77,14 @@ jQuery.offset = { } }; -jQuery.fn.extend({ +jQuery.fn.extend( { offset: function( options ) { if ( arguments.length ) { return options === undefined ? this : - this.each(function( i ) { + this.each( function( i ) { jQuery.offset.setOffset( this, options, i ); - }); + } ); } var docElem, win, @@ -103,7 +105,7 @@ jQuery.fn.extend({ // If we don't have gBCR, just use 0,0 rather than error // BlackBerry 5, iOS 3 (original iPhone) - if ( typeof elem.getBoundingClientRect !== strundefined ) { + if ( typeof elem.getBoundingClientRect !== "undefined" ) { box = elem.getBoundingClientRect(); } win = getWindow( doc ); @@ -122,11 +124,14 @@ jQuery.fn.extend({ parentOffset = { top: 0, left: 0 }, elem = this[ 0 ]; - // fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent + // Fixed elements are offset from window (parentOffset = {top:0, left: 0}, + // because it is its only offset parent if ( jQuery.css( elem, "position" ) === "fixed" ) { + // we assume that getBoundingClientRect is available when computed position is fixed offset = elem.getBoundingClientRect(); } else { + // Get *real* offsetParent offsetParent = this.offsetParent(); @@ -146,21 +151,22 @@ jQuery.fn.extend({ // are the same in Safari causing offset.left to incorrectly be 0 return { top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ), - left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true) + left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true ) }; }, offsetParent: function() { - return this.map(function() { - var offsetParent = this.offsetParent || docElem; + return this.map( function() { + var offsetParent = this.offsetParent; - while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) { + while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && + jQuery.css( offsetParent, "position" ) === "static" ) ) { offsetParent = offsetParent.offsetParent; } - return offsetParent || docElem; - }); + return offsetParent || documentElement; + } ); } -}); +} ); // Create scrollLeft and scrollTop methods jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) { @@ -171,7 +177,7 @@ jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( var win = getWindow( elem ); if ( val === undefined ) { - return win ? (prop in win) ? win[ prop ] : + return win ? ( prop in win ) ? win[ prop ] : win.document.documentElement[ method ] : elem[ method ]; } @@ -187,8 +193,9 @@ jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( } }, method, val, arguments.length, null ); }; -}); +} ); +// Support: Safari<7-8+, Chrome<37-44+ // Add the top/left cssHooks using jQuery.fn.position // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 // getComputedStyle returns percent when specified for top/left/bottom/right @@ -198,6 +205,7 @@ jQuery.each( [ "top", "left" ], function( i, prop ) { function( elem, computed ) { if ( computed ) { computed = curCSS( elem, prop ); + // if curCSS returns percentage, fallback to offset return rnumnonpx.test( computed ) ? jQuery( elem ).position()[ prop ] + "px" : @@ -205,7 +213,7 @@ jQuery.each( [ "top", "left" ], function( i, prop ) { } } ); -}); +} ); return jQuery; -}); +} ); |