aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2007-09-09 22:59:41 +0000
committerJohn Resig <jeresig@gmail.com>2007-09-09 22:59:41 +0000
commit139b03af7c2d7e70a26591424f82f09a02132198 (patch)
treee496f35a74b9c1fdf3621aa9975f588eef58e7f8
parent052aa1445a780f69576a800836be73b57b62a909 (diff)
downloadjquery-139b03af7c2d7e70a26591424f82f09a02132198.tar.gz
jquery-139b03af7c2d7e70a26591424f82f09a02132198.zip
Landing a version of $(document)/$(window) .width()/.height(). It won't win any awards, but it'll hold us over for this release.
-rw-r--r--src/core.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/core.js b/src/core.js
index bedafdce2..3fb59f8d5 100644
--- a/src/core.js
+++ b/src/core.js
@@ -1080,10 +1080,20 @@ jQuery.each( {
};
});
-jQuery.each( [ "height", "width" ], function(i,n){
+jQuery.each( [ "Height", "Width" ], function(i,name){
+ var n = name.toLowerCase();
+
jQuery.fn[ n ] = function(h) {
- return h == undefined ?
- ( this.length ? jQuery.css( this[0], n ) : null ) :
- this.css( n, h.constructor == String ? h : h + "px" );
+ return this[0] == window ?
+ jQuery.browser.safari && self["inner" + name] ||
+ jQuery.boxModel && Math.max(document.documentElement["client" + name], document.body["client" + name]) ||
+ document.body["client" + name] :
+
+ this[0] == document ?
+ Math.max( document.body["scroll" + name], document.body["offset" + name] ) :
+
+ h == undefined ?
+ ( this.length ? jQuery.css( this[0], n ) : null ) :
+ this.css( n, h.constructor == String ? h : h + "px" );
};
});