Skip to content

Commit f717260

Browse files
committed
jquery dimensions: reducing the code size.
1 parent 44a6f5d commit f717260

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/dimensions.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Create innerHeight, innerWidth, outerHeight and outerWidth methods
22
jQuery.each([ "Height", "Width" ], function(i, name){
33

4-
var tl = name == "Height" ? "Top" : "Left", // top or left
5-
br = name == "Height" ? "Bottom" : "Right"; // bottom or right
4+
var tl = i ? "Left" : "Top", // top or left
5+
br = i ? "Right" : "Bottom"; // bottom or right
66

77
// innerHeight and innerWidth
88
jQuery.fn["inner" + name] = function(){
@@ -16,13 +16,12 @@ jQuery.each([ "Height", "Width" ], function(i, name){
1616
return this["inner" + name]() +
1717
num(this, "border" + tl + "Width") +
1818
num(this, "border" + br + "Width") +
19-
(!!margin ?
19+
(margin ?
2020
num(this, "margin" + tl) + num(this, "margin" + br) : 0);
2121
};
2222

2323
});
2424

2525
function num(elem, prop) {
26-
elem = elem.jquery ? elem[0] : elem;
27-
return elem && parseInt( jQuery.curCSS(elem, prop, true), 10 ) || 0;
26+
return elem[0] && parseInt( jQuery.curCSS(elem[0], prop, true), 10 ) || 0;
2827
}

0 commit comments

Comments
 (0)