1
|
define([
|
2
|
"./core",
|
3
|
"./core/access",
|
4
|
"./css"
|
5
|
], function( jQuery, access ) {
|
6
|
|
7
|
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
|
8
|
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
|
9
|
jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
|
10
|
// Margin is only for outerHeight, outerWidth
|
11
|
jQuery.fn[ funcName ] = function( margin, value ) {
|
12
|
var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
|
13
|
extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
|
14
|
|
15
|
return access( this, function( elem, type, value ) {
|
16
|
var doc;
|
17
|
|
18
|
if ( jQuery.isWindow( elem ) ) {
|
19
|
// As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
|
20
|
// isn't a whole lot we can do. See pull request at this URL for discussion:
|
21
|
// https://github.com/jquery/jquery/pull/764
|
22
|
return elem.document.documentElement[ "client" + name ];
|
23
|
}
|
24
|
|
25
|
// Get document width or height
|
26
|
if ( elem.nodeType === 9 ) {
|
27
|
doc = elem.documentElement;
|
28
|
|
29
|
// Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
|
30
|
// whichever is greatest
|
31
|
return Math.max(
|
32
|
elem.body[ "scroll" + name ], doc[ "scroll" + name ],
|
33
|
elem.body[ "offset" + name ], doc[ "offset" + name ],
|
34
|
doc[ "client" + name ]
|
35
|
);
|
36
|
}
|
37
|
|
38
|
return value === undefined ?
|
39
|
// Get width or height on the element, requesting but not forcing parseFloat
|
40
|
jQuery.css( elem, type, extra ) :
|
41
|
|
42
|
// Set width or height on the element
|
43
|
jQuery.style( elem, type, value, extra );
|
44
|
}, type, chainable ? margin : undefined, chainable, null );
|
45
|
};
|
46
|
});
|
47
|
});
|
48
|
|
49
|
return jQuery;
|
50
|
});
|