Project

General

Profile

1
define( [
2
	"./core",
3
	"./core/access",
4
	"./css"
5
], function( jQuery, access ) {
6

    
7
"use strict";
8

    
9
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
10
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
11
	jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
12
		function( defaultExtra, funcName ) {
13

    
14
		// Margin is only for outerHeight, outerWidth
15
		jQuery.fn[ funcName ] = function( margin, value ) {
16
			var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
17
				extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
18

    
19
			return access( this, function( elem, type, value ) {
20
				var doc;
21

    
22
				if ( jQuery.isWindow( elem ) ) {
23

    
24
					// $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
25
					return funcName.indexOf( "outer" ) === 0 ?
26
						elem[ "inner" + name ] :
27
						elem.document.documentElement[ "client" + name ];
28
				}
29

    
30
				// Get document width or height
31
				if ( elem.nodeType === 9 ) {
32
					doc = elem.documentElement;
33

    
34
					// Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
35
					// whichever is greatest
36
					return Math.max(
37
						elem.body[ "scroll" + name ], doc[ "scroll" + name ],
38
						elem.body[ "offset" + name ], doc[ "offset" + name ],
39
						doc[ "client" + name ]
40
					);
41
				}
42

    
43
				return value === undefined ?
44

    
45
					// Get width or height on the element, requesting but not forcing parseFloat
46
					jQuery.css( elem, type, extra ) :
47

    
48
					// Set width or height on the element
49
					jQuery.style( elem, type, value, extra );
50
			}, type, chainable ? margin : undefined, chainable );
51
		};
52
	} );
53
} );
54

    
55
return jQuery;
56
} );
(10-10/22)