jquery dimensions & offset: moving the local function 'num' to core, so it can be...
[jquery.git] / src / dimensions.js
1 // Create innerHeight, innerWidth, outerHeight and outerWidth methods
2 jQuery.each([ "Height", "Width" ], function(i, name){
3
4         var tl = i ? "Left"  : "Top",  // top or left
5                 br = i ? "Right" : "Bottom"; // bottom or right
6
7         // innerHeight and innerWidth
8         jQuery.fn["inner" + name] = function(){
9                 return this[ name.toLowerCase() ]() +
10                         num(this, "padding" + tl) +
11                         num(this, "padding" + br);
12         };
13
14         // outerHeight and outerWidth
15         jQuery.fn["outer" + name] = function(margin) {
16                 return this["inner" + name]() +
17                         num(this, "border" + tl + "Width") +
18                         num(this, "border" + br + "Width") +
19                         (margin ?
20                                 num(this, "margin" + tl) + num(this, "margin" + br) : 0);
21         };
22
23 });