fix for #4399, removing unused variables
[jquery.git] / src / dimensions.js
1 // Create innerHeight, innerWidth, outerHeight and outerWidth methods
2 jQuery.each([ "Height", "Width" ], function(i, name){
3
4         var type = name.toLowerCase();
5
6         // innerHeight and innerWidth
7         jQuery.fn["inner" + name] = function(){
8                 return this[0] ?
9                         jQuery.css( this[0], type, false, "padding" ) :
10                         null;
11         };
12
13         // outerHeight and outerWidth
14         jQuery.fn["outer" + name] = function(margin) {
15                 return this[0] ?
16                         jQuery.css( this[0], type, false, margin ? "margin" : "border" ) :
17                         null;
18         };
19         
20         jQuery.fn[ type ] = function( size ) {
21                 // Get window width or height
22                 return this[0] == window ?
23                         // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
24                         document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] ||
25                         document.body[ "client" + name ] :
26
27                         // Get document width or height
28                         this[0] == document ?
29                                 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
30                                 Math.max(
31                                         document.documentElement["client" + name],
32                                         document.body["scroll" + name], document.documentElement["scroll" + name],
33                                         document.body["offset" + name], document.documentElement["offset" + name]
34                                 ) :
35
36                                 // Get or set width or height on the element
37                                 size === undefined ?
38                                         // Get width or height on the element
39                                         (this.length ? jQuery.css( this[0], type ) : null) :
40
41                                         // Set the width or height on the element (default to pixels if value is unitless)
42                                         this.css( type, typeof size === "string" ? size : size + "px" );
43         };
44
45 });