diff --git a/source/Ox/js/Core.js b/source/Ox/js/Core.js index e0f3484f..f8612de8 100644 --- a/source/Ox/js/Core.js +++ b/source/Ox/js/Core.js @@ -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) diff --git a/source/Ox/js/DOM.js b/source/Ox/js/DOM.js index 9cafd053..fd4d3497 100644 --- a/source/Ox/js/DOM.js +++ b/source/Ox/js/DOM.js @@ -77,12 +77,12 @@ Ox.$ Generic HTML element, mimics jQuery > Ox.$('').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 The DOM element itself 0: element, @@ -91,10 +91,10 @@ Ox.$ = Ox.element = function(val) { (className) -> This element className 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) -> True if this element has the class className 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 Returns the height of this element @@ -211,9 +211,9 @@ Ox.$ = Ox.element = function(val) { (html) -> This element html 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) -> This element className 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) -> This element value 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;