aboutsummaryrefslogtreecommitdiffstats
path: root/attr
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2006-04-09 04:04:52 +0000
committerJohn Resig <jeresig@gmail.com>2006-04-09 04:04:52 +0000
commit40fdf0ad5c0dd13546a2a0925778605c5e7b1173 (patch)
tree74f6c97622d95c8281000a1e207d9072a5855747 /attr
parent4ab5a88bc4cd76c293190ed68a4962d91c108816 (diff)
downloadjquery-40fdf0ad5c0dd13546a2a0925778605c5e7b1173.tar.gz
jquery-40fdf0ad5c0dd13546a2a0925778605c5e7b1173.zip
Started work on new attr plugin - will provide a ton of accessors for common styles and attributes.
Diffstat (limited to 'attr')
-rw-r--r--attr/attr.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/attr/attr.js b/attr/attr.js
new file mode 100644
index 000000000..21331b63e
--- /dev/null
+++ b/attr/attr.js
@@ -0,0 +1,37 @@
+var pos = [
+ "height", "width", "top", "left", "bottom", "right",
+ "paddingTop", "paddingRight", "paddingBottom", "paddingLeft",
+ "marginTop", "marginRight", "marginBottom", "marginLeft",
+ "lineHeight", "maxWidth", "maxHeight", "minWidth", "minHeight",
+ "textIndent", "fontSize"
+];
+
+for ( var i = 0; i < pos.length; i++ ) {
+ (function(){
+ var o = pos[i];
+ $.fn[o] = function(a){
+ return a ?
+ this.css(o,a) :
+ parseInt( this.css(o) );
+ };
+ })();
+}
+
+var posArg = [
+ "clientLeft", "clientTop", "clientWidth", "clientHeight",
+ "offsetLeft", "offsetTop", "offsetWidth", "offsetHeight",
+ "scrollLeft", "scrollTop", "scrollWidth", "scrollHeight"
+];
+
+for ( var i = 0; i < posArg.length; i++ ) {
+ (function(){
+ var o = posArg[i];
+ $.fn[o] = function(a){
+ return a ? this.each(function(){
+ this[o] = parseInt( a );
+ }) : this.size() > 0 ?
+ this.get(0)[o] :
+ null;
+ };
+ })();
+} \ No newline at end of file