git.asbjorn.biz
/
jquery.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix width/height to work properly on window/document
[jquery.git]
/
src
/
core.js
diff --git
a/src/core.js
b/src/core.js
index
d059564
..
960af44
100644
(file)
--- a/
src/core.js
+++ b/
src/core.js
@@
-282,7
+282,7
@@
jQuery.fn = jQuery.prototype = {
this.get(),
t.constructor == String ?
jQuery(t).get() :
this.get(),
t.constructor == String ?
jQuery(t).get() :
- t.length != undefined && (!t.nodeName || t.nodeName == "FORM") ?
+ t.length != undefined && (!t.nodeName || jQuery.nodeName(t, "form")) ?
t : [t] )
);
},
t : [t] )
);
},
@@
-1114,16
+1114,27
@@
jQuery.each( [ "Height", "Width" ], function(i,name){
var n = name.toLowerCase();
jQuery.fn[ n ] = function(h) {
var n = name.toLowerCase();
jQuery.fn[ n ] = function(h) {
+ // Get window width or height
return this[0] == window ?
return this[0] == window ?
+ // Opera reports document.body.client[Width/Height] properly in both quirks and standards
+ jQuery.browser.opera && document.body["client" + name] ||
+
+ // Safari reports inner[Width/Height] just fine (Mozilla and Opera include scroll bar widths)
jQuery.browser.safari && self["inner" + name] ||
jQuery.browser.safari && self["inner" + name] ||
- jQuery.boxModel && Math.max(document.documentElement["client" + name], document.body["client" + name]) ||
- document.body["client" + name] :
+
+ // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
+ jQuery.boxModel && document.documentElement["client" + name] || document.body["client" + name] :
+ // Get document width or height
this[0] == document ?
this[0] == document ?
+ // Either scroll[Width/Height] or offset[Width/Height], whichever is greater (Mozilla reports scrollWidth the same as offsetWidth)
Math.max( document.body["scroll" + name], document.body["offset" + name] ) :
Math.max( document.body["scroll" + name], document.body["offset" + name] ) :
+ // Get or set width or height on the element
h == undefined ?
h == undefined ?
+ // Get width or height on the element
( this.length ? jQuery.css( this[0], n ) : null ) :
( this.length ? jQuery.css( this[0], n ) : null ) :
+ // Set the width or height on the element (default to pixels if value is unitless)
this.css( n, h.constructor == String ? h : h + "px" );
};
});
this.css( n, h.constructor == String ? h : h + "px" );
};
});