X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Foffset.js;h=010c57d1954e679995a77f8443178fe1ec5fe585;hb=5d033dba02fc1ffe1398cdaf0e9d402fc75e13f0;hp=b29fcc7c2914b68db2eeb1108d8b22e311c73770;hpb=e71e4a47f35a4380664b6cc209e482adea6b4b14;p=jquery.git diff --git a/src/offset.js b/src/offset.js index b29fcc7..010c57d 100644 --- a/src/offset.js +++ b/src/offset.js @@ -96,3 +96,32 @@ jQuery.fn.offset = function() { return results; }; + +// Create innerHeight, innerWidth, outerHeight and outerWidth methods +jQuery.each(["Height", "Width"], function(i, name){ + + var tl = name == "Height" ? "Top" : "Left", // top or left + br = name == "Height" ? "Bottom" : "Right"; // bottom or right + + // innerHeight and innerWidth + jQuery.fn["inner" + name] = function(){ + return this[ name.toLowerCase() ]() + + num(this, "padding" + tl) + + num(this, "padding" + br); + }; + + // 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); + }; + +}); + +function num(elem, prop) { + elem = elem.jquery ? elem[0] : elem; + return elem && parseInt( jQuery.curCSS(elem, prop, true) ) || 0; +} \ No newline at end of file