2012-05-25 01:52:35 +00:00
|
|
|
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
|
2011-12-06 20:25:38 +00:00
|
|
|
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
|
2012-05-25 01:52:35 +00:00
|
|
|
jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
|
|
|
|
// margin is only for outerHeight, outerWidth
|
|
|
|
jQuery.fn[ funcName ] = function( margin, value ) {
|
|
|
|
var clientProp = "client" + name,
|
|
|
|
scrollProp = "scroll" + name,
|
|
|
|
offsetProp = "offset" + name,
|
|
|
|
chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
|
|
|
|
extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
|
|
|
|
|
|
|
|
return jQuery.access( this, function( elem, type, value ) {
|
|
|
|
var doc;
|
|
|
|
|
|
|
|
if ( jQuery.isWindow( elem ) ) {
|
|
|
|
// As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
|
|
|
|
// isn't a whole lot we can do. See pull request at this URL for discussion:
|
|
|
|
// https://github.com/jquery/jquery/pull/764
|
|
|
|
return elem.document.documentElement[ clientProp ];
|
2012-02-25 18:13:16 +00:00
|
|
|
}
|
|
|
|
|
2012-05-25 01:52:35 +00:00
|
|
|
// Get document width or height
|
|
|
|
if ( elem.nodeType === 9 ) {
|
|
|
|
doc = elem.documentElement;
|
|
|
|
|
2012-05-29 12:46:00 +00:00
|
|
|
// Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
|
|
|
|
// unfortunately, this causes bug #3838 in IE6 only, but there is currently no good, small way to fix it.
|
2012-05-25 01:52:35 +00:00
|
|
|
return Math.max(
|
|
|
|
elem.body[ scrollProp ], doc[ scrollProp ],
|
2012-05-29 12:46:00 +00:00
|
|
|
elem.body[ offsetProp ], doc[ offsetProp ],
|
|
|
|
doc[ clientProp ]
|
2012-05-25 01:52:35 +00:00
|
|
|
);
|
|
|
|
}
|
2010-10-22 06:39:06 +00:00
|
|
|
|
2012-05-25 01:52:35 +00:00
|
|
|
return value === undefined ?
|
|
|
|
// Get width or height on the element, requesting but not forcing parseFloat
|
|
|
|
jQuery.css( elem, type, value, extra ) :
|
2010-11-09 16:09:07 +00:00
|
|
|
|
2012-05-25 01:52:35 +00:00
|
|
|
// Set width or height on the element
|
|
|
|
jQuery.style( elem, type, value, extra );
|
|
|
|
}, type, chainable ? margin : undefined, chainable );
|
|
|
|
};
|
|
|
|
});
|
2009-02-13 22:58:57 +00:00
|
|
|
});
|