rename vars
This commit is contained in:
parent
147d637b7b
commit
e4f34b1c7d
2 changed files with 24 additions and 23 deletions
|
@ -28,6 +28,7 @@ Some conventions:
|
||||||
object object
|
object object
|
||||||
regexp regexp
|
regexp regexp
|
||||||
ret return value
|
ret return value
|
||||||
|
string string
|
||||||
test test function
|
test test function
|
||||||
v value (of a key/value pair)
|
v value (of a key/value pair)
|
||||||
value value (of a key/value pair)
|
value value (of a key/value pair)
|
||||||
|
|
|
@ -77,12 +77,12 @@ Ox.$ <f> Generic HTML element, mimics jQuery
|
||||||
> Ox.$('<input>').val('red').val()
|
> Ox.$('<input>').val('red').val()
|
||||||
'red'
|
'red'
|
||||||
@*/
|
@*/
|
||||||
Ox.$ = Ox.element = function(val) {
|
Ox.$ = Ox.element = function(value) {
|
||||||
var element = !Ox.isString(val) ? val // window or document
|
var element = !Ox.isString(value) ? value // window or document
|
||||||
: val[0] == '<' ? document.createElement(val.slice(1, -1))
|
: value[0] == '<' ? document.createElement(value.slice(1, -1))
|
||||||
: val[0] == '#' ? document.getElementById(val.slice(1))
|
: value[0] == '#' ? document.getElementById(value.slice(1))
|
||||||
: val[0] == '.' ? document.getElementsByClassName(val.slice(1))[0]
|
: value[0] == '.' ? document.getElementsByClassName(value.slice(1))[0]
|
||||||
: document.getElementsByTagName(val)[0];
|
: document.getElementsByTagName(value)[0];
|
||||||
return element ? {
|
return element ? {
|
||||||
//@ 0 <e> The DOM element itself
|
//@ 0 <e> The DOM element itself
|
||||||
0: element,
|
0: element,
|
||||||
|
@ -91,10 +91,10 @@ Ox.$ = Ox.element = function(val) {
|
||||||
(className) -> <o> This element
|
(className) -> <o> This element
|
||||||
className <s> Class name
|
className <s> Class name
|
||||||
@*/
|
@*/
|
||||||
addClass: function(str) {
|
addClass: function(string) {
|
||||||
this[0].className = Ox.unique(((
|
this[0].className = Ox.unique(((
|
||||||
this[0].className ? this[0].className + ' ' : ''
|
this[0].className ? this[0].className + ' ' : ''
|
||||||
) + Ox.clean(str)).split(' ')).join(' ');
|
) + Ox.clean(string)).split(' ')).join(' ');
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
/*@
|
/*@
|
||||||
|
@ -134,8 +134,8 @@ Ox.$ = Ox.element = function(val) {
|
||||||
ret = void 0;
|
ret = void 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Ox.forEach(Ox.makeObject(arguments), function(v, k) {
|
Ox.forEach(Ox.makeObject(arguments), function(value, key) {
|
||||||
that[0].setAttribute(k, v);
|
that[0].setAttribute(key, value);
|
||||||
});
|
});
|
||||||
ret = this;
|
ret = this;
|
||||||
}
|
}
|
||||||
|
@ -169,8 +169,8 @@ Ox.$ = Ox.element = function(val) {
|
||||||
if (arguments.length == 1 && Ox.isString(arguments[0])) {
|
if (arguments.length == 1 && Ox.isString(arguments[0])) {
|
||||||
ret = this[0].style[arguments[0]];
|
ret = this[0].style[arguments[0]];
|
||||||
} else {
|
} else {
|
||||||
Ox.forEach(Ox.makeObject(arguments), function(v, k) {
|
Ox.forEach(Ox.makeObject(arguments), function(value, key) {
|
||||||
that[0].style[k] = v;
|
that[0].style[key] = value;
|
||||||
});
|
});
|
||||||
ret = this;
|
ret = this;
|
||||||
}
|
}
|
||||||
|
@ -188,8 +188,8 @@ Ox.$ = Ox.element = function(val) {
|
||||||
(className) -> <b> True if this element has the class
|
(className) -> <b> True if this element has the class
|
||||||
className <s> Class name
|
className <s> Class name
|
||||||
@*/
|
@*/
|
||||||
hasClass: function(str) {
|
hasClass: function(string) {
|
||||||
return this[0].className.split(' ').indexOf(str) > -1;
|
return this[0].className.split(' ').indexOf(string) > -1;
|
||||||
},
|
},
|
||||||
/*@
|
/*@
|
||||||
height <f> Returns the height of this element
|
height <f> Returns the height of this element
|
||||||
|
@ -211,9 +211,9 @@ Ox.$ = Ox.element = function(val) {
|
||||||
(html) -> <o> This element
|
(html) -> <o> This element
|
||||||
html <s> The inner HTML
|
html <s> The inner HTML
|
||||||
@*/
|
@*/
|
||||||
html: function(str) {
|
html: function(string) {
|
||||||
var ret;
|
var ret;
|
||||||
if (Ox.isUndefined(str)) {
|
if (arguments.length == 0) {
|
||||||
ret = this[0].innerHTML;
|
ret = this[0].innerHTML;
|
||||||
} else {
|
} else {
|
||||||
this[0].innerHTML = str;
|
this[0].innerHTML = str;
|
||||||
|
@ -232,8 +232,8 @@ Ox.$ = Ox.element = function(val) {
|
||||||
one: function(events) {
|
one: function(events) {
|
||||||
var that = this;
|
var that = this;
|
||||||
Ox.forEach(Ox.makeObject(arguments), function(callback, event) {
|
Ox.forEach(Ox.makeObject(arguments), function(callback, event) {
|
||||||
that.bind(event, function f() {
|
that.bind(event, function fn() {
|
||||||
that.unbind(event, f);
|
that.unbind(event, fn);
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -265,11 +265,11 @@ Ox.$ = Ox.element = function(val) {
|
||||||
(className) -> <o> This element
|
(className) -> <o> This element
|
||||||
className <s> Class name
|
className <s> Class name
|
||||||
@*/
|
@*/
|
||||||
removeClass: function(str) {
|
removeClass: function(string) {
|
||||||
var arr = Ox.clean(str).split(' ');
|
var array = Ox.clean(string).split(' ');
|
||||||
this[0].className = this[0].className.split(' ').filter(
|
this[0].className = this[0].className.split(' ').filter(
|
||||||
function(className) {
|
function(className) {
|
||||||
return arr.indexOf(className) == -1;
|
return array.indexOf(className) == -1;
|
||||||
}
|
}
|
||||||
).join(' ');
|
).join(' ');
|
||||||
return this;
|
return this;
|
||||||
|
@ -306,12 +306,12 @@ Ox.$ = Ox.element = function(val) {
|
||||||
(value) -> <o> This element
|
(value) -> <o> This element
|
||||||
value <s> Value
|
value <s> Value
|
||||||
@*/
|
@*/
|
||||||
val: function() {
|
val: function(value) {
|
||||||
var ret;
|
var ret;
|
||||||
if (arguments.length == 0) {
|
if (arguments.length == 0) {
|
||||||
return this[0].value;
|
return this[0].value;
|
||||||
} else {
|
} else {
|
||||||
this[0].value = arguments[0];
|
this[0].value = value;
|
||||||
ret = this;
|
ret = this;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in a new issue