2017-05-13 13:25:33 +02:00
|
|
|
define( [
|
2014-05-12 20:08:19 +02:00
|
|
|
"./core",
|
|
|
|
"./var/pnum",
|
|
|
|
"./core/access",
|
2019-03-29 22:00:08 +01:00
|
|
|
"./core/camelCase",
|
2017-05-13 13:25:33 +02:00
|
|
|
"./var/document",
|
|
|
|
"./var/rcssNum",
|
2014-05-12 20:08:19 +02:00
|
|
|
"./css/var/rnumnonpx",
|
|
|
|
"./css/var/cssExpand",
|
|
|
|
"./css/var/getStyles",
|
2017-05-13 13:25:33 +02:00
|
|
|
"./css/var/swap",
|
2014-05-12 20:08:19 +02:00
|
|
|
"./css/curCSS",
|
2017-05-13 13:25:33 +02:00
|
|
|
"./css/adjustCSS",
|
2014-05-12 20:08:19 +02:00
|
|
|
"./css/addGetHookIf",
|
|
|
|
"./css/support",
|
|
|
|
|
|
|
|
"./core/init",
|
|
|
|
"./core/ready",
|
|
|
|
"./selector" // contains
|
2019-03-29 22:00:08 +01:00
|
|
|
], function( jQuery, pnum, access, camelCase, document, rcssNum, rnumnonpx, cssExpand,
|
2017-05-13 13:25:33 +02:00
|
|
|
getStyles, swap, curCSS, adjustCSS, addGetHookIf, support ) {
|
|
|
|
|
|
|
|
"use strict";
|
2014-05-12 20:08:19 +02:00
|
|
|
|
|
|
|
var
|
2017-05-13 13:25:33 +02:00
|
|
|
|
|
|
|
// Swappable if display is none or starts with table
|
|
|
|
// except "table", "table-cell", or "table-caption"
|
2016-05-16 13:33:49 +02:00
|
|
|
// See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
|
2014-05-12 20:08:19 +02:00
|
|
|
rdisplayswap = /^(none|table(?!-c[ea]).+)/,
|
2017-05-13 13:25:33 +02:00
|
|
|
rcustomProp = /^--/,
|
2014-05-12 20:08:19 +02:00
|
|
|
cssShow = { position: "absolute", visibility: "hidden", display: "block" },
|
|
|
|
cssNormalTransform = {
|
|
|
|
letterSpacing: "0",
|
|
|
|
fontWeight: "400"
|
|
|
|
},
|
|
|
|
|
2017-05-13 13:25:33 +02:00
|
|
|
cssPrefixes = [ "Webkit", "Moz", "ms" ],
|
|
|
|
emptyStyle = document.createElement( "div" ).style;
|
2014-05-12 20:08:19 +02:00
|
|
|
|
2016-05-16 13:33:49 +02:00
|
|
|
// Return a css property mapped to a potentially vendor prefixed property
|
2017-05-13 13:25:33 +02:00
|
|
|
function vendorPropName( name ) {
|
2014-05-12 20:08:19 +02:00
|
|
|
|
2016-05-16 13:33:49 +02:00
|
|
|
// Shortcut for names that are not vendor prefixed
|
2017-05-13 13:25:33 +02:00
|
|
|
if ( name in emptyStyle ) {
|
2014-05-12 20:08:19 +02:00
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2016-05-16 13:33:49 +02:00
|
|
|
// Check for vendor prefixed names
|
2017-05-13 13:25:33 +02:00
|
|
|
var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
|
2014-05-12 20:08:19 +02:00
|
|
|
i = cssPrefixes.length;
|
|
|
|
|
|
|
|
while ( i-- ) {
|
|
|
|
name = cssPrefixes[ i ] + capName;
|
2017-05-13 13:25:33 +02:00
|
|
|
if ( name in emptyStyle ) {
|
2014-05-12 20:08:19 +02:00
|
|
|
return name;
|
|
|
|
}
|
|
|
|
}
|
2017-05-13 13:25:33 +02:00
|
|
|
}
|
2014-05-12 20:08:19 +02:00
|
|
|
|
2017-05-13 13:25:33 +02:00
|
|
|
// Return a property mapped along what jQuery.cssProps suggests or to
|
|
|
|
// a vendor prefixed property.
|
|
|
|
function finalPropName( name ) {
|
|
|
|
var ret = jQuery.cssProps[ name ];
|
|
|
|
if ( !ret ) {
|
|
|
|
ret = jQuery.cssProps[ name ] = vendorPropName( name ) || name;
|
|
|
|
}
|
|
|
|
return ret;
|
2014-05-12 20:08:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function setPositiveNumber( elem, value, subtract ) {
|
2017-05-13 13:25:33 +02:00
|
|
|
|
|
|
|
// Any relative (+/-) values have already been
|
|
|
|
// normalized at this point
|
|
|
|
var matches = rcssNum.exec( value );
|
2014-05-12 20:08:19 +02:00
|
|
|
return matches ?
|
2017-05-13 13:25:33 +02:00
|
|
|
|
2014-05-12 20:08:19 +02:00
|
|
|
// Guard against undefined "subtract", e.g., when used as in cssHooks
|
2017-05-13 13:25:33 +02:00
|
|
|
Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
|
2014-05-12 20:08:19 +02:00
|
|
|
value;
|
|
|
|
}
|
|
|
|
|
2019-03-29 22:00:08 +01:00
|
|
|
function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
|
|
|
|
var i = dimension === "width" ? 1 : 0,
|
|
|
|
extra = 0,
|
|
|
|
delta = 0;
|
2014-05-12 20:08:19 +02:00
|
|
|
|
2019-03-29 22:00:08 +01:00
|
|
|
// Adjustment may not be necessary
|
|
|
|
if ( box === ( isBorderBox ? "border" : "content" ) ) {
|
|
|
|
return 0;
|
2017-05-13 13:25:33 +02:00
|
|
|
}
|
|
|
|
|
2014-05-12 20:08:19 +02:00
|
|
|
for ( ; i < 4; i += 2 ) {
|
2017-05-13 13:25:33 +02:00
|
|
|
|
2019-03-29 22:00:08 +01:00
|
|
|
// Both box models exclude margin
|
|
|
|
if ( box === "margin" ) {
|
|
|
|
delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
|
2014-05-12 20:08:19 +02:00
|
|
|
}
|
|
|
|
|
2019-03-29 22:00:08 +01:00
|
|
|
// If we get here with a content-box, we're seeking "padding" or "border" or "margin"
|
|
|
|
if ( !isBorderBox ) {
|
2017-05-13 13:25:33 +02:00
|
|
|
|
2019-03-29 22:00:08 +01:00
|
|
|
// Add padding
|
|
|
|
delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
|
2014-05-12 20:08:19 +02:00
|
|
|
|
2019-03-29 22:00:08 +01:00
|
|
|
// For "border" or "margin", add border
|
|
|
|
if ( box !== "padding" ) {
|
|
|
|
delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
|
|
|
|
|
|
|
|
// But still keep track of it otherwise
|
|
|
|
} else {
|
|
|
|
extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
|
2014-05-12 20:08:19 +02:00
|
|
|
}
|
2019-03-29 22:00:08 +01:00
|
|
|
|
|
|
|
// If we get here with a border-box (content + padding + border), we're seeking "content" or
|
|
|
|
// "padding" or "margin"
|
2014-05-12 20:08:19 +02:00
|
|
|
} else {
|
2017-05-13 13:25:33 +02:00
|
|
|
|
2019-03-29 22:00:08 +01:00
|
|
|
// For "content", subtract padding
|
|
|
|
if ( box === "content" ) {
|
|
|
|
delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
|
|
|
|
}
|
2014-05-12 20:08:19 +02:00
|
|
|
|
2019-03-29 22:00:08 +01:00
|
|
|
// For "content" or "padding", subtract border
|
|
|
|
if ( box !== "margin" ) {
|
|
|
|
delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
|
2014-05-12 20:08:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-29 22:00:08 +01:00
|
|
|
// Account for positive content-box scroll gutter when requested by providing computedVal
|
|
|
|
if ( !isBorderBox && computedVal >= 0 ) {
|
|
|
|
|
|
|
|
// offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
|
|
|
|
// Assuming integer scroll gutter, subtract the rest and round down
|
|
|
|
delta += Math.max( 0, Math.ceil(
|
|
|
|
elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
|
|
|
|
computedVal -
|
|
|
|
delta -
|
|
|
|
extra -
|
|
|
|
0.5
|
|
|
|
) );
|
|
|
|
}
|
|
|
|
|
|
|
|
return delta;
|
2014-05-12 20:08:19 +02:00
|
|
|
}
|
|
|
|
|
2019-03-29 22:00:08 +01:00
|
|
|
function getWidthOrHeight( elem, dimension, extra ) {
|
2014-05-12 20:08:19 +02:00
|
|
|
|
2017-05-13 13:25:33 +02:00
|
|
|
// Start with computed style
|
2019-03-29 22:00:08 +01:00
|
|
|
var styles = getStyles( elem ),
|
|
|
|
val = curCSS( elem, dimension, styles ),
|
|
|
|
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
|
|
|
|
valueIsBorderBox = isBorderBox;
|
2014-05-12 20:08:19 +02:00
|
|
|
|
2019-03-29 22:00:08 +01:00
|
|
|
// Support: Firefox <=54
|
|
|
|
// Return a confounding non-pixel value or feign ignorance, as appropriate.
|
2017-05-13 13:25:33 +02:00
|
|
|
if ( rnumnonpx.test( val ) ) {
|
2019-03-29 22:00:08 +01:00
|
|
|
if ( !extra ) {
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
val = "auto";
|
2017-05-13 13:25:33 +02:00
|
|
|
}
|
2014-05-12 20:08:19 +02:00
|
|
|
|
2017-05-13 13:25:33 +02:00
|
|
|
// Check for style in case a browser which returns unreliable values
|
|
|
|
// for getComputedStyle silently falls back to the reliable elem.style
|
2019-03-29 22:00:08 +01:00
|
|
|
valueIsBorderBox = valueIsBorderBox &&
|
|
|
|
( support.boxSizingReliable() || val === elem.style[ dimension ] );
|
2014-05-12 20:08:19 +02:00
|
|
|
|
2019-03-29 22:00:08 +01:00
|
|
|
// Fall back to offsetWidth/offsetHeight when value is "auto"
|
2017-05-13 13:25:33 +02:00
|
|
|
// This happens for inline elements with no explicit setting (gh-3571)
|
2019-03-29 22:00:08 +01:00
|
|
|
// Support: Android <=4.1 - 4.3 only
|
|
|
|
// Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
|
|
|
|
if ( val === "auto" ||
|
|
|
|
!parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) {
|
|
|
|
|
|
|
|
val = elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ];
|
|
|
|
|
|
|
|
// offsetWidth/offsetHeight provide border-box values
|
|
|
|
valueIsBorderBox = true;
|
2014-05-12 20:08:19 +02:00
|
|
|
}
|
|
|
|
|
2019-03-29 22:00:08 +01:00
|
|
|
// Normalize "" and auto
|
2017-05-13 13:25:33 +02:00
|
|
|
val = parseFloat( val ) || 0;
|
|
|
|
|
2019-03-29 22:00:08 +01:00
|
|
|
// Adjust for the element's box model
|
2014-05-12 20:08:19 +02:00
|
|
|
return ( val +
|
2019-03-29 22:00:08 +01:00
|
|
|
boxModelAdjustment(
|
2014-05-12 20:08:19 +02:00
|
|
|
elem,
|
2019-03-29 22:00:08 +01:00
|
|
|
dimension,
|
2014-05-12 20:08:19 +02:00
|
|
|
extra || ( isBorderBox ? "border" : "content" ),
|
|
|
|
valueIsBorderBox,
|
2019-03-29 22:00:08 +01:00
|
|
|
styles,
|
|
|
|
|
|
|
|
// Provide the current computed size to request scroll gutter calculation (gh-3589)
|
|
|
|
val
|
2014-05-12 20:08:19 +02:00
|
|
|
)
|
|
|
|
) + "px";
|
|
|
|
}
|
|
|
|
|
2017-05-13 13:25:33 +02:00
|
|
|
jQuery.extend( {
|
2016-05-16 13:33:49 +02:00
|
|
|
|
2014-05-12 20:08:19 +02:00
|
|
|
// Add in style property hooks for overriding the default
|
|
|
|
// behavior of getting and setting a style property
|
|
|
|
cssHooks: {
|
|
|
|
opacity: {
|
|
|
|
get: function( elem, computed ) {
|
|
|
|
if ( computed ) {
|
2016-05-16 13:33:49 +02:00
|
|
|
|
2014-05-12 20:08:19 +02:00
|
|
|
// We should always get a number back from opacity
|
|
|
|
var ret = curCSS( elem, "opacity" );
|
|
|
|
return ret === "" ? "1" : ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// Don't automatically add "px" to these possibly-unitless properties
|
|
|
|
cssNumber: {
|
2017-05-13 13:25:33 +02:00
|
|
|
"animationIterationCount": true,
|
2014-05-12 20:08:19 +02:00
|
|
|
"columnCount": true,
|
|
|
|
"fillOpacity": true,
|
|
|
|
"flexGrow": true,
|
|
|
|
"flexShrink": true,
|
|
|
|
"fontWeight": true,
|
|
|
|
"lineHeight": true,
|
|
|
|
"opacity": true,
|
|
|
|
"order": true,
|
|
|
|
"orphans": true,
|
|
|
|
"widows": true,
|
|
|
|
"zIndex": true,
|
|
|
|
"zoom": true
|
|
|
|
},
|
|
|
|
|
|
|
|
// Add in properties whose names you wish to fix before
|
|
|
|
// setting or getting the value
|
2019-03-29 22:00:08 +01:00
|
|
|
cssProps: {},
|
2014-05-12 20:08:19 +02:00
|
|
|
|
|
|
|
// Get and set the style property on a DOM Node
|
|
|
|
style: function( elem, name, value, extra ) {
|
2016-05-16 13:33:49 +02:00
|
|
|
|
2014-05-12 20:08:19 +02:00
|
|
|
// Don't set styles on text and comment nodes
|
|
|
|
if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure that we're working with the right name
|
|
|
|
var ret, type, hooks,
|
2019-03-29 22:00:08 +01:00
|
|
|
origName = camelCase( name ),
|
2017-05-13 13:25:33 +02:00
|
|
|
isCustomProp = rcustomProp.test( name ),
|
2014-05-12 20:08:19 +02:00
|
|
|
style = elem.style;
|
|
|
|
|
2017-05-13 13:25:33 +02:00
|
|
|
// Make sure that we're working with the right name. We don't
|
|
|
|
// want to query the value if it is a CSS custom property
|
|
|
|
// since they are user-defined.
|
|
|
|
if ( !isCustomProp ) {
|
|
|
|
name = finalPropName( origName );
|
|
|
|
}
|
2014-05-12 20:08:19 +02:00
|
|
|
|
2016-05-16 13:33:49 +02:00
|
|
|
// Gets hook for the prefixed version, then unprefixed version
|
2014-05-12 20:08:19 +02:00
|
|
|
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
|
|
|
|
|
|
|
|
// Check if we're setting a value
|
|
|
|
if ( value !== undefined ) {
|
|
|
|
type = typeof value;
|
|
|
|
|
2016-05-16 13:33:49 +02:00
|
|
|
// Convert "+=" or "-=" to relative numbers (#7345)
|
2017-05-13 13:25:33 +02:00
|
|
|
if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
|
|
|
|
value = adjustCSS( elem, name, ret );
|
|
|
|
|
2014-05-12 20:08:19 +02:00
|
|
|
// Fixes bug #9237
|
|
|
|
type = "number";
|
|
|
|
}
|
|
|
|
|
2016-05-16 13:33:49 +02:00
|
|
|
// Make sure that null and NaN values aren't set (#7116)
|
2014-05-12 20:08:19 +02:00
|
|
|
if ( value == null || value !== value ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-05-13 13:25:33 +02:00
|
|
|
// If a number was passed in, add the unit (except for certain CSS properties)
|
|
|
|
if ( type === "number" ) {
|
|
|
|
value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
|
2014-05-12 20:08:19 +02:00
|
|
|
}
|
|
|
|
|
2016-05-16 13:33:49 +02:00
|
|
|
// background-* props affect original clone's values
|
2014-05-12 20:08:19 +02:00
|
|
|
if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
|
|
|
|
style[ name ] = "inherit";
|
|
|
|
}
|
|
|
|
|
|
|
|
// If a hook was provided, use that value, otherwise just set the specified value
|
2017-05-13 13:25:33 +02:00
|
|
|
if ( !hooks || !( "set" in hooks ) ||
|
|
|
|
( value = hooks.set( elem, value, extra ) ) !== undefined ) {
|
|
|
|
|
|
|
|
if ( isCustomProp ) {
|
|
|
|
style.setProperty( name, value );
|
|
|
|
} else {
|
|
|
|
style[ name ] = value;
|
|
|
|
}
|
2014-05-12 20:08:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2017-05-13 13:25:33 +02:00
|
|
|
|
2014-05-12 20:08:19 +02:00
|
|
|
// If a hook was provided get the non-computed value from there
|
2017-05-13 13:25:33 +02:00
|
|
|
if ( hooks && "get" in hooks &&
|
|
|
|
( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
|
|
|
|
|
2014-05-12 20:08:19 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise just get the value from the style object
|
|
|
|
return style[ name ];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
css: function( elem, name, extra, styles ) {
|
|
|
|
var val, num, hooks,
|
2019-03-29 22:00:08 +01:00
|
|
|
origName = camelCase( name ),
|
2017-05-13 13:25:33 +02:00
|
|
|
isCustomProp = rcustomProp.test( name );
|
2014-05-12 20:08:19 +02:00
|
|
|
|
2017-05-13 13:25:33 +02:00
|
|
|
// Make sure that we're working with the right name. We don't
|
|
|
|
// want to modify the value if it is a CSS custom property
|
|
|
|
// since they are user-defined.
|
|
|
|
if ( !isCustomProp ) {
|
|
|
|
name = finalPropName( origName );
|
|
|
|
}
|
2014-05-12 20:08:19 +02:00
|
|
|
|
2016-05-16 13:33:49 +02:00
|
|
|
// Try prefixed name followed by the unprefixed name
|
2014-05-12 20:08:19 +02:00
|
|
|
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
|
|
|
|
|
|
|
|
// If a hook was provided get the computed value from there
|
|
|
|
if ( hooks && "get" in hooks ) {
|
|
|
|
val = hooks.get( elem, true, extra );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise, if a way to get the computed value exists, use that
|
|
|
|
if ( val === undefined ) {
|
|
|
|
val = curCSS( elem, name, styles );
|
|
|
|
}
|
|
|
|
|
2016-05-16 13:33:49 +02:00
|
|
|
// Convert "normal" to computed value
|
2014-05-12 20:08:19 +02:00
|
|
|
if ( val === "normal" && name in cssNormalTransform ) {
|
|
|
|
val = cssNormalTransform[ name ];
|
|
|
|
}
|
|
|
|
|
2016-05-16 13:33:49 +02:00
|
|
|
// Make numeric if forced or a qualifier was provided and val looks numeric
|
2014-05-12 20:08:19 +02:00
|
|
|
if ( extra === "" || extra ) {
|
|
|
|
num = parseFloat( val );
|
2017-05-13 13:25:33 +02:00
|
|
|
return extra === true || isFinite( num ) ? num || 0 : val;
|
2014-05-12 20:08:19 +02:00
|
|
|
}
|
2017-05-13 13:25:33 +02:00
|
|
|
|
2014-05-12 20:08:19 +02:00
|
|
|
return val;
|
|
|
|
}
|
2017-05-13 13:25:33 +02:00
|
|
|
} );
|
2014-05-12 20:08:19 +02:00
|
|
|
|
2019-03-29 22:00:08 +01:00
|
|
|
jQuery.each( [ "height", "width" ], function( i, dimension ) {
|
|
|
|
jQuery.cssHooks[ dimension ] = {
|
2014-05-12 20:08:19 +02:00
|
|
|
get: function( elem, computed, extra ) {
|
|
|
|
if ( computed ) {
|
2016-05-16 13:33:49 +02:00
|
|
|
|
|
|
|
// Certain elements can have dimension info if we invisibly show them
|
|
|
|
// but it must have a current display style that would benefit
|
2017-05-13 13:25:33 +02:00
|
|
|
return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
|
|
|
|
|
|
|
|
// Support: Safari 8+
|
|
|
|
// Table columns in Safari have non-zero offsetWidth & zero
|
|
|
|
// getBoundingClientRect().width unless display is changed.
|
|
|
|
// Support: IE <=11 only
|
|
|
|
// Running getBoundingClientRect on a disconnected node
|
|
|
|
// in IE throws an error.
|
|
|
|
( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
|
|
|
|
swap( elem, cssShow, function() {
|
2019-03-29 22:00:08 +01:00
|
|
|
return getWidthOrHeight( elem, dimension, extra );
|
2017-05-13 13:25:33 +02:00
|
|
|
} ) :
|
2019-03-29 22:00:08 +01:00
|
|
|
getWidthOrHeight( elem, dimension, extra );
|
2014-05-12 20:08:19 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
set: function( elem, value, extra ) {
|
2017-05-13 13:25:33 +02:00
|
|
|
var matches,
|
2019-03-29 22:00:08 +01:00
|
|
|
styles = getStyles( elem ),
|
|
|
|
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
|
|
|
|
subtract = extra && boxModelAdjustment(
|
2014-05-12 20:08:19 +02:00
|
|
|
elem,
|
2019-03-29 22:00:08 +01:00
|
|
|
dimension,
|
2014-05-12 20:08:19 +02:00
|
|
|
extra,
|
2019-03-29 22:00:08 +01:00
|
|
|
isBorderBox,
|
2014-05-12 20:08:19 +02:00
|
|
|
styles
|
2017-05-13 13:25:33 +02:00
|
|
|
);
|
|
|
|
|
2019-03-29 22:00:08 +01:00
|
|
|
// Account for unreliable border-box dimensions by comparing offset* to computed and
|
|
|
|
// faking a content-box to get border and padding (gh-3699)
|
|
|
|
if ( isBorderBox && support.scrollboxSize() === styles.position ) {
|
|
|
|
subtract -= Math.ceil(
|
|
|
|
elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
|
|
|
|
parseFloat( styles[ dimension ] ) -
|
|
|
|
boxModelAdjustment( elem, dimension, "border", false, styles ) -
|
|
|
|
0.5
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-05-13 13:25:33 +02:00
|
|
|
// Convert to pixels if value adjustment is needed
|
|
|
|
if ( subtract && ( matches = rcssNum.exec( value ) ) &&
|
|
|
|
( matches[ 3 ] || "px" ) !== "px" ) {
|
|
|
|
|
2019-03-29 22:00:08 +01:00
|
|
|
elem.style[ dimension ] = value;
|
|
|
|
value = jQuery.css( elem, dimension );
|
2017-05-13 13:25:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return setPositiveNumber( elem, value, subtract );
|
2014-05-12 20:08:19 +02:00
|
|
|
}
|
|
|
|
};
|
2017-05-13 13:25:33 +02:00
|
|
|
} );
|
2014-05-12 20:08:19 +02:00
|
|
|
|
2017-05-13 13:25:33 +02:00
|
|
|
jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
|
2014-05-12 20:08:19 +02:00
|
|
|
function( elem, computed ) {
|
|
|
|
if ( computed ) {
|
2017-05-13 13:25:33 +02:00
|
|
|
return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
|
|
|
|
elem.getBoundingClientRect().left -
|
|
|
|
swap( elem, { marginLeft: 0 }, function() {
|
|
|
|
return elem.getBoundingClientRect().left;
|
|
|
|
} )
|
|
|
|
) + "px";
|
2014-05-12 20:08:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
// These hooks are used by animate to expand properties
|
2017-05-13 13:25:33 +02:00
|
|
|
jQuery.each( {
|
2014-05-12 20:08:19 +02:00
|
|
|
margin: "",
|
|
|
|
padding: "",
|
|
|
|
border: "Width"
|
|
|
|
}, function( prefix, suffix ) {
|
|
|
|
jQuery.cssHooks[ prefix + suffix ] = {
|
|
|
|
expand: function( value ) {
|
|
|
|
var i = 0,
|
|
|
|
expanded = {},
|
|
|
|
|
2016-05-16 13:33:49 +02:00
|
|
|
// Assumes a single number if not a string
|
2017-05-13 13:25:33 +02:00
|
|
|
parts = typeof value === "string" ? value.split( " " ) : [ value ];
|
2014-05-12 20:08:19 +02:00
|
|
|
|
|
|
|
for ( ; i < 4; i++ ) {
|
|
|
|
expanded[ prefix + cssExpand[ i ] + suffix ] =
|
|
|
|
parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
|
|
|
|
}
|
|
|
|
|
|
|
|
return expanded;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-03-29 22:00:08 +01:00
|
|
|
if ( prefix !== "margin" ) {
|
2014-05-12 20:08:19 +02:00
|
|
|
jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
|
|
|
|
}
|
2017-05-13 13:25:33 +02:00
|
|
|
} );
|
2014-05-12 20:08:19 +02:00
|
|
|
|
2017-05-13 13:25:33 +02:00
|
|
|
jQuery.fn.extend( {
|
2014-05-12 20:08:19 +02:00
|
|
|
css: function( name, value ) {
|
|
|
|
return access( this, function( elem, name, value ) {
|
|
|
|
var styles, len,
|
|
|
|
map = {},
|
|
|
|
i = 0;
|
|
|
|
|
2017-05-13 13:25:33 +02:00
|
|
|
if ( Array.isArray( name ) ) {
|
2014-05-12 20:08:19 +02:00
|
|
|
styles = getStyles( elem );
|
|
|
|
len = name.length;
|
|
|
|
|
|
|
|
for ( ; i < len; i++ ) {
|
|
|
|
map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
|
|
|
|
}
|
|
|
|
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
|
|
|
return value !== undefined ?
|
|
|
|
jQuery.style( elem, name, value ) :
|
|
|
|
jQuery.css( elem, name );
|
|
|
|
}, name, value, arguments.length > 1 );
|
|
|
|
}
|
2017-05-13 13:25:33 +02:00
|
|
|
} );
|
2014-05-12 20:08:19 +02:00
|
|
|
|
|
|
|
return jQuery;
|
2017-05-13 13:25:33 +02:00
|
|
|
} );
|