scratch

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 124  →  ?path2? @ 125
/bower_components/jquery/src/offset.js
@@ -1,8 +1,7 @@
define( [
define([
"./core",
"./var/strundefined",
"./core/access",
"./var/document",
"./var/documentElement",
"./css/var/rnumnonpx",
"./css/curCSS",
"./css/addGetHookIf",
@@ -11,9 +10,9 @@
"./core/init",
"./css",
"./selector" // contains
], function( jQuery, access, document, documentElement, rnumnonpx, curCSS, addGetHookIf, support ) {
], function( jQuery, strundefined, access, rnumnonpx, curCSS, addGetHookIf, support ) {
 
"use strict";
var docElem = window.document.documentElement;
 
/**
* Gets a window from an element
@@ -38,7 +37,7 @@
curCSSTop = jQuery.css( elem, "top" );
curCSSLeft = jQuery.css( elem, "left" );
calculatePosition = ( position === "absolute" || position === "fixed" ) &&
( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
( curCSSTop + curCSSLeft ).indexOf("auto") > -1;
 
// Need to be able to calculate position if either
// top or left is auto and position is either absolute or fixed
@@ -53,9 +52,7 @@
}
 
if ( jQuery.isFunction( options ) ) {
 
// Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
options = options.call( elem, i, curOffset );
}
 
if ( options.top != null ) {
@@ -74,48 +71,42 @@
}
};
 
jQuery.fn.extend( {
jQuery.fn.extend({
offset: function( options ) {
 
// Preserve chaining for setter
if ( arguments.length ) {
return options === undefined ?
this :
this.each( function( i ) {
this.each(function( i ) {
jQuery.offset.setOffset( this, options, i );
} );
});
}
 
var docElem, win, rect, doc,
elem = this[ 0 ];
var docElem, win,
elem = this[ 0 ],
box = { top: 0, left: 0 },
doc = elem && elem.ownerDocument;
 
if ( !elem ) {
if ( !doc ) {
return;
}
 
// Support: IE <=11 only
// Running getBoundingClientRect on a
// disconnected node in IE throws an error
if ( !elem.getClientRects().length ) {
return { top: 0, left: 0 };
docElem = doc.documentElement;
 
// Make sure it's not a disconnected DOM node
if ( !jQuery.contains( docElem, elem ) ) {
return box;
}
 
rect = elem.getBoundingClientRect();
 
// Make sure element is not hidden (display: none)
if ( rect.width || rect.height ) {
doc = elem.ownerDocument;
win = getWindow( doc );
docElem = doc.documentElement;
 
return {
top: rect.top + win.pageYOffset - docElem.clientTop,
left: rect.left + win.pageXOffset - docElem.clientLeft
};
// Support: BlackBerry 5, iOS 3 (original iPhone)
// If we don't have gBCR, just use 0,0 rather than error
if ( typeof elem.getBoundingClientRect !== strundefined ) {
box = elem.getBoundingClientRect();
}
 
// Return zeros for disconnected and hidden elements (gh-2310)
return rect;
win = getWindow( doc );
return {
top: box.top + win.pageYOffset - docElem.clientTop,
left: box.left + win.pageXOffset - docElem.clientLeft
};
},
 
position: function() {
@@ -127,15 +118,12 @@
elem = this[ 0 ],
parentOffset = { top: 0, left: 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" ) {
 
// Assume getBoundingClientRect is there when computed position is fixed
offset = elem.getBoundingClientRect();
 
} else {
 
// Get *real* offsetParent
offsetParent = this.offsetParent();
 
@@ -146,10 +134,8 @@
}
 
// Add offsetParent borders
parentOffset = {
top: parentOffset.top + jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ),
left: parentOffset.left + jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true )
};
parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
}
 
// Subtract parent offsets and element margins
@@ -159,28 +145,18 @@
};
},
 
// This method will return documentElement in the following cases:
// 1) For the element inside the iframe without offsetParent, this method will return
// documentElement of the parent window
// 2) For the hidden or detached element
// 3) For body or html element, i.e. in case of the html node - it will return itself
//
// but those exceptions were never presented as a real life use-cases
// and might be considered as more preferable results.
//
// This logic, however, is not guaranteed and can change at any point in the future
offsetParent: function() {
return this.map( function() {
var offsetParent = this.offsetParent;
return this.map(function() {
var offsetParent = this.offsetParent || docElem;
 
while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) {
offsetParent = offsetParent.offsetParent;
}
 
return offsetParent || documentElement;
} );
return offsetParent || docElem;
});
}
} );
});
 
// Create scrollLeft and scrollTop methods
jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
@@ -196,21 +172,21 @@
 
if ( win ) {
win.scrollTo(
!top ? val : win.pageXOffset,
top ? val : win.pageYOffset
!top ? val : window.pageXOffset,
top ? val : window.pageYOffset
);
 
} else {
elem[ method ] = val;
}
}, method, val, arguments.length );
}, method, val, arguments.length, null );
};
} );
});
 
// Support: Safari <=7 - 9.1, Chrome <=37 - 49
// Support: Safari<7+, Chrome<37+
// Add the top/left cssHooks using jQuery.fn.position
// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
// Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
// Blink bug: https://code.google.com/p/chromium/issues/detail?id=229280
// getComputedStyle returns percent when specified for top/left/bottom/right;
// rather than make the css module depend on the offset module, just check for it here
jQuery.each( [ "top", "left" ], function( i, prop ) {
@@ -218,7 +194,6 @@
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" :
@@ -226,7 +201,7 @@
}
}
);
} );
});
 
return jQuery;
} );
});