|
define( [ |
|
"./core", |
|
"./var/pnum", |
|
"./core/access", |
|
"./css/var/rmargin", |
|
"./var/document", |
|
"./var/rcssNum", |
|
"./css/var/rnumnonpx", |
|
"./css/var/cssExpand", |
|
"./css/var/isHidden", |
|
"./css/var/getStyles", |
|
"./css/var/swap", |
|
"./css/curCSS", |
|
"./css/adjustCSS", |
|
"./css/defaultDisplay", |
|
"./css/addGetHookIf", |
|
"./css/support", |
|
"./data/var/dataPriv", |
|
|
|
"./core/init", |
|
"./core/ready", |
|
"./selector" |
|
], function( jQuery, pnum, access, rmargin, document, rcssNum, rnumnonpx, cssExpand, isHidden, |
|
getStyles, swap, curCSS, adjustCSS, defaultDisplay, addGetHookIf, support, dataPriv ) { |
|
|
|
var |
|
|
|
|
|
|
|
|
|
rdisplayswap = /^(none|table(?!-c[ea]).+)/, |
|
|
|
cssShow = { position: "absolute", visibility: "hidden", display: "block" }, |
|
cssNormalTransform = { |
|
letterSpacing: "0", |
|
fontWeight: "400" |
|
}, |
|
|
|
cssPrefixes = [ "Webkit", "O", "Moz", "ms" ], |
|
emptyStyle = document.createElement( "div" ).style; |
|
|
|
|
|
function vendorPropName( name ) { |
|
|
|
|
|
if ( name in emptyStyle ) { |
|
return name; |
|
} |
|
|
|
|
|
var capName = name[ 0 ].toUpperCase() + name.slice( 1 ), |
|
i = cssPrefixes.length; |
|
|
|
while ( i-- ) { |
|
name = cssPrefixes[ i ] + capName; |
|
if ( name in emptyStyle ) { |
|
return name; |
|
} |
|
} |
|
} |
|
|
|
function setPositiveNumber( elem, value, subtract ) { |
|
|
|
|
|
|
|
var matches = rcssNum.exec( value ); |
|
return matches ? |
|
|
|
|
|
Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) : |
|
value; |
|
} |
|
|
|
function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { |
|
var i = extra === ( isBorderBox ? "border" : "content" ) ? |
|
|
|
|
|
4 : |
|
|
|
|
|
name === "width" ? 1 : 0, |
|
|
|
val = 0; |
|
|
|
for ( ; i < 4; i += 2 ) { |
|
|
|
|
|
if ( extra === "margin" ) { |
|
val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); |
|
} |
|
|
|
if ( isBorderBox ) { |
|
|
|
|
|
if ( extra === "content" ) { |
|
val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); |
|
} |
|
|
|
|
|
if ( extra !== "margin" ) { |
|
val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); |
|
} |
|
} else { |
|
|
|
|
|
val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); |
|
|
|
|
|
if ( extra !== "padding" ) { |
|
val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); |
|
} |
|
} |
|
} |
|
|
|
return val; |
|
} |
|
|
|
function getWidthOrHeight( elem, name, extra ) { |
|
|
|
|
|
var valueIsBorderBox = true, |
|
val = name === "width" ? elem.offsetWidth : elem.offsetHeight, |
|
styles = getStyles( elem ), |
|
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; |
|
|
|
|
|
|
|
|
|
if ( document.msFullscreenElement && window.top !== window ) { |
|
|
|
|
|
|
|
|
|
if ( elem.getClientRects().length ) { |
|
val = Math.round( elem.getBoundingClientRect()[ name ] * 100 ); |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
if ( val <= 0 || val == null ) { |
|
|
|
|
|
val = curCSS( elem, name, styles ); |
|
if ( val < 0 || val == null ) { |
|
val = elem.style[ name ]; |
|
} |
|
|
|
|
|
if ( rnumnonpx.test( val ) ) { |
|
return val; |
|
} |
|
|
|
|
|
|
|
valueIsBorderBox = isBorderBox && |
|
( support.boxSizingReliable() || val === elem.style[ name ] ); |
|
|
|
|
|
val = parseFloat( val ) || 0; |
|
} |
|
|
|
|
|
return ( val + |
|
augmentWidthOrHeight( |
|
elem, |
|
name, |
|
extra || ( isBorderBox ? "border" : "content" ), |
|
valueIsBorderBox, |
|
styles |
|
) |
|
) + "px"; |
|
} |
|
|
|
function showHide( elements, show ) { |
|
var display, elem, hidden, |
|
values = [], |
|
index = 0, |
|
length = elements.length; |
|
|
|
for ( ; index < length; index++ ) { |
|
elem = elements[ index ]; |
|
if ( !elem.style ) { |
|
continue; |
|
} |
|
|
|
values[ index ] = dataPriv.get( elem, "olddisplay" ); |
|
display = elem.style.display; |
|
if ( show ) { |
|
|
|
|
|
|
|
if ( !values[ index ] && display === "none" ) { |
|
elem.style.display = ""; |
|
} |
|
|
|
|
|
|
|
|
|
if ( elem.style.display === "" && isHidden( elem ) ) { |
|
values[ index ] = dataPriv.access( |
|
elem, |
|
"olddisplay", |
|
defaultDisplay( elem.nodeName ) |
|
); |
|
} |
|
} else { |
|
hidden = isHidden( elem ); |
|
|
|
if ( display !== "none" || !hidden ) { |
|
dataPriv.set( |
|
elem, |
|
"olddisplay", |
|
hidden ? display : jQuery.css( elem, "display" ) |
|
); |
|
} |
|
} |
|
} |
|
|
|
|
|
|
|
for ( index = 0; index < length; index++ ) { |
|
elem = elements[ index ]; |
|
if ( !elem.style ) { |
|
continue; |
|
} |
|
if ( !show || elem.style.display === "none" || elem.style.display === "" ) { |
|
elem.style.display = show ? values[ index ] || "" : "none"; |
|
} |
|
} |
|
|
|
return elements; |
|
} |
|
|
|
jQuery.extend( { |
|
|
|
|
|
|
|
cssHooks: { |
|
opacity: { |
|
get: function( elem, computed ) { |
|
if ( computed ) { |
|
|
|
|
|
var ret = curCSS( elem, "opacity" ); |
|
return ret === "" ? "1" : ret; |
|
} |
|
} |
|
} |
|
}, |
|
|
|
|
|
cssNumber: { |
|
"animationIterationCount": true, |
|
"columnCount": true, |
|
"fillOpacity": true, |
|
"flexGrow": true, |
|
"flexShrink": true, |
|
"fontWeight": true, |
|
"lineHeight": true, |
|
"opacity": true, |
|
"order": true, |
|
"orphans": true, |
|
"widows": true, |
|
"zIndex": true, |
|
"zoom": true |
|
}, |
|
|
|
|
|
|
|
cssProps: { |
|
"float": "cssFloat" |
|
}, |
|
|
|
|
|
style: function( elem, name, value, extra ) { |
|
|
|
|
|
if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { |
|
return; |
|
} |
|
|
|
|
|
var ret, type, hooks, |
|
origName = jQuery.camelCase( name ), |
|
style = elem.style; |
|
|
|
name = jQuery.cssProps[ origName ] || |
|
( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName ); |
|
|
|
|
|
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; |
|
|
|
|
|
if ( value !== undefined ) { |
|
type = typeof value; |
|
|
|
|
|
if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) { |
|
value = adjustCSS( elem, name, ret ); |
|
|
|
|
|
type = "number"; |
|
} |
|
|
|
|
|
if ( value == null || value !== value ) { |
|
return; |
|
} |
|
|
|
|
|
if ( type === "number" ) { |
|
value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" ); |
|
} |
|
|
|
|
|
|
|
if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { |
|
style[ name ] = "inherit"; |
|
} |
|
|
|
|
|
if ( !hooks || !( "set" in hooks ) || |
|
( value = hooks.set( elem, value, extra ) ) !== undefined ) { |
|
|
|
style[ name ] = value; |
|
} |
|
|
|
} else { |
|
|
|
|
|
if ( hooks && "get" in hooks && |
|
( ret = hooks.get( elem, false, extra ) ) !== undefined ) { |
|
|
|
return ret; |
|
} |
|
|
|
|
|
return style[ name ]; |
|
} |
|
}, |
|
|
|
css: function( elem, name, extra, styles ) { |
|
var val, num, hooks, |
|
origName = jQuery.camelCase( name ); |
|
|
|
|
|
name = jQuery.cssProps[ origName ] || |
|
( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName ); |
|
|
|
|
|
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; |
|
|
|
|
|
if ( hooks && "get" in hooks ) { |
|
val = hooks.get( elem, true, extra ); |
|
} |
|
|
|
|
|
if ( val === undefined ) { |
|
val = curCSS( elem, name, styles ); |
|
} |
|
|
|
|
|
if ( val === "normal" && name in cssNormalTransform ) { |
|
val = cssNormalTransform[ name ]; |
|
} |
|
|
|
|
|
if ( extra === "" || extra ) { |
|
num = parseFloat( val ); |
|
return extra === true || isFinite( num ) ? num || 0 : val; |
|
} |
|
return val; |
|
} |
|
} ); |
|
|
|
jQuery.each( [ "height", "width" ], function( i, name ) { |
|
jQuery.cssHooks[ name ] = { |
|
get: function( elem, computed, extra ) { |
|
if ( computed ) { |
|
|
|
|
|
|
|
return rdisplayswap.test( jQuery.css( elem, "display" ) ) && |
|
elem.offsetWidth === 0 ? |
|
swap( elem, cssShow, function() { |
|
return getWidthOrHeight( elem, name, extra ); |
|
} ) : |
|
getWidthOrHeight( elem, name, extra ); |
|
} |
|
}, |
|
|
|
set: function( elem, value, extra ) { |
|
var matches, |
|
styles = extra && getStyles( elem ), |
|
subtract = extra && augmentWidthOrHeight( |
|
elem, |
|
name, |
|
extra, |
|
jQuery.css( elem, "boxSizing", false, styles ) === "border-box", |
|
styles |
|
); |
|
|
|
|
|
if ( subtract && ( matches = rcssNum.exec( value ) ) && |
|
( matches[ 3 ] || "px" ) !== "px" ) { |
|
|
|
elem.style[ name ] = value; |
|
value = jQuery.css( elem, name ); |
|
} |
|
|
|
return setPositiveNumber( elem, value, subtract ); |
|
} |
|
}; |
|
} ); |
|
|
|
jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft, |
|
function( elem, computed ) { |
|
if ( computed ) { |
|
return ( parseFloat( curCSS( elem, "marginLeft" ) ) || |
|
elem.getBoundingClientRect().left - |
|
swap( elem, { marginLeft: 0 }, function() { |
|
return elem.getBoundingClientRect().left; |
|
} ) |
|
) + "px"; |
|
} |
|
} |
|
); |
|
|
|
|
|
jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight, |
|
function( elem, computed ) { |
|
if ( computed ) { |
|
return swap( elem, { "display": "inline-block" }, |
|
curCSS, [ elem, "marginRight" ] ); |
|
} |
|
} |
|
); |
|
|
|
|
|
jQuery.each( { |
|
margin: "", |
|
padding: "", |
|
border: "Width" |
|
}, function( prefix, suffix ) { |
|
jQuery.cssHooks[ prefix + suffix ] = { |
|
expand: function( value ) { |
|
var i = 0, |
|
expanded = {}, |
|
|
|
|
|
parts = typeof value === "string" ? value.split( " " ) : [ value ]; |
|
|
|
for ( ; i < 4; i++ ) { |
|
expanded[ prefix + cssExpand[ i ] + suffix ] = |
|
parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; |
|
} |
|
|
|
return expanded; |
|
} |
|
}; |
|
|
|
if ( !rmargin.test( prefix ) ) { |
|
jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; |
|
} |
|
} ); |
|
|
|
jQuery.fn.extend( { |
|
css: function( name, value ) { |
|
return access( this, function( elem, name, value ) { |
|
var styles, len, |
|
map = {}, |
|
i = 0; |
|
|
|
if ( jQuery.isArray( name ) ) { |
|
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 ); |
|
}, |
|
show: function() { |
|
return showHide( this, true ); |
|
}, |
|
hide: function() { |
|
return showHide( this ); |
|
}, |
|
toggle: function( state ) { |
|
if ( typeof state === "boolean" ) { |
|
return state ? this.show() : this.hide(); |
|
} |
|
|
|
return this.each( function() { |
|
if ( isHidden( this ) ) { |
|
jQuery( this ).show(); |
|
} else { |
|
jQuery( this ).hide(); |
|
} |
|
} ); |
|
} |
|
} ); |
|
|
|
return jQuery; |
|
} ); |
|
|