]> source.dussan.org Git - jquery.git/commitdiff
Landing a version of $(document)/$(window) .width()/.height(). It won't win any award...
authorJohn Resig <jeresig@gmail.com>
Sun, 9 Sep 2007 22:59:41 +0000 (22:59 +0000)
committerJohn Resig <jeresig@gmail.com>
Sun, 9 Sep 2007 22:59:41 +0000 (22:59 +0000)
src/core.js

index bedafdce2fb93e769aaad449406a9ab096b139cd..3fb59f8d5e52f68303023c2549c7ab895318f10b 100644 (file)
@@ -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" );
        };
 });