Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

1.8 effects #731

Closed
wants to merge 39 commits into
from
Commits
Jump to file or symbol
Failed to load files and symbols.
+618 −546
Split
View
@@ -1,18 +1,20 @@
(function( jQuery ) {
+jQuery.cssExpand = [ "Top", "Right", "Bottom", "Left" ];
+
var ralpha = /alpha\([^)]*\)/i,
ropacity = /opacity=([^)]*)/,
// fixed for IE9, see #8346
rupper = /([A-Z]|^ms)/g,
- rnum = /^[\-+]?(?:\d*\.)?\d+$/i,
+ rnumsplit = /^([\-+]?(?:\d*\.)?\d+)(.*)$/i,
rnumnonpx = /^-?(?:\d*\.)?\d+(?!px)[^\d\s]+$/i,
rrelNum = /^([\-+])=([\-+.\de]+)/,
rmargin = /^margin/,
cssShow = { position: "absolute", visibility: "hidden", display: "block" },
// order is important!
- cssExpand = [ "Top", "Right", "Bottom", "Left" ],
+ cssExpand = jQuery.cssExpand,
cssPrefixes = [ "O", "Webkit", "Moz", "ms" ],
curCSS;
@@ -264,6 +266,13 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) {
};
}
+function setPositiveNumber( elem, value ) {
+ var matches = rnumsplit.exec( value );
+ return matches ?
+ Math.max( 0, matches[ 1 ] ) + ( matches [ 2 ] || "px" )
+ : value;
+}
+
function getWidthOrHeight( elem, name, extra ) {
// Start with offset property, which is equivalent to the border-box value
@@ -348,11 +357,7 @@ jQuery.each([ "height", "width" ], function( i, name ) {
}
},
- set: function( elem, value ) {
- return rnum.test( value ) ?
- value + "px" :
- value;
- }
+ set: setPositiveNumber
};
});
@@ -436,7 +441,6 @@ jQuery.each({
padding: "",
border: "Width"
}, function( prefix, suffix ) {
-
jQuery.cssHooks[ prefix + suffix ] = {
expand: function( value ) {
var i,
@@ -453,6 +457,10 @@ jQuery.each({
return expanded;
}
};
+
+ if ( !rmargin.test( prefix ) ) {
+ jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
+ }
});
})( jQuery );
Oops, something went wrong.