diff options
author | Scott González <scott.gonzalez@gmail.com> | 2010-07-21 22:17:52 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2010-07-21 22:17:52 -0400 |
commit | 4deb824699b025d74d6849a73ec47c182df93fa0 (patch) | |
tree | 42e2cacdc7b031e8f56c23617eb31538fb715156 /ui/jquery.ui.core.js | |
parent | 3f070bdc62a8d00ca6d8428b1a1fe9e39ff72c65 (diff) | |
download | jquery-ui-4deb824699b025d74d6849a73ec47c182df93fa0.tar.gz jquery-ui-4deb824699b025d74d6849a73ec47c182df93fa0.zip |
Core: Added .outerWidth(), .outerHeight(), .innerWidth(), .innerHeight(). Fixes #5850 - .outerWidth(), .outerHeight(), .innerWidth(), .innerHeight() setters.
Diffstat (limited to 'ui/jquery.ui.core.js')
-rw-r--r-- | ui/jquery.ui.core.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js index bffa51d77..0804edab7 100644 --- a/ui/jquery.ui.core.js +++ b/ui/jquery.ui.core.js @@ -186,6 +186,49 @@ $.fn.extend({ } }); +$.each( [ "Width", "Height" ], function( i, name ) { + var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ], + type = name.toLowerCase(), + orig = { + innerWidth: $.fn.innerWidth, + innerHeight: $.fn.innerHeight, + outerWidth: $.fn.outerWidth, + outerHeight: $.fn.outerHeight + }; + + function reduce( elem, size, border, margin ) { + $.each( side, function() { + size -= parseFloat( $.curCSS( elem, "padding" + this, true)) || 0; + if ( border ) { + size -= parseFloat( $.curCSS( elem, "border" + this + "Width", true)) || 0; + } + if ( margin ) { + size -= parseFloat( $.curCSS( elem, "margin" + this, true)) || 0; + } + }); + return size; + } + + $.fn[ "inner" + name ] = function( size ) { + if ( size === undefined ) { + return orig[ "inner" + name ].call( this ); + } + + return this.each(function() { + $.style( this, 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() { + $.style( this, type, reduce( this, size, true, margin ) + "px" ); + }); + }; +}); //Additional selectors $.extend($.expr[':'], { |