21331b63ea998f7fdf6d5861f2fb5513f6667dea
[jquery.git] / attr / attr.js
1 var pos = [
2   "height", "width", "top", "left", "bottom", "right",
3   "paddingTop", "paddingRight", "paddingBottom", "paddingLeft",
4   "marginTop", "marginRight", "marginBottom", "marginLeft",
5   "lineHeight", "maxWidth", "maxHeight", "minWidth", "minHeight",
6   "textIndent", "fontSize"
7 ];
8
9 for ( var i = 0; i < pos.length; i++ ) {
10         (function(){
11                 var o = pos[i];
12                 $.fn[o] = function(a){
13                         return a ?
14                                 this.css(o,a) :
15                                 parseInt( this.css(o) );
16                 };
17         })();
18 }
19
20 var posArg = [
21         "clientLeft", "clientTop", "clientWidth", "clientHeight",
22         "offsetLeft", "offsetTop", "offsetWidth", "offsetHeight",
23         "scrollLeft", "scrollTop", "scrollWidth", "scrollHeight"
24 ];
25
26 for ( var i = 0; i < posArg.length; i++ ) {
27         (function(){
28                 var o = posArg[i];
29                 $.fn[o] = function(a){
30                         return a ? this.each(function(){
31                                 this[o] = parseInt( a );
32                         }) : this.size() > 0 ?
33                                 this.get(0)[o] :
34                                 null;
35                 };
36         })();
37 }