X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fdimensions.js;h=7371f00fa75fba8beaa75e92ce23a7da2f0f1b1f;hb=a974b255c30ac23906ba45bf95de99542a70b587;hp=297118457375a3103ff5d6b05d0e15ce7e434f8e;hpb=b850ab2b8e65eadd25093c81bbc67a881daa0488;p=jquery.git diff --git a/src/dimensions.js b/src/dimensions.js index 2971184..7371f00 100644 --- a/src/dimensions.js +++ b/src/dimensions.js @@ -1,27 +1,22 @@ // Create innerHeight, innerWidth, outerHeight and outerWidth methods jQuery.each([ "Height", "Width" ], function(i, name){ - var tl = i ? "Left" : "Top", // top or left - br = i ? "Right" : "Bottom"; // bottom or right + var type = name.toLowerCase(); // innerHeight and innerWidth jQuery.fn["inner" + name] = function(){ - return this[ name.toLowerCase() ]() + - num(this, "padding" + tl) + - num(this, "padding" + br); + return this[0] ? + jQuery.css( this[0], type, false, "padding" ) : + null; }; // outerHeight and outerWidth jQuery.fn["outer" + name] = function(margin) { - return this["inner" + name]() + - num(this, "border" + tl + "Width") + - num(this, "border" + br + "Width") + - (margin ? - num(this, "margin" + tl) + num(this, "margin" + br) : 0); + return this[0] ? + jQuery.css( this[0], type, false, margin ? "margin" : "border" ) : + null; }; - var type = name.toLowerCase(); - jQuery.fn[ type ] = function( size ) { // Get window width or height return this[0] == window ? @@ -47,4 +42,4 @@ jQuery.each([ "Height", "Width" ], function(i, name){ this.css( type, typeof size === "string" ? size : size + "px" ); }; -}); \ No newline at end of file +});