test runner: when errors are thrown in a test, the message is successfully show on...
[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 = name == "Height" ? "Top"    : "Left",  // top or left
5                 br = name == "Height" ? "Bottom" : "Right"; // 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 });
24
25 function num(elem, prop) {
26         elem = elem.jquery ? elem[0] : elem;
27         return elem && parseInt( jQuery.curCSS(elem, prop, true), 10 ) || 0;
28 }