rename vars

This commit is contained in:
rolux 2012-05-25 09:52:57 +02:00
parent 147d637b7b
commit e4f34b1c7d
2 changed files with 24 additions and 23 deletions

View file

@ -28,6 +28,7 @@ Some conventions:
object object
regexp regexp
ret return value
string string
test test function
v value (of a key/value pair)
value value (of a key/value pair)

View file

@ -77,12 +77,12 @@ Ox.$ <f> Generic HTML element, mimics jQuery
> Ox.$('<input>').val('red').val()
'red'
@*/
Ox.$ = Ox.element = function(val) {
var element = !Ox.isString(val) ? val // window or document
: val[0] == '<' ? document.createElement(val.slice(1, -1))
: val[0] == '#' ? document.getElementById(val.slice(1))
: val[0] == '.' ? document.getElementsByClassName(val.slice(1))[0]
: document.getElementsByTagName(val)[0];
Ox.$ = Ox.element = function(value) {
var element = !Ox.isString(value) ? value // window or document
: value[0] == '<' ? document.createElement(value.slice(1, -1))
: value[0] == '#' ? document.getElementById(value.slice(1))
: value[0] == '.' ? document.getElementsByClassName(value.slice(1))[0]
: document.getElementsByTagName(value)[0];
return element ? {
//@ 0 <e> The DOM element itself
0: element,
@ -91,10 +91,10 @@ Ox.$ = Ox.element = function(val) {
(className) -> <o> This element
className <s> Class name
@*/
addClass: function(str) {
addClass: function(string) {
this[0].className = Ox.unique(((
this[0].className ? this[0].className + ' ' : ''
) + Ox.clean(str)).split(' ')).join(' ');
) + Ox.clean(string)).split(' ')).join(' ');
return this;
},
/*@
@ -134,8 +134,8 @@ Ox.$ = Ox.element = function(val) {
ret = void 0;
}
} else {
Ox.forEach(Ox.makeObject(arguments), function(v, k) {
that[0].setAttribute(k, v);
Ox.forEach(Ox.makeObject(arguments), function(value, key) {
that[0].setAttribute(key, value);
});
ret = this;
}
@ -169,8 +169,8 @@ Ox.$ = Ox.element = function(val) {
if (arguments.length == 1 && Ox.isString(arguments[0])) {
ret = this[0].style[arguments[0]];
} else {
Ox.forEach(Ox.makeObject(arguments), function(v, k) {
that[0].style[k] = v;
Ox.forEach(Ox.makeObject(arguments), function(value, key) {
that[0].style[key] = value;
});
ret = this;
}
@ -188,8 +188,8 @@ Ox.$ = Ox.element = function(val) {
(className) -> <b> True if this element has the class
className <s> Class name
@*/
hasClass: function(str) {
return this[0].className.split(' ').indexOf(str) > -1;
hasClass: function(string) {
return this[0].className.split(' ').indexOf(string) > -1;
},
/*@
height <f> Returns the height of this element
@ -211,9 +211,9 @@ Ox.$ = Ox.element = function(val) {
(html) -> <o> This element
html <s> The inner HTML
@*/
html: function(str) {
html: function(string) {
var ret;
if (Ox.isUndefined(str)) {
if (arguments.length == 0) {
ret = this[0].innerHTML;
} else {
this[0].innerHTML = str;
@ -232,8 +232,8 @@ Ox.$ = Ox.element = function(val) {
one: function(events) {
var that = this;
Ox.forEach(Ox.makeObject(arguments), function(callback, event) {
that.bind(event, function f() {
that.unbind(event, f);
that.bind(event, function fn() {
that.unbind(event, fn);
callback();
});
});
@ -265,11 +265,11 @@ Ox.$ = Ox.element = function(val) {
(className) -> <o> This element
className <s> Class name
@*/
removeClass: function(str) {
var arr = Ox.clean(str).split(' ');
removeClass: function(string) {
var array = Ox.clean(string).split(' ');
this[0].className = this[0].className.split(' ').filter(
function(className) {
return arr.indexOf(className) == -1;
return array.indexOf(className) == -1;
}
).join(' ');
return this;
@ -306,12 +306,12 @@ Ox.$ = Ox.element = function(val) {
(value) -> <o> This element
value <s> Value
@*/
val: function() {
val: function(value) {
var ret;
if (arguments.length == 0) {
return this[0].value;
} else {
this[0].value = arguments[0];
this[0].value = value;
ret = this;
}
return ret;