diff options
author | Brandon Aaron <brandon.aaron@gmail.com> | 2008-04-29 03:26:06 +0000 |
---|---|---|
committer | Brandon Aaron <brandon.aaron@gmail.com> | 2008-04-29 03:26:06 +0000 |
commit | aea452f1624df811c8b0b2916bfb22213d153f9d (patch) | |
tree | 96b4a610b52a93edbdbabb3483d7f84ca494812f /src/dimensions.js | |
parent | f3f3238c53a3cad8ebe5c4be191ac4c5d0990f06 (diff) | |
download | jquery-aea452f1624df811c8b0b2916bfb22213d153f9d.tar.gz jquery-aea452f1624df811c8b0b2916bfb22213d153f9d.zip |
Merged dimensions with core
Diffstat (limited to 'src/dimensions.js')
-rw-r--r-- | src/dimensions.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/dimensions.js b/src/dimensions.js new file mode 100644 index 000000000..e707f8338 --- /dev/null +++ b/src/dimensions.js @@ -0,0 +1,28 @@ +// 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 |