mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Core: Check if jQuery supports inner/outer/Width/Height setters.
This commit is contained in:
parent
15ece1f51a
commit
033f83ffeb
81
ui/jquery.ui.core.js
vendored
81
ui/jquery.ui.core.js
vendored
@ -119,49 +119,52 @@ $.fn.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$.each( [ "Width", "Height" ], function( i, name ) {
|
// support: jQuery <1.8
|
||||||
var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
|
if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
|
||||||
type = name.toLowerCase(),
|
$.each( [ "Width", "Height" ], function( i, name ) {
|
||||||
orig = {
|
var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
|
||||||
innerWidth: $.fn.innerWidth,
|
type = name.toLowerCase(),
|
||||||
innerHeight: $.fn.innerHeight,
|
orig = {
|
||||||
outerWidth: $.fn.outerWidth,
|
innerWidth: $.fn.innerWidth,
|
||||||
outerHeight: $.fn.outerHeight
|
innerHeight: $.fn.innerHeight,
|
||||||
|
outerWidth: $.fn.outerWidth,
|
||||||
|
outerHeight: $.fn.outerHeight
|
||||||
|
};
|
||||||
|
|
||||||
|
function reduce( elem, size, border, margin ) {
|
||||||
|
$.each( side, function() {
|
||||||
|
size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
|
||||||
|
if ( border ) {
|
||||||
|
size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
|
||||||
|
}
|
||||||
|
if ( margin ) {
|
||||||
|
size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
$.fn[ "inner" + name ] = function( size ) {
|
||||||
|
if ( size === undefined ) {
|
||||||
|
return orig[ "inner" + name ].call( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.each(function() {
|
||||||
|
$( this ).css( type, reduce( this, size ) + "px" );
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function reduce( elem, size, border, margin ) {
|
$.fn[ "outer" + name] = function( size, margin ) {
|
||||||
$.each( side, function() {
|
if ( typeof size !== "number" ) {
|
||||||
size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
|
return orig[ "outer" + name ].call( this, size );
|
||||||
if ( border ) {
|
|
||||||
size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
|
|
||||||
}
|
}
|
||||||
if ( margin ) {
|
|
||||||
size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
$.fn[ "inner" + name ] = function( size ) {
|
return this.each(function() {
|
||||||
if ( size === undefined ) {
|
$( this).css( type, reduce( this, size, true, margin ) + "px" );
|
||||||
return orig[ "inner" + name ].call( this );
|
});
|
||||||
}
|
};
|
||||||
|
});
|
||||||
return this.each(function() {
|
}
|
||||||
$( this ).css( type, reduce( this, size ) + "px" );
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
$.fn[ "outer" + name] = function( size, margin ) {
|
|
||||||
if ( typeof size !== "number" ) {
|
|
||||||
return orig[ "outer" + name ].call( this, size );
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.each(function() {
|
|
||||||
$( this).css( type, reduce( this, size, true, margin ) + "px" );
|
|
||||||
});
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
// selectors
|
// selectors
|
||||||
function focusable( element, isTabIndexNotNaN ) {
|
function focusable( element, isTabIndexNotNaN ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user