2012-05-21 17:44:19 +00:00
|
|
|
// order is important!
|
2012-04-23 19:05:12 +00:00
|
|
|
jQuery.cssExpand = [ "Top", "Right", "Bottom", "Left" ];
|
|
|
|
|
2012-05-29 02:25:04 +00:00
|
|
|
var curCSS, iframe, iframeDoc,
|
|
|
|
ralpha = /alpha\([^)]*\)/i,
|
2009-07-19 16:13:45 +00:00
|
|
|
ropacity = /opacity=([^)]*)/,
|
2012-04-23 19:05:12 +00:00
|
|
|
rnumsplit = /^([\-+]?(?:\d*\.)?\d+)(.*)$/i,
|
2011-12-09 01:26:50 +00:00
|
|
|
rnumnonpx = /^-?(?:\d*\.)?\d+(?!px)[^\d\s]+$/i,
|
2011-08-26 14:44:50 +00:00
|
|
|
rrelNum = /^([\-+])=([\-+.\de]+)/,
|
2011-12-07 01:32:26 +00:00
|
|
|
rmargin = /^margin/,
|
2012-05-29 02:25:04 +00:00
|
|
|
elemdisplay = {},
|
2010-09-05 15:01:27 +00:00
|
|
|
cssShow = { position: "absolute", visibility: "hidden", display: "block" },
|
2011-12-09 01:01:23 +00:00
|
|
|
|
2012-04-23 19:05:12 +00:00
|
|
|
cssExpand = jQuery.cssExpand,
|
2012-04-28 14:52:32 +00:00
|
|
|
cssPrefixes = [ "Webkit", "O", "Moz", "ms" ],
|
2012-05-25 01:39:31 +00:00
|
|
|
rposition = /^(top|right|bottom|left)$/,
|
2011-12-09 01:01:23 +00:00
|
|
|
|
2012-06-06 23:03:10 +00:00
|
|
|
eventsToggle = jQuery.fn.toggle,
|
|
|
|
|
|
|
|
cssNormalTransform = {
|
|
|
|
letterSpacing: 0,
|
|
|
|
fontWeight: 400,
|
|
|
|
lineHeight: 1
|
|
|
|
};
|
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-05-29 02:25:04 +00:00
|
|
|
function showHide( elements, show ) {
|
|
|
|
var elem, display,
|
|
|
|
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
|
|
|
|
if ( (elem.style.display === "" && curCSS( elem, "display" ) === "none") ||
|
|
|
|
!jQuery.contains( elem.ownerDocument.documentElement, 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
|
|
|
}
|
|
|
|
} else {
|
|
|
|
display = curCSS( elem, "display" );
|
|
|
|
|
|
|
|
if ( !values[ index ] && display !== "none" ) {
|
|
|
|
jQuery._data( elem, "olddisplay", display );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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 ) {
|
|
|
|
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( fn, fn2 ) {
|
|
|
|
var bool = typeof fn === "boolean";
|
|
|
|
|
|
|
|
if ( jQuery.isFunction( fn ) && jQuery.isFunction( fn2 ) ) {
|
|
|
|
return eventsToggle.apply( this, arguments );
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.each(function() {
|
|
|
|
var state = bool ? fn : jQuery( this ).is(":hidden");
|
|
|
|
showHide([ this ], state );
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
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: {
|
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
|
|
|
|
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 ) {
|
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-05-25 01:52:35 +00:00
|
|
|
css: function( elem, name, numeric, extra ) {
|
|
|
|
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 ) {
|
|
|
|
val = curCSS( elem, name );
|
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-06-06 23:03:10 +00:00
|
|
|
if ( numeric || extra !== undefined ) {
|
2012-05-25 01:52:35 +00:00
|
|
|
num = parseFloat( val );
|
|
|
|
return numeric || jQuery.isNumeric( num ) ? num || 0 : val;
|
|
|
|
}
|
|
|
|
return val;
|
2009-03-22 23:25:03 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// A method for quickly swapping in/out CSS properties to get correct calculations
|
|
|
|
swap: function( elem, options, callback ) {
|
2011-12-06 21:23:22 +00:00
|
|
|
var old = {},
|
|
|
|
ret, name;
|
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 ];
|
|
|
|
}
|
|
|
|
|
2011-12-06 21:23:22 +00:00
|
|
|
ret = callback.call( elem );
|
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-06-18 17:26:46 +00:00
|
|
|
// NOTE: To any future maintainer, we've used both window.getComputedStyle
|
2012-06-18 18:17:10 +00:00
|
|
|
// and getComputedStyle here to produce a better gzip size
|
2012-06-18 17:26:46 +00:00
|
|
|
if ( window.getComputedStyle ) {
|
2012-04-20 18:18:15 +00:00
|
|
|
curCSS = function( elem, name ) {
|
2012-06-18 17:26:46 +00:00
|
|
|
var ret, width,
|
|
|
|
computed = getComputedStyle( elem, null ),
|
2011-12-12 15:22:38 +00:00
|
|
|
style = elem.style;
|
2010-09-05 04:04:37 +00:00
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
if ( computed ) {
|
2011-12-12 15:22:38 +00:00
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
ret = computed[ name ];
|
2010-10-11 19:11:03 +00:00
|
|
|
if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
|
|
|
|
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"
|
|
|
|
// WebKit uses "computed value (percentage if specified)" instead of "used value" for margins
|
|
|
|
// which is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
|
|
|
|
if ( !jQuery.support.pixelMargin && rmargin.test( name ) && rnumnonpx.test( ret ) ) {
|
|
|
|
width = style.width;
|
|
|
|
style.width = ret;
|
2012-06-18 17:26:46 +00:00
|
|
|
ret = computed.width;
|
2012-06-16 01:20:41 +00:00
|
|
|
style.width = width;
|
|
|
|
}
|
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 ) {
|
|
|
|
curCSS = function( elem, name ) {
|
2011-11-01 13:46:20 +00:00
|
|
|
var left, rsLeft, uncomputed,
|
2010-11-09 16:09:07 +00:00
|
|
|
ret = elem.currentStyle && elem.currentStyle[ name ],
|
|
|
|
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
|
2011-12-06 21:44:32 +00:00
|
|
|
if ( ret == null && style && (uncomputed = style[ name ]) ) {
|
2011-11-01 13:46:20 +00:00
|
|
|
ret = uncomputed;
|
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;
|
2011-10-28 14:53:42 +00:00
|
|
|
rsLeft = elem.runtimeStyle && elem.runtimeStyle.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 ) {
|
|
|
|
elem.runtimeStyle.left = elem.currentStyle.left;
|
|
|
|
}
|
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 ) {
|
|
|
|
elem.runtimeStyle.left = rsLeft;
|
|
|
|
}
|
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-05-25 01:52:35 +00:00
|
|
|
Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
|
|
|
|
value;
|
2012-04-23 19:05:12 +00:00
|
|
|
}
|
|
|
|
|
2012-05-25 01:52:35 +00:00
|
|
|
function augmentWidthOrHeight( elem, name, extra, isBorderBox ) {
|
|
|
|
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" ) {
|
|
|
|
// we use jQuery.css instead of curCSS here
|
|
|
|
// because of the reliableMarginRight CSS hook!
|
|
|
|
val += jQuery.css( elem, extra + cssExpand[ i ], true );
|
|
|
|
}
|
2012-05-21 17:44:19 +00:00
|
|
|
|
2012-05-25 01:52:35 +00:00
|
|
|
// From this point on we use curCSS for maximum performance (relevant in animations)
|
|
|
|
if ( isBorderBox ) {
|
|
|
|
// border-box includes padding, so remove it if we want content
|
|
|
|
if ( extra === "content" ) {
|
|
|
|
val -= parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0;
|
|
|
|
}
|
2012-05-21 17:44:19 +00:00
|
|
|
|
2012-05-25 01:52:35 +00:00
|
|
|
// at this point, extra isnt border nor margin, so remove border
|
|
|
|
if ( extra !== "margin" ) {
|
|
|
|
val -= parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// at this point, extra isnt content, so add padding
|
|
|
|
val += parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0;
|
2012-05-21 17:44:19 +00:00
|
|
|
|
2012-05-25 01:52:35 +00:00
|
|
|
// at this point, extra isnt content nor padding, so add border
|
|
|
|
if ( extra !== "padding" ) {
|
|
|
|
val += parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
|
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
|
2011-06-07 03:35:16 +00:00
|
|
|
var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
|
2012-04-10 21:18:00 +00:00
|
|
|
valueIsBorderBox = true,
|
|
|
|
isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box";
|
2012-04-06 12:39:59 +00:00
|
|
|
|
|
|
|
if ( val <= 0 ) {
|
|
|
|
// Fall back to computed then uncomputed css if necessary
|
|
|
|
val = curCSS( elem, name );
|
|
|
|
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" ),
|
|
|
|
valueIsBorderBox
|
|
|
|
)
|
|
|
|
) + "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-06-04 16:48:18 +00:00
|
|
|
if ( elemdisplay[ nodeName ] ) {
|
|
|
|
return elemdisplay[ nodeName ];
|
|
|
|
}
|
|
|
|
|
|
|
|
var elem = jQuery( "<" + nodeName + ">" ).appendTo( document.body ),
|
|
|
|
display = elem.css("display");
|
|
|
|
elem.remove();
|
|
|
|
|
|
|
|
// If the simple way fails,
|
|
|
|
// get element's real default display by attaching it to a temp iframe
|
|
|
|
if ( display === "none" || display === "" ) {
|
|
|
|
// Use the already-created iframe if possible
|
|
|
|
iframe = document.body.appendChild(
|
|
|
|
iframe || jQuery.extend( document.createElement("iframe"), {
|
|
|
|
frameBorder: 0,
|
|
|
|
width: 0,
|
|
|
|
height: 0
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
// Create a cacheable copy of the iframe document on first call.
|
|
|
|
// IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
|
|
|
|
// document to it; WebKit & Firefox won't allow reusing the iframe document.
|
|
|
|
if ( !iframeDoc || !iframe.createElement ) {
|
|
|
|
iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
|
|
|
|
iframeDoc.write("<!doctype html><html><body>");
|
|
|
|
iframeDoc.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
elem = iframeDoc.body.appendChild( iframeDoc.createElement(nodeName) );
|
|
|
|
|
|
|
|
display = curCSS( elem, "display" );
|
|
|
|
document.body.removeChild( iframe );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Store the correct default display
|
|
|
|
elemdisplay[ nodeName ] = display;
|
|
|
|
|
|
|
|
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-06-07 15:08:31 +00:00
|
|
|
if ( elem.offsetWidth !== 0 || curCSS( elem, "display" ) !== "none" ) {
|
2011-12-12 15:22:38 +00:00
|
|
|
return getWidthOrHeight( elem, name, extra );
|
|
|
|
} else {
|
|
|
|
return jQuery.swap( elem, cssShow, function() {
|
|
|
|
return getWidthOrHeight( elem, name, extra );
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-05-21 17:44:19 +00:00
|
|
|
set: function( elem, value, extra ) {
|
|
|
|
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,
|
|
|
|
jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box"
|
|
|
|
) : 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
|
|
|
|
if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" ) {
|
|
|
|
|
|
|
|
// 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" );
|
|
|
|
|
|
|
|
// if there there is no filter style applied in a css rule, we are done
|
|
|
|
if ( currentStyle && !currentStyle.filter ) {
|
|
|
|
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 ) {
|
|
|
|
// 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" }, function() {
|
|
|
|
if ( computed ) {
|
2012-05-31 12:32:19 +00:00
|
|
|
return curCSS( elem, "marginRight" );
|
2011-12-12 15:22:38 +00:00
|
|
|
} else {
|
|
|
|
return elem.style.marginRight;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
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 ) {
|
|
|
|
var ret = curCSS( elem, prop );
|
|
|
|
// if curCSS returns percentage, fallback to offset
|
|
|
|
return rnumnonpx.test( ret ) ? jQuery( elem ).position()[ prop ] + "px" : ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
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 ) {
|
2010-11-09 16:09:07 +00:00
|
|
|
var width = elem.offsetWidth,
|
|
|
|
height = elem.offsetHeight;
|
2010-10-05 18:23:10 +00:00
|
|
|
|
2011-10-27 19:29:09 +00:00
|
|
|
return ( width === 0 && height === 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 ) {
|
|
|
|
var i,
|
|
|
|
|
|
|
|
// assumes a single number if not a string
|
|
|
|
parts = typeof value === "string" ? value.split(" ") : [ value ],
|
|
|
|
expanded = {};
|
|
|
|
|
|
|
|
for ( i = 0; i < 4; i++ ) {
|
|
|
|
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
|
|
|
});
|