mirror of
https://github.com/jquery/jquery.git
synced 2026-02-10 16:25:02 -05:00
Apply consistent ordering in all modules. -219 bytes. Order modules like functions > jQuery.extend > jQuery.fn.extend.
This commit is contained in:
@@ -8,45 +8,18 @@ define([
|
||||
|
||||
var docElem = window.document.documentElement;
|
||||
|
||||
jQuery.fn.offset = function( options ) {
|
||||
if ( arguments.length ) {
|
||||
return options === undefined ?
|
||||
this :
|
||||
this.each(function( i ) {
|
||||
jQuery.offset.setOffset( this, options, i );
|
||||
});
|
||||
}
|
||||
|
||||
var docElem, win,
|
||||
box = { top: 0, left: 0 },
|
||||
elem = this[ 0 ],
|
||||
doc = elem && elem.ownerDocument;
|
||||
|
||||
if ( !doc ) {
|
||||
return;
|
||||
}
|
||||
|
||||
docElem = doc.documentElement;
|
||||
|
||||
// Make sure it's not a disconnected DOM node
|
||||
if ( !jQuery.contains( docElem, elem ) ) {
|
||||
return box;
|
||||
}
|
||||
|
||||
// If we don't have gBCR, just use 0,0 rather than error
|
||||
// BlackBerry 5, iOS 3 (original iPhone)
|
||||
if ( typeof elem.getBoundingClientRect !== strundefined ) {
|
||||
box = elem.getBoundingClientRect();
|
||||
}
|
||||
win = getWindow( doc );
|
||||
return {
|
||||
top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
|
||||
left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Gets a window from an element
|
||||
*/
|
||||
function getWindow( elem ) {
|
||||
return jQuery.isWindow( elem ) ?
|
||||
elem :
|
||||
elem.nodeType === 9 ?
|
||||
elem.defaultView || elem.parentWindow :
|
||||
false;
|
||||
}
|
||||
|
||||
jQuery.offset = {
|
||||
|
||||
setOffset: function( elem, options, i ) {
|
||||
var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
|
||||
position = jQuery.css( elem, "position" ),
|
||||
@@ -93,8 +66,43 @@ jQuery.offset = {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
jQuery.fn.extend({
|
||||
offset: function( options ) {
|
||||
if ( arguments.length ) {
|
||||
return options === undefined ?
|
||||
this :
|
||||
this.each(function( i ) {
|
||||
jQuery.offset.setOffset( this, options, i );
|
||||
});
|
||||
}
|
||||
|
||||
var docElem, win,
|
||||
box = { top: 0, left: 0 },
|
||||
elem = this[ 0 ],
|
||||
doc = elem && elem.ownerDocument;
|
||||
|
||||
if ( !doc ) {
|
||||
return;
|
||||
}
|
||||
|
||||
docElem = doc.documentElement;
|
||||
|
||||
// Make sure it's not a disconnected DOM node
|
||||
if ( !jQuery.contains( docElem, elem ) ) {
|
||||
return box;
|
||||
}
|
||||
|
||||
// If we don't have gBCR, just use 0,0 rather than error
|
||||
// BlackBerry 5, iOS 3 (original iPhone)
|
||||
if ( typeof elem.getBoundingClientRect !== strundefined ) {
|
||||
box = elem.getBoundingClientRect();
|
||||
}
|
||||
win = getWindow( doc );
|
||||
return {
|
||||
top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
|
||||
left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
|
||||
};
|
||||
},
|
||||
|
||||
position: function() {
|
||||
if ( !this[ 0 ] ) {
|
||||
@@ -145,17 +153,6 @@ jQuery.fn.extend({
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Gets a window from an element
|
||||
*/
|
||||
function getWindow( elem ) {
|
||||
return jQuery.isWindow( elem ) ?
|
||||
elem :
|
||||
elem.nodeType === 9 ?
|
||||
elem.defaultView || elem.parentWindow :
|
||||
false;
|
||||
}
|
||||
|
||||
// Create scrollLeft and scrollTop methods
|
||||
jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) {
|
||||
var top = /Y/.test( prop );
|
||||
|
||||
Reference in New Issue
Block a user