mirror of
https://github.com/jquery/jquery.git
synced 2026-02-02 12:55:02 -05:00
Conflicts: Gruntfile.js README.md src/ajax.js src/ajax/xhr.js src/attributes.js src/core.js src/css.js src/data.js src/effects.js src/event.js src/manipulation.js src/offset.js src/selector-native.js src/traversing.js test/unit/core.js test/unit/data.js
This commit is contained in:
85
src/css.js
85
src/css.js
@@ -1,4 +1,14 @@
|
||||
var iframe, getStyles, curCSS,
|
||||
define([
|
||||
"./core",
|
||||
"./var/pnum",
|
||||
"./css/var/cssExpand",
|
||||
"./css/var/isHidden",
|
||||
"./css/defaultDisplay",
|
||||
"./core/swap",
|
||||
"./selector" // contains
|
||||
], function( jQuery, pnum, cssExpand, isHidden, defaultDisplay ) {
|
||||
|
||||
var getStyles, curCSS,
|
||||
ralpha = /alpha\([^)]*\)/i,
|
||||
ropacity = /opacity\s*=\s*([^)]*)/,
|
||||
rposition = /^(top|right|bottom|left)$/,
|
||||
@@ -6,10 +16,9 @@ var iframe, getStyles, curCSS,
|
||||
// see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
|
||||
rdisplayswap = /^(none|table(?!-c[ea]).+)/,
|
||||
rmargin = /^margin/,
|
||||
rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ),
|
||||
rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ),
|
||||
rrelNum = new RegExp( "^([+-])=(" + core_pnum + ")", "i" ),
|
||||
elemdisplay = { BODY: "block" },
|
||||
rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
|
||||
rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ),
|
||||
rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
|
||||
|
||||
cssShow = { position: "absolute", visibility: "hidden", display: "block" },
|
||||
cssNormalTransform = {
|
||||
@@ -17,7 +26,6 @@ var iframe, getStyles, curCSS,
|
||||
fontWeight: 400
|
||||
},
|
||||
|
||||
cssExpand = [ "Top", "Right", "Bottom", "Left" ],
|
||||
cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
|
||||
|
||||
// return a css property mapped to a potentially vendor prefixed property
|
||||
@@ -43,13 +51,6 @@ function vendorPropName( style, name ) {
|
||||
return origName;
|
||||
}
|
||||
|
||||
function isHidden( elem, el ) {
|
||||
// isHidden might be called from jQuery#filter function;
|
||||
// in that case, element will be second argument
|
||||
elem = el || elem;
|
||||
return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
|
||||
}
|
||||
|
||||
function showHide( elements, show ) {
|
||||
var display, elem, hidden,
|
||||
values = [],
|
||||
@@ -75,7 +76,7 @@ function showHide( elements, show ) {
|
||||
// in a stylesheet to whatever the default browser style is
|
||||
// for such an element
|
||||
if ( elem.style.display === "" && isHidden( elem ) ) {
|
||||
values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) );
|
||||
values[ index ] = jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) );
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -469,46 +470,6 @@ function getWidthOrHeight( elem, name, extra ) {
|
||||
) + "px";
|
||||
}
|
||||
|
||||
// Try to determine the default display value of an element
|
||||
function css_defaultDisplay( nodeName ) {
|
||||
var doc = document,
|
||||
display = elemdisplay[ nodeName ];
|
||||
|
||||
if ( !display ) {
|
||||
display = actualDisplay( nodeName, doc );
|
||||
|
||||
// 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();
|
||||
|
||||
display = actualDisplay( nodeName, doc );
|
||||
iframe.detach();
|
||||
}
|
||||
|
||||
// Store the correct default display
|
||||
elemdisplay[ nodeName ] = display;
|
||||
}
|
||||
|
||||
return display;
|
||||
}
|
||||
|
||||
// Called ONLY from within css_defaultDisplay
|
||||
function actualDisplay( name, doc ) {
|
||||
var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
|
||||
display = jQuery.css( elem[0], "display" );
|
||||
elem.remove();
|
||||
return display;
|
||||
}
|
||||
|
||||
jQuery.each([ "height", "width" ], function( i, name ) {
|
||||
jQuery.cssHooks[ name ] = {
|
||||
get: function( elem, computed, extra ) {
|
||||
@@ -601,6 +562,7 @@ jQuery(function() {
|
||||
// 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
|
||||
// TODO: Optional dependency on offset
|
||||
if ( !jQuery.support.pixelPosition && jQuery.fn.position ) {
|
||||
jQuery.each( [ "top", "left" ], function( i, prop ) {
|
||||
jQuery.cssHooks[ prop ] = {
|
||||
@@ -616,21 +578,8 @@ jQuery(function() {
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if ( jQuery.expr && jQuery.expr.filters ) {
|
||||
jQuery.expr.filters.hidden = function( elem ) {
|
||||
// Support: Opera <= 12.12
|
||||
// Opera reports offsetWidths and offsetHeights less than zero on some elements
|
||||
return elem.offsetWidth <= 0 && elem.offsetHeight <= 0 ||
|
||||
(!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
|
||||
};
|
||||
|
||||
jQuery.expr.filters.visible = function( elem ) {
|
||||
return !jQuery.expr.filters.hidden( elem );
|
||||
};
|
||||
}
|
||||
|
||||
// These hooks are used by animate to expand properties
|
||||
jQuery.each({
|
||||
@@ -659,3 +608,5 @@ jQuery.each({
|
||||
jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user