Removing the old cow image from the effects tests - it's no longer needed. Fixes...
[jquery.git] / src / dimensions.js
1 (function( jQuery ) {
2
3 // Create innerHeight, innerWidth, outerHeight and outerWidth methods
4 jQuery.each([ "Height", "Width" ], function( i, name ) {
5
6         var type = name.toLowerCase();
7
8         // innerHeight and innerWidth
9         jQuery.fn["inner" + name] = function() {
10                 return this[0] ?
11                         parseFloat( jQuery.css( this[0], type, "padding" ) ) :
12                         null;
13         };
14
15         // outerHeight and outerWidth
16         jQuery.fn["outer" + name] = function( margin ) {
17                 return this[0] ?
18                         parseFloat( jQuery.css( this[0], type, margin ? "margin" : "border" ) ) :
19                         null;
20         };
21
22         jQuery.fn[ type ] = function( size ) {
23                 // Get window width or height
24                 var elem = this[0];
25                 if ( !elem ) {
26                         return size == null ? null : this;
27                 }
28                 
29                 if ( jQuery.isFunction( size ) ) {
30                         return this.each(function( i ) {
31                                 var self = jQuery( this );
32                                 self[ type ]( size.call( this, i, self[ type ]() ) );
33                         });
34                 }
35
36                 return jQuery.isWindow( elem ) ?
37                         // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
38                         elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] ||
39                         elem.document.body[ "client" + name ] :
40
41                         // Get document width or height
42                         (elem.nodeType === 9) ? // is it a document
43                                 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
44                                 Math.max(
45                                         elem.documentElement["client" + name],
46                                         elem.body["scroll" + name], elem.documentElement["scroll" + name],
47                                         elem.body["offset" + name], elem.documentElement["offset" + name]
48                                 ) :
49
50                                 // Get or set width or height on the element
51                                 size === undefined ?
52                                         // Get width or height on the element
53                                         parseFloat( jQuery.css( elem, type ) ) :
54
55                                         // Set the width or height on the element (default to pixels if value is unitless)
56                                         this.css( type, typeof size === "string" ? size : size + "px" );
57         };
58
59 });
60
61 })( jQuery );