aboutsummaryrefslogtreecommitdiffstats
path: root/src/dimensions.js
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2008-12-21 21:22:44 +0000
committerJohn Resig <jeresig@gmail.com>2008-12-21 21:22:44 +0000
commitb850ab2b8e65eadd25093c81bbc67a881daa0488 (patch)
treedf385b3c4b165384f3a6c4ade60760b94db8cac4 /src/dimensions.js
parent8ee1708ea93517f69979a6805480597b96b58da7 (diff)
downloadjquery-b850ab2b8e65eadd25093c81bbc67a881daa0488.tar.gz
jquery-b850ab2b8e65eadd25093c81bbc67a881daa0488.zip
Added the new jQuery.support object and removed all uses of jQuery.browser from within jQuery itself (while simultaneously deprecating the use of jQuery.browser).
Diffstat (limited to 'src/dimensions.js')
-rw-r--r--src/dimensions.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/dimensions.js b/src/dimensions.js
index bcef47fdf..297118457 100644
--- a/src/dimensions.js
+++ b/src/dimensions.js
@@ -19,5 +19,32 @@ jQuery.each([ "Height", "Width" ], function(i, name){
(margin ?
num(this, "margin" + tl) + num(this, "margin" + br) : 0);
};
+
+ var type = name.toLowerCase();
+
+ jQuery.fn[ type ] = function( size ) {
+ // Get window width or height
+ return this[0] == window ?
+ // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
+ document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] ||
+ document.body[ "client" + name ] :
+
+ // Get document width or height
+ this[0] == document ?
+ // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
+ Math.max(
+ document.documentElement["client" + name],
+ document.body["scroll" + name], document.documentElement["scroll" + name],
+ document.body["offset" + name], document.documentElement["offset" + name]
+ ) :
+
+ // Get or set width or height on the element
+ size === undefined ?
+ // Get width or height on the element
+ (this.length ? jQuery.css( this[0], type ) : null) :
+
+ // Set the width or height on the element (default to pixels if value is unitless)
+ this.css( type, typeof size === "string" ? size : size + "px" );
+ };
}); \ No newline at end of file