ffffng/app/bower_components/jquery/src/dimensions.js

58 lines
1.7 KiB
JavaScript
Raw Normal View History

2017-05-13 13:25:33 +02:00
define( [
2014-05-12 20:08:19 +02:00
"./core",
"./core/access",
2019-03-29 22:00:08 +01:00
"./var/isWindow",
2014-05-12 20:08:19 +02:00
"./css"
2019-03-29 22:00:08 +01:00
], function( jQuery, access, isWindow ) {
2014-05-12 20:08:19 +02:00
2017-05-13 13:25:33 +02:00
"use strict";
2014-05-12 20:08:19 +02:00
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
2017-05-13 13:25:33 +02:00
jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
function( defaultExtra, funcName ) {
2016-05-16 13:33:49 +02:00
// Margin is only for outerHeight, outerWidth
2014-05-12 20:08:19 +02:00
jQuery.fn[ funcName ] = function( margin, value ) {
var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
return access( this, function( elem, type, value ) {
var doc;
2019-03-29 22:00:08 +01:00
if ( isWindow( elem ) ) {
2017-05-13 13:25:33 +02:00
// $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
return funcName.indexOf( "outer" ) === 0 ?
elem[ "inner" + name ] :
elem.document.documentElement[ "client" + name ];
2014-05-12 20:08:19 +02:00
}
// Get document width or height
if ( elem.nodeType === 9 ) {
doc = elem.documentElement;
// Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
// whichever is greatest
return Math.max(
elem.body[ "scroll" + name ], doc[ "scroll" + name ],
elem.body[ "offset" + name ], doc[ "offset" + name ],
doc[ "client" + name ]
);
}
return value === undefined ?
2017-05-13 13:25:33 +02:00
2014-05-12 20:08:19 +02:00
// Get width or height on the element, requesting but not forcing parseFloat
jQuery.css( elem, type, extra ) :
// Set width or height on the element
jQuery.style( elem, type, value, extra );
2017-05-13 13:25:33 +02:00
}, type, chainable ? margin : undefined, chainable );
2014-05-12 20:08:19 +02:00
};
2017-05-13 13:25:33 +02:00
} );
} );
2014-05-12 20:08:19 +02:00
return jQuery;
2017-05-13 13:25:33 +02:00
} );