2012-12-10 23:25:23 +00:00
|
|
|
var curCSS, getStyles, iframe,
|
2012-05-29 02:25:04 +00:00
|
|
|
ralpha = /alpha\([^)]*\)/i,
|
2012-10-22 03:40:37 +00:00
|
|
|
ropacity = /opacity\s*=\s*([^)]*)/,
|
2012-07-23 02:23:32 +00:00
|
|
|
rposition = /^(top|right|bottom|left)$/,
|
2012-08-29 12:50:56 +00:00
|
|
|
// swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
|
|
|
|
// see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
|
|
|
|
rdisplayswap = /^(none|table(?!-c[ea]).+)/,
|
2011-12-07 01:32:26 +00:00
|
|
|
rmargin = /^margin/,
|
2012-07-23 02:23:32 +00:00
|
|
|
rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ),
|
|
|
|
rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ),
|
2012-11-26 08:20:43 +00:00
|
|
|
rrelNum = new RegExp( "^([+-])=(" + core_pnum + ")", "i" ),
|
2012-10-04 17:25:50 +00:00
|
|
|
elemdisplay = { BODY: "block" },
|
2012-06-06 23:03:10 +00:00
|
|
|
|
2012-07-23 02:23:32 +00:00
|
|
|
cssShow = { position: "absolute", visibility: "hidden", display: "block" },
|
2012-06-06 23:03:10 +00:00
|
|
|
cssNormalTransform = {
|
|
|
|
letterSpacing: 0,
|
2012-08-19 20:03:08 +00:00
|
|
|
fontWeight: 400
|
2012-07-23 02:23:32 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
cssExpand = [ "Top", "Right", "Bottom", "Left" ],
|
2012-10-17 16:50:12 +00:00
|
|
|
cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
|
2009-03-22 23:25:03 +00:00
|
|
|
|
2012-04-06 12:39:59 +00:00
|
|
|
// return a css property mapped to a potentially vendor prefixed property
|
|
|
|
function vendorPropName( style, name ) {
|
|
|
|
|
|
|
|
// shortcut for names that are not vendor prefixed
|
|
|
|
if ( name in style ) {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
// check for vendor prefixed names
|
|
|
|
var capName = name.charAt(0).toUpperCase() + name.slice(1),
|
|
|
|
origName = name,
|
|
|
|
i = cssPrefixes.length;
|
|
|
|
|
|
|
|
while ( i-- ) {
|
|
|
|
name = cssPrefixes[ i ] + capName;
|
|
|
|
if ( name in style ) {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return origName;
|
|
|
|
}
|
|
|
|
|
2012-07-26 01:44:44 +00:00
|
|
|
function isHidden( elem, el ) {
|
2012-09-28 20:56:49 +00:00
|
|
|
// isHidden might be called from jQuery#filter function;
|
|
|
|
// in that case, element will be second argument
|
2012-07-26 01:44:44 +00:00
|
|
|
elem = el || elem;
|
2012-12-10 23:25:23 +00:00
|
|
|
return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
|
2012-07-25 23:24:10 +00:00
|
|
|
}
|
|
|
|
|
2012-05-29 02:25:04 +00:00
|
|
|
function showHide( elements, show ) {
|
2012-09-28 20:56:49 +00:00
|
|
|
var elem,
|
2012-05-29 02:25:04 +00:00
|
|
|
values = [],
|
|
|
|
index = 0,
|
|
|
|
length = elements.length;
|
|
|
|
|
|
|
|
for ( ; index < length; index++ ) {
|
|
|
|
elem = elements[ index ];
|
|
|
|
if ( !elem.style ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
values[ index ] = jQuery._data( elem, "olddisplay" );
|
|
|
|
if ( show ) {
|
|
|
|
// Reset the inline display of this element to learn if it is
|
|
|
|
// being hidden by cascaded rules or not
|
|
|
|
if ( !values[ index ] && elem.style.display === "none" ) {
|
|
|
|
elem.style.display = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set elements which have been overridden with display: none
|
|
|
|
// in a stylesheet to whatever the default browser style is
|
|
|
|
// for such an element
|
2012-07-25 23:24:10 +00:00
|
|
|
if ( elem.style.display === "" && isHidden( elem ) ) {
|
2012-06-16 01:01:44 +00:00
|
|
|
values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) );
|
2012-05-29 02:25:04 +00:00
|
|
|
}
|
2012-09-28 20:56:49 +00:00
|
|
|
} else if ( !values[ index ] && !isHidden( elem ) ) {
|
2012-12-10 23:25:23 +00:00
|
|
|
jQuery._data( elem, "olddisplay", jQuery.css( elem, "display" ) );
|
2012-05-29 02:25:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the display of most of the elements in a second loop
|
|
|
|
// to avoid the constant reflow
|
|
|
|
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.fn.extend({
|
|
|
|
css: function( name, value ) {
|
|
|
|
return jQuery.access( this, function( elem, name, value ) {
|
2012-12-11 13:06:48 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-05-29 02:25:04 +00:00
|
|
|
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 );
|
|
|
|
},
|
2012-10-17 16:50:12 +00:00
|
|
|
toggle: function( state ) {
|
2012-07-26 01:24:49 +00:00
|
|
|
var bool = typeof state === "boolean";
|
2012-05-29 02:25:04 +00:00
|
|
|
|
|
|
|
return this.each(function() {
|
2012-07-26 01:24:49 +00:00
|
|
|
if ( bool ? state : isHidden( this ) ) {
|
|
|
|
jQuery( this ).show();
|
|
|
|
} else {
|
|
|
|
jQuery( this ).hide();
|
|
|
|
}
|
2012-05-29 02:25:04 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2009-03-22 23:25:03 +00:00
|
|
|
|
|
|
|
jQuery.extend({
|
2010-09-16 14:00:56 +00:00
|
|
|
// Add in style property hooks for overriding the default
|
|
|
|
// behavior of getting and setting a style property
|
2010-09-05 15:01:27 +00:00
|
|
|
cssHooks: {
|
|
|
|
opacity: {
|
2010-09-27 15:51:01 +00:00
|
|
|
get: function( elem, computed ) {
|
|
|
|
if ( computed ) {
|
|
|
|
// We should always get a number back from opacity
|
2012-01-12 03:11:22 +00:00
|
|
|
var ret = curCSS( elem, "opacity" );
|
2010-09-27 15:51:01 +00:00
|
|
|
return ret === "" ? "1" : ret;
|
|
|
|
}
|
2010-09-05 15:01:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-09-16 14:00:56 +00:00
|
|
|
// Exclude the following css properties to add px
|
2010-09-05 15:01:27 +00:00
|
|
|
cssNumber: {
|
2012-12-01 22:11:56 +00:00
|
|
|
"columnCount": true,
|
2011-06-14 19:59:22 +00:00
|
|
|
"fillOpacity": true,
|
2010-09-05 15:01:27 +00:00
|
|
|
"fontWeight": true,
|
2011-04-22 04:02:08 +00:00
|
|
|
"lineHeight": true,
|
2011-06-14 19:59:22 +00:00
|
|
|
"opacity": true,
|
|
|
|
"orphans": true,
|
2011-04-22 04:02:08 +00:00
|
|
|
"widows": true,
|
2011-06-14 19:59:22 +00:00
|
|
|
"zIndex": true,
|
|
|
|
"zoom": true
|
2010-09-05 15:01:27 +00:00
|
|
|
},
|
|
|
|
|
2010-09-16 14:00:56 +00:00
|
|
|
// Add in properties whose names you wish to fix before
|
|
|
|
// setting or getting the value
|
2010-09-05 15:01:27 +00:00
|
|
|
cssProps: {
|
|
|
|
// normalize float css property
|
|
|
|
"float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
|
|
|
|
},
|
2010-09-03 02:06:40 +00:00
|
|
|
|
2010-09-16 14:00:56 +00:00
|
|
|
// Get and set the style property on a DOM Node
|
|
|
|
style: function( elem, name, value, extra ) {
|
|
|
|
// Don't set styles on text and comment nodes
|
|
|
|
if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
|
2010-10-09 14:52:53 +00:00
|
|
|
return;
|
2010-09-03 02:06:40 +00:00
|
|
|
}
|
2009-03-22 23:25:03 +00:00
|
|
|
|
2010-09-16 14:00:56 +00:00
|
|
|
// Make sure that we're working with the right name
|
2012-04-06 12:39:59 +00:00
|
|
|
var ret, type, hooks,
|
|
|
|
origName = jQuery.camelCase( name ),
|
|
|
|
style = elem.style;
|
2009-03-22 23:25:03 +00:00
|
|
|
|
2012-04-06 12:39:59 +00:00
|
|
|
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
|
|
|
|
|
|
|
|
// gets hook for the prefixed version
|
|
|
|
// followed by the unprefixed version
|
|
|
|
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
|
2010-09-03 02:06:40 +00:00
|
|
|
|
2010-09-16 14:00:56 +00:00
|
|
|
// Check if we're setting a value
|
2010-09-05 14:17:18 +00:00
|
|
|
if ( value !== undefined ) {
|
2011-04-04 23:48:24 +00:00
|
|
|
type = typeof value;
|
|
|
|
|
|
|
|
// convert relative number strings (+= or -=) to relative numbers. #7345
|
2011-08-16 22:00:44 +00:00
|
|
|
if ( type === "string" && (ret = rrelNum.exec( value )) ) {
|
2012-05-25 01:52:35 +00:00
|
|
|
value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
|
2011-05-13 16:09:49 +00:00
|
|
|
// Fixes bug #9237
|
2011-05-13 16:14:31 +00:00
|
|
|
type = "number";
|
2011-04-04 18:21:15 +00:00
|
|
|
}
|
|
|
|
|
2011-08-16 22:00:44 +00:00
|
|
|
// Make sure that NaN and null values aren't set. See: #7116
|
2011-08-16 23:30:20 +00:00
|
|
|
if ( value == null || type === "number" && isNaN( value ) ) {
|
2011-08-16 22:00:44 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-09-16 14:00:56 +00:00
|
|
|
// If a number was passed in, add 'px' to the (except for certain CSS properties)
|
2011-04-04 23:48:24 +00:00
|
|
|
if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
|
2010-09-05 14:17:18 +00:00
|
|
|
value += "px";
|
2010-09-03 02:06:40 +00:00
|
|
|
}
|
2009-03-22 23:25:03 +00:00
|
|
|
|
2012-11-18 22:03:38 +00:00
|
|
|
// Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
|
|
|
|
// but it would mean to define eight (for every problematic property) identical functions
|
|
|
|
if ( value === "" && name.indexOf("background") === 0 ) {
|
|
|
|
value = " ";
|
|
|
|
}
|
|
|
|
|
2010-09-16 14:00:56 +00:00
|
|
|
// If a hook was provided, use that value, otherwise just set the specified value
|
2012-05-21 17:44:19 +00:00
|
|
|
if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
|
2012-08-13 12:46:55 +00:00
|
|
|
|
2010-10-09 14:42:01 +00:00
|
|
|
// Wrapped to prevent IE from throwing errors when 'invalid' values are provided
|
|
|
|
// Fixes bug #5509
|
|
|
|
try {
|
|
|
|
style[ name ] = value;
|
|
|
|
} catch(e) {}
|
2009-07-19 16:08:17 +00:00
|
|
|
}
|
2009-03-22 23:25:03 +00:00
|
|
|
|
2010-09-05 14:17:18 +00:00
|
|
|
} else {
|
2010-09-16 14:00:56 +00:00
|
|
|
// If a hook was provided get the non-computed value from there
|
|
|
|
if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
|
2010-09-05 14:17:18 +00:00
|
|
|
return ret;
|
2010-09-16 14:00:56 +00:00
|
|
|
}
|
2009-03-22 23:25:03 +00:00
|
|
|
|
2010-09-16 14:00:56 +00:00
|
|
|
// Otherwise just get the value from the style object
|
|
|
|
return style[ name ];
|
|
|
|
}
|
|
|
|
},
|
2009-03-22 23:25:03 +00:00
|
|
|
|
2012-12-10 23:25:23 +00:00
|
|
|
css: function( elem, name, extra, styles ) {
|
2012-05-25 01:52:35 +00:00
|
|
|
var val, num, hooks,
|
2012-04-06 12:39:59 +00:00
|
|
|
origName = jQuery.camelCase( name );
|
2011-04-11 18:33:52 +00:00
|
|
|
|
2010-09-16 14:00:56 +00:00
|
|
|
// Make sure that we're working with the right name
|
2012-04-06 12:39:59 +00:00
|
|
|
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
|
|
|
|
|
|
|
|
// gets hook for the prefixed version
|
|
|
|
// followed by the unprefixed version
|
|
|
|
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
|
2010-09-16 14:00:56 +00:00
|
|
|
|
|
|
|
// If a hook was provided get the computed value from there
|
2012-05-25 01:52:35 +00:00
|
|
|
if ( hooks && "get" in hooks ) {
|
|
|
|
val = hooks.get( elem, true, extra );
|
|
|
|
}
|
2010-09-16 14:00:56 +00:00
|
|
|
|
|
|
|
// Otherwise, if a way to get the computed value exists, use that
|
2012-05-25 01:52:35 +00:00
|
|
|
if ( val === undefined ) {
|
2012-12-10 23:25:23 +00:00
|
|
|
val = curCSS( elem, name, styles );
|
2010-09-03 02:06:40 +00:00
|
|
|
}
|
2012-05-25 01:52:35 +00:00
|
|
|
|
2012-06-06 23:03:10 +00:00
|
|
|
//convert "normal" to computed value
|
|
|
|
if ( val === "normal" && name in cssNormalTransform ) {
|
|
|
|
val = cssNormalTransform[ name ];
|
|
|
|
}
|
|
|
|
|
2012-05-25 01:52:35 +00:00
|
|
|
// Return, converting to number if forced or a qualifier was provided and val looks numeric
|
2012-12-10 23:25:23 +00:00
|
|
|
if ( extra ) {
|
2012-05-25 01:52:35 +00:00
|
|
|
num = parseFloat( val );
|
2012-12-10 23:25:23 +00:00
|
|
|
return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
|
2012-05-25 01:52:35 +00:00
|
|
|
}
|
|
|
|
return val;
|
2009-03-22 23:25:03 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// A method for quickly swapping in/out CSS properties to get correct calculations
|
2012-12-13 17:40:55 +00:00
|
|
|
swap: function( elem, options, callback, args ) {
|
2012-07-10 01:38:11 +00:00
|
|
|
var ret, name,
|
|
|
|
old = {};
|
2009-07-19 16:08:17 +00:00
|
|
|
|
2009-03-22 23:25:03 +00:00
|
|
|
// Remember the old values, and insert the new ones
|
2011-12-06 21:23:22 +00:00
|
|
|
for ( name in options ) {
|
2009-03-22 23:25:03 +00:00
|
|
|
old[ name ] = elem.style[ name ];
|
|
|
|
elem.style[ name ] = options[ name ];
|
|
|
|
}
|
|
|
|
|
2012-12-13 17:40:55 +00:00
|
|
|
ret = callback.apply( elem, args || [] );
|
2009-03-22 23:25:03 +00:00
|
|
|
|
|
|
|
// Revert the old values
|
2010-03-02 02:24:49 +00:00
|
|
|
for ( name in options ) {
|
2009-03-22 23:25:03 +00:00
|
|
|
elem.style[ name ] = old[ name ];
|
2009-07-19 16:08:17 +00:00
|
|
|
}
|
2011-12-06 21:23:22 +00:00
|
|
|
|
|
|
|
return ret;
|
2009-03-22 23:25:03 +00:00
|
|
|
}
|
2009-07-19 13:21:51 +00:00
|
|
|
});
|
2009-10-26 22:07:57 +00:00
|
|
|
|
2012-12-10 23:25:23 +00:00
|
|
|
// NOTE: we've included the "window" in window.getComputedStyle
|
2012-08-10 23:34:01 +00:00
|
|
|
// because jsdom on node.js will break without it.
|
2012-06-18 17:26:46 +00:00
|
|
|
if ( window.getComputedStyle ) {
|
2012-12-10 23:25:23 +00:00
|
|
|
getStyles = function( elem ) {
|
|
|
|
return window.getComputedStyle( elem, null );
|
|
|
|
};
|
2010-09-05 04:04:37 +00:00
|
|
|
|
2012-12-10 23:25:23 +00:00
|
|
|
curCSS = function( elem, name, _computed ) {
|
|
|
|
var width, minWidth, maxWidth,
|
|
|
|
computed = _computed || getStyles( elem ),
|
2011-12-12 15:22:38 +00:00
|
|
|
|
2012-09-30 21:41:42 +00:00
|
|
|
// getPropertyValue is only needed for .css('filter') in IE9, see #12537
|
2012-12-10 23:25:23 +00:00
|
|
|
ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined,
|
|
|
|
style = elem.style;
|
|
|
|
|
|
|
|
if ( computed ) {
|
2012-09-30 21:41:42 +00:00
|
|
|
|
2012-08-20 00:34:03 +00:00
|
|
|
if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
|
2010-10-11 19:11:03 +00:00
|
|
|
ret = jQuery.style( elem, name );
|
|
|
|
}
|
2010-09-05 04:04:37 +00:00
|
|
|
|
2012-06-16 01:20:41 +00:00
|
|
|
// A tribute to the "awesome hack by Dean Edwards"
|
2012-07-23 01:58:23 +00:00
|
|
|
// Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
|
|
|
|
// Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
|
|
|
|
// this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
|
2012-07-25 12:49:51 +00:00
|
|
|
if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
|
2012-12-10 23:25:23 +00:00
|
|
|
|
|
|
|
// Remember the original values
|
2012-06-16 01:20:41 +00:00
|
|
|
width = style.width;
|
2012-07-23 01:58:23 +00:00
|
|
|
minWidth = style.minWidth;
|
|
|
|
maxWidth = style.maxWidth;
|
|
|
|
|
2012-12-10 23:25:23 +00:00
|
|
|
// Put in the new values to get a computed value out
|
2012-07-23 01:58:23 +00:00
|
|
|
style.minWidth = style.maxWidth = style.width = ret;
|
2012-06-18 17:26:46 +00:00
|
|
|
ret = computed.width;
|
2012-07-23 01:58:23 +00:00
|
|
|
|
2012-12-10 23:25:23 +00:00
|
|
|
// Revert the changed values
|
2012-06-16 01:20:41 +00:00
|
|
|
style.width = width;
|
2012-07-23 01:58:23 +00:00
|
|
|
style.minWidth = minWidth;
|
|
|
|
style.maxWidth = maxWidth;
|
2012-06-16 01:20:41 +00:00
|
|
|
}
|
2011-12-07 01:32:26 +00:00
|
|
|
}
|
|
|
|
|
2010-11-03 22:59:55 +00:00
|
|
|
return ret;
|
2010-09-05 04:04:37 +00:00
|
|
|
};
|
2012-04-20 18:18:15 +00:00
|
|
|
} else if ( document.documentElement.currentStyle ) {
|
2012-12-10 23:25:23 +00:00
|
|
|
getStyles = function( elem ) {
|
|
|
|
return elem.currentStyle;
|
|
|
|
};
|
|
|
|
|
|
|
|
curCSS = function( elem, name, _computed ) {
|
|
|
|
var left, rs, rsLeft,
|
|
|
|
computed = _computed || getStyles( elem ),
|
|
|
|
ret = computed ? computed[ name ] : undefined,
|
2010-11-09 16:09:07 +00:00
|
|
|
style = elem.style;
|
2010-09-05 04:04:37 +00:00
|
|
|
|
2011-11-01 13:46:20 +00:00
|
|
|
// Avoid setting ret to empty string here
|
|
|
|
// so we don't default to auto
|
2012-07-10 01:38:11 +00:00
|
|
|
if ( ret == null && style && style[ name ] ) {
|
|
|
|
ret = style[ name ];
|
2011-10-22 20:08:14 +00:00
|
|
|
}
|
|
|
|
|
2010-09-05 04:04:37 +00:00
|
|
|
// From the awesome hack by Dean Edwards
|
|
|
|
// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
|
|
|
|
|
|
|
|
// If we're not dealing with a regular pixel number
|
|
|
|
// but a number that has a weird ending, we need to convert it to pixels
|
2012-05-25 01:39:31 +00:00
|
|
|
// but not position css attributes, as those are proportional to the parent element instead
|
|
|
|
// and we can't measure the parent instead because it might trigger a "stacking dolls" problem
|
|
|
|
if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
|
2011-10-28 14:53:42 +00:00
|
|
|
|
2010-09-05 04:04:37 +00:00
|
|
|
// Remember the original values
|
|
|
|
left = style.left;
|
2012-12-10 23:25:23 +00:00
|
|
|
rs = elem.runtimeStyle;
|
|
|
|
rsLeft = rs && rs.left;
|
2010-09-05 04:04:37 +00:00
|
|
|
|
|
|
|
// Put in the new values to get a computed value out
|
2011-01-05 18:32:59 +00:00
|
|
|
if ( rsLeft ) {
|
2012-12-10 23:25:23 +00:00
|
|
|
rs.left = elem.currentStyle.left;
|
2011-01-05 18:32:59 +00:00
|
|
|
}
|
2011-12-07 01:32:26 +00:00
|
|
|
style.left = name === "fontSize" ? "1em" : ret;
|
2010-09-05 04:04:37 +00:00
|
|
|
ret = style.pixelLeft + "px";
|
|
|
|
|
|
|
|
// Revert the changed values
|
|
|
|
style.left = left;
|
2011-01-05 18:32:59 +00:00
|
|
|
if ( rsLeft ) {
|
2012-12-10 23:25:23 +00:00
|
|
|
rs.left = rsLeft;
|
2011-01-05 18:32:59 +00:00
|
|
|
}
|
2010-09-05 04:04:37 +00:00
|
|
|
}
|
|
|
|
|
2010-11-01 23:04:59 +00:00
|
|
|
return ret === "" ? "auto" : ret;
|
2010-09-05 04:04:37 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2012-05-21 17:44:19 +00:00
|
|
|
function setPositiveNumber( elem, value, subtract ) {
|
2012-04-23 19:05:12 +00:00
|
|
|
var matches = rnumsplit.exec( value );
|
|
|
|
return matches ?
|
2012-12-11 04:39:08 +00:00
|
|
|
// Guard against undefined "subtract", e.g., when used as in cssHooks
|
|
|
|
Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
|
|
|
|
value;
|
2012-04-23 19:05:12 +00:00
|
|
|
}
|
|
|
|
|
2012-12-10 23:25:23 +00:00
|
|
|
function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
|
2012-05-25 01:52:35 +00:00
|
|
|
var i = extra === ( isBorderBox ? "border" : "content" ) ?
|
|
|
|
// If we already have the right measurement, avoid augmentation
|
|
|
|
4 :
|
|
|
|
// Otherwise initialize for horizontal or vertical properties
|
|
|
|
name === "width" ? 1 : 0,
|
|
|
|
|
|
|
|
val = 0;
|
|
|
|
|
|
|
|
for ( ; i < 4; i += 2 ) {
|
|
|
|
// both box models exclude margin, so add it if we want it
|
|
|
|
if ( extra === "margin" ) {
|
2012-12-10 23:25:23 +00:00
|
|
|
val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
|
2012-05-25 01:52:35 +00:00
|
|
|
}
|
2012-05-21 17:44:19 +00:00
|
|
|
|
2012-05-25 01:52:35 +00:00
|
|
|
if ( isBorderBox ) {
|
|
|
|
// border-box includes padding, so remove it if we want content
|
|
|
|
if ( extra === "content" ) {
|
2012-12-10 23:25:23 +00:00
|
|
|
val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
|
2012-05-25 01:52:35 +00:00
|
|
|
}
|
2012-05-21 17:44:19 +00:00
|
|
|
|
2012-07-11 13:46:21 +00:00
|
|
|
// at this point, extra isn't border nor margin, so remove border
|
2012-05-25 01:52:35 +00:00
|
|
|
if ( extra !== "margin" ) {
|
2012-12-10 23:25:23 +00:00
|
|
|
val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
|
2012-05-25 01:52:35 +00:00
|
|
|
}
|
|
|
|
} else {
|
2012-07-11 13:46:21 +00:00
|
|
|
// at this point, extra isn't content, so add padding
|
2012-12-10 23:25:23 +00:00
|
|
|
val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
|
2012-05-21 17:44:19 +00:00
|
|
|
|
2012-07-11 13:46:21 +00:00
|
|
|
// at this point, extra isn't content nor padding, so add border
|
2012-05-25 01:52:35 +00:00
|
|
|
if ( extra !== "padding" ) {
|
2012-12-10 23:25:23 +00:00
|
|
|
val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
|
2012-05-21 17:44:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2011-12-09 01:01:23 +00:00
|
|
|
function getWidthOrHeight( elem, name, extra ) {
|
2011-04-14 19:49:15 +00:00
|
|
|
|
2012-04-10 21:18:00 +00:00
|
|
|
// Start with offset property, which is equivalent to the border-box value
|
2012-12-11 04:39:08 +00:00
|
|
|
var valueIsBorderBox = true,
|
|
|
|
val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
|
2012-12-10 23:25:23 +00:00
|
|
|
styles = getStyles( elem ),
|
|
|
|
isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
|
2012-04-06 12:39:59 +00:00
|
|
|
|
2012-08-25 15:26:37 +00:00
|
|
|
// some non-html elements return undefined for offsetWidth, so check for null/undefined
|
|
|
|
// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
|
|
|
|
// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
|
|
|
|
if ( val <= 0 || val == null ) {
|
2012-04-06 12:39:59 +00:00
|
|
|
// Fall back to computed then uncomputed css if necessary
|
2012-12-10 23:25:23 +00:00
|
|
|
val = curCSS( elem, name, styles );
|
2012-04-06 12:39:59 +00:00
|
|
|
if ( val < 0 || val == null ) {
|
|
|
|
val = elem.style[ name ];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Computed unit is not pixels. Stop here and return.
|
|
|
|
if ( rnumnonpx.test(val) ) {
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2012-04-10 21:18:00 +00:00
|
|
|
// we need the check for style in case a browser which returns unreliable values
|
|
|
|
// for getComputedStyle silently falls back to the reliable elem.style
|
|
|
|
valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] );
|
|
|
|
|
2012-04-06 12:39:59 +00:00
|
|
|
// Normalize "", auto, and prepare for extra
|
|
|
|
val = parseFloat( val ) || 0;
|
|
|
|
}
|
2011-04-14 04:30:30 +00:00
|
|
|
|
2012-05-25 01:52:35 +00:00
|
|
|
// use the active box-sizing model to add/subtract irrelevant styles
|
|
|
|
return ( val +
|
|
|
|
augmentWidthOrHeight(
|
|
|
|
elem,
|
|
|
|
name,
|
|
|
|
extra || ( isBorderBox ? "border" : "content" ),
|
2012-12-10 23:25:23 +00:00
|
|
|
valueIsBorderBox,
|
|
|
|
styles
|
2012-05-25 01:52:35 +00:00
|
|
|
)
|
|
|
|
) + "px";
|
2010-03-01 17:44:56 +00:00
|
|
|
}
|
|
|
|
|
2012-06-04 16:48:18 +00:00
|
|
|
// Try to determine the default display value of an element
|
2012-06-16 01:01:44 +00:00
|
|
|
function css_defaultDisplay( nodeName ) {
|
2012-12-10 15:05:39 +00:00
|
|
|
var doc = document,
|
2012-12-08 23:04:13 +00:00
|
|
|
display = elemdisplay[ nodeName ];
|
|
|
|
|
|
|
|
if ( !display ) {
|
2012-12-10 15:05:39 +00:00
|
|
|
display = actualDisplay( nodeName, doc );
|
2012-12-08 23:04:13 +00:00
|
|
|
|
|
|
|
// If the simple way fails, read from inside an iframe
|
|
|
|
if ( display === "none" || !display ) {
|
|
|
|
// Use the already-created iframe if possible
|
|
|
|
iframe = ( iframe ||
|
|
|
|
jQuery("<iframe frameborder='0' width='0' height='0'/>")
|
|
|
|
.css( "cssText", "display:block !important" )
|
|
|
|
).appendTo( doc.documentElement );
|
|
|
|
|
|
|
|
// Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
|
|
|
|
doc = ( iframe[0].contentWindow || iframe[0].contentDocument ).document;
|
|
|
|
doc.write("<!doctype html><html><body>");
|
|
|
|
doc.close();
|
|
|
|
|
2012-12-10 15:05:39 +00:00
|
|
|
display = actualDisplay( nodeName, doc );
|
2012-12-08 23:04:13 +00:00
|
|
|
iframe.detach();
|
2012-06-04 16:48:18 +00:00
|
|
|
}
|
|
|
|
|
2012-12-08 23:04:13 +00:00
|
|
|
// Store the correct default display
|
|
|
|
elemdisplay[ nodeName ] = display;
|
2012-06-04 16:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return display;
|
|
|
|
}
|
|
|
|
|
2012-12-10 15:05:39 +00:00
|
|
|
// Called ONLY from within css_defaultDisplay
|
|
|
|
function actualDisplay( name, doc ) {
|
2012-12-11 04:39:08 +00:00
|
|
|
var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
|
|
|
|
display = jQuery.css( elem[0], "display" );
|
2012-12-10 15:05:39 +00:00
|
|
|
elem.remove();
|
|
|
|
return display;
|
|
|
|
}
|
|
|
|
|
2011-12-12 15:22:38 +00:00
|
|
|
jQuery.each([ "height", "width" ], function( i, name ) {
|
|
|
|
jQuery.cssHooks[ name ] = {
|
|
|
|
get: function( elem, computed, extra ) {
|
|
|
|
if ( computed ) {
|
2012-08-29 12:50:56 +00:00
|
|
|
// certain elements can have dimension info if we invisibly show them
|
|
|
|
// however, it must have a current display style that would benefit from this
|
2012-12-13 17:40:55 +00:00
|
|
|
return elem.offsetWidth === 0 && rdisplayswap.test( jQuery.css( elem, "display" ) ) ?
|
|
|
|
jQuery.swap( elem, cssShow, function() {
|
2011-12-12 15:22:38 +00:00
|
|
|
return getWidthOrHeight( elem, name, extra );
|
2012-12-13 17:40:55 +00:00
|
|
|
}) :
|
|
|
|
getWidthOrHeight( elem, name, extra );
|
2011-12-12 15:22:38 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-05-21 17:44:19 +00:00
|
|
|
set: function( elem, value, extra ) {
|
2012-12-10 23:25:23 +00:00
|
|
|
var styles = extra && getStyles( elem );
|
2012-05-21 17:44:19 +00:00
|
|
|
return setPositiveNumber( elem, value, extra ?
|
|
|
|
augmentWidthOrHeight(
|
|
|
|
elem,
|
2012-05-25 01:52:35 +00:00
|
|
|
name,
|
2012-05-21 17:44:19 +00:00
|
|
|
extra,
|
2012-12-10 23:25:23 +00:00
|
|
|
jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
|
|
|
|
styles
|
2012-05-21 17:44:19 +00:00
|
|
|
) : 0
|
|
|
|
);
|
|
|
|
}
|
2011-12-12 15:22:38 +00:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
if ( !jQuery.support.opacity ) {
|
|
|
|
jQuery.cssHooks.opacity = {
|
|
|
|
get: function( elem, computed ) {
|
|
|
|
// IE uses filters for opacity
|
|
|
|
return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
|
2012-03-06 15:25:29 +00:00
|
|
|
( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
|
2011-12-12 15:22:38 +00:00
|
|
|
computed ? "1" : "";
|
|
|
|
},
|
|
|
|
|
|
|
|
set: function( elem, value ) {
|
|
|
|
var style = elem.style,
|
|
|
|
currentStyle = elem.currentStyle,
|
|
|
|
opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
|
|
|
|
filter = currentStyle && currentStyle.filter || style.filter || "";
|
|
|
|
|
|
|
|
// IE has trouble with opacity if it does not have layout
|
|
|
|
// Force it by setting the zoom level
|
|
|
|
style.zoom = 1;
|
|
|
|
|
|
|
|
// if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
|
2012-10-22 03:40:37 +00:00
|
|
|
// if value === "", then remove inline opacity #12685
|
|
|
|
if ( ( value >= 1 || value === "" ) &&
|
2012-12-11 04:39:08 +00:00
|
|
|
jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
|
|
|
|
style.removeAttribute ) {
|
2011-12-12 15:22:38 +00:00
|
|
|
|
|
|
|
// Setting style.filter to null, "" & " " still leave "filter:" in the cssText
|
|
|
|
// if "filter:" is present at all, clearType is disabled, we want to avoid this
|
|
|
|
// style.removeAttribute is IE Only, but so apparently is this code path...
|
|
|
|
style.removeAttribute( "filter" );
|
|
|
|
|
2012-10-22 03:40:37 +00:00
|
|
|
// if there is no filter style applied in a css rule or unset inline opacity, we are done
|
|
|
|
if ( value === "" || currentStyle && !currentStyle.filter ) {
|
2011-12-12 15:22:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// otherwise, set new filter values
|
|
|
|
style.filter = ralpha.test( filter ) ?
|
|
|
|
filter.replace( ralpha, opacity ) :
|
|
|
|
filter + " " + opacity;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2012-06-16 01:20:41 +00:00
|
|
|
// These hooks cannot be added until DOM ready because the support test
|
|
|
|
// for it is not run until after DOM ready
|
2011-12-12 15:22:38 +00:00
|
|
|
jQuery(function() {
|
|
|
|
if ( !jQuery.support.reliableMarginRight ) {
|
|
|
|
jQuery.cssHooks.marginRight = {
|
|
|
|
get: function( elem, computed ) {
|
2012-12-13 17:40:55 +00:00
|
|
|
if ( computed ) {
|
|
|
|
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
|
|
|
|
// Work around by temporarily setting element display to inline-block
|
|
|
|
return jQuery.swap( elem, { "display": "inline-block" },
|
|
|
|
curCSS, [ elem, "marginRight" ] );
|
|
|
|
}
|
2011-12-12 15:22:38 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2012-06-16 01:20:41 +00:00
|
|
|
|
|
|
|
// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
|
|
|
|
// getComputedStyle returns percent when specified for top/left/bottom/right
|
|
|
|
// rather than make the css module depend on the offset module, we just check for it here
|
|
|
|
if ( !jQuery.support.pixelPosition && jQuery.fn.position ) {
|
|
|
|
jQuery.each( [ "top", "left" ], function( i, prop ) {
|
|
|
|
jQuery.cssHooks[ prop ] = {
|
|
|
|
get: function( elem, computed ) {
|
|
|
|
if ( computed ) {
|
2012-12-13 17:40:55 +00:00
|
|
|
computed = curCSS( elem, prop );
|
2012-06-16 01:20:41 +00:00
|
|
|
// if curCSS returns percentage, fallback to offset
|
2012-12-13 17:40:55 +00:00
|
|
|
return rnumnonpx.test( computed ) ?
|
|
|
|
jQuery( elem ).position()[ prop ] + "px" :
|
|
|
|
computed;
|
2012-06-16 01:20:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2011-12-12 15:22:38 +00:00
|
|
|
});
|
|
|
|
|
2009-10-26 22:07:57 +00:00
|
|
|
if ( jQuery.expr && jQuery.expr.filters ) {
|
2009-12-05 20:02:45 +00:00
|
|
|
jQuery.expr.filters.hidden = function( elem ) {
|
2012-12-10 23:25:23 +00:00
|
|
|
return ( elem.offsetWidth === 0 && elem.offsetHeight === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
|
2009-10-26 22:07:57 +00:00
|
|
|
};
|
|
|
|
|
2009-12-05 20:02:45 +00:00
|
|
|
jQuery.expr.filters.visible = function( elem ) {
|
|
|
|
return !jQuery.expr.filters.hidden( elem );
|
2009-10-26 22:07:57 +00:00
|
|
|
};
|
2009-11-11 19:17:16 +00:00
|
|
|
}
|
2010-09-08 16:00:29 +00:00
|
|
|
|
2011-12-09 01:01:23 +00:00
|
|
|
// These hooks are used by animate to expand properties
|
|
|
|
jQuery.each({
|
|
|
|
margin: "",
|
|
|
|
padding: "",
|
|
|
|
border: "Width"
|
|
|
|
}, function( prefix, suffix ) {
|
|
|
|
jQuery.cssHooks[ prefix + suffix ] = {
|
|
|
|
expand: function( value ) {
|
2012-12-11 04:39:08 +00:00
|
|
|
var i = 0,
|
2012-12-13 17:40:55 +00:00
|
|
|
expanded = {},
|
2011-12-09 01:01:23 +00:00
|
|
|
|
|
|
|
// assumes a single number if not a string
|
2012-12-13 17:40:55 +00:00
|
|
|
parts = typeof value === "string" ? value.split(" ") : [ value ];
|
2011-12-09 01:01:23 +00:00
|
|
|
|
2012-12-11 04:39:08 +00:00
|
|
|
for ( ; i < 4; i++ ) {
|
2011-12-09 01:01:23 +00:00
|
|
|
expanded[ prefix + cssExpand[ i ] + suffix ] =
|
|
|
|
parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
|
|
|
|
}
|
|
|
|
|
|
|
|
return expanded;
|
|
|
|
}
|
|
|
|
};
|
2012-04-23 19:05:12 +00:00
|
|
|
|
|
|
|
if ( !rmargin.test( prefix ) ) {
|
|
|
|
jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
|
|
|
|
}
|
2011-12-09 01:01:23 +00:00
|
|
|
});
|