formatting

This commit is contained in:
rolux 2014-09-22 14:34:44 +02:00
parent 78c1b55d85
commit 55999d654c

View file

@ -81,6 +81,7 @@ Ox.$ = Ox.element = function $(value) {
return elements.length ? Ox.extend( return elements.length ? Ox.extend(
Ox.zipObject(Ox.range(elements.length), elements Ox.zipObject(Ox.range(elements.length), elements
), { ), {
/*@ /*@
add <f> Adds another DOM object to this DOM object add <f> Adds another DOM object to this DOM object
(other) -> This DOM object (other) -> This DOM object
@ -91,6 +92,7 @@ Ox.$ = Ox.element = function $(value) {
this.length = elements.length; this.length = elements.length;
return this; return this;
}, },
/*@ /*@
addClass <f> Adds a class name to all elements addClass <f> Adds a class name to all elements
(className) -> <o> This DOM object (className) -> <o> This DOM object
@ -105,6 +107,7 @@ Ox.$ = Ox.element = function $(value) {
}); });
return this; return this;
}, },
/*@ /*@
append <f> Appends one or more DOM objects to this DOM object append <f> Appends one or more DOM objects to this DOM object
(object[, object[, ...]]) -> <o> This DOM object (object[, object[, ...]]) -> <o> This DOM object
@ -121,6 +124,7 @@ Ox.$ = Ox.element = function $(value) {
}); });
return this; return this;
}, },
/*@ /*@
appendTo <f> Appends this DOM object to another DOM object appendTo <f> Appends this DOM object to another DOM object
(object) -> <o> This DOM object (object) -> <o> This DOM object
@ -134,6 +138,7 @@ Ox.$ = Ox.element = function $(value) {
}); });
return this; return this;
}, },
/*@ /*@
attr <f> Gets or sets an attribute for all elements attr <f> Gets or sets an attribute for all elements
(key) -> <s> Value (key) -> <s> Value
@ -165,6 +170,7 @@ Ox.$ = Ox.element = function $(value) {
return this; return this;
} }
}, },
/*@ /*@
children <f> Returns the unique list of children of all elements children <f> Returns the unique list of children of all elements
([selector]) -> <[h]> Children ([selector]) -> <[h]> Children
@ -178,6 +184,7 @@ Ox.$ = Ox.element = function $(value) {
return Ox.$(child).is(selector); return Ox.$(child).is(selector);
}) : children); }) : children);
}, },
/*@ /*@
css <f> Gets or sets a CSS attribute for all elements css <f> Gets or sets a CSS attribute for all elements
(key) -> <s> Value (key) -> <s> Value
@ -199,6 +206,7 @@ Ox.$ = Ox.element = function $(value) {
return this; return this;
} }
}, },
/*@ /*@
data <f> Gets or sets data data <f> Gets or sets data
() -> <o> All data () -> <o> All data
@ -220,10 +228,12 @@ Ox.$ = Ox.element = function $(value) {
return this; return this;
} }
}, },
/*@ /*@
elements <a> All elements elements <a> All elements
@*/ @*/
elements: elements, elements: elements,
/*@ /*@
eq <f> Reduces the list of elements to the one at the given index eq <f> Reduces the list of elements to the one at the given index
() -> <o> This DOM object () -> <o> This DOM object
@ -237,6 +247,7 @@ Ox.$ = Ox.element = function $(value) {
this.length = 1; this.length = 1;
return this; return this;
}, },
/*@ /*@
empty <f> Empties the inner HTML of all elements empty <f> Empties the inner HTML of all elements
() -> <o> This DOM object () -> <o> This DOM object
@ -244,6 +255,7 @@ Ox.$ = Ox.element = function $(value) {
empty: function empty() { empty: function empty() {
return this.html(''); return this.html('');
}, },
/*@ /*@
every <f> Tests if every element satisfies a given condition every <f> Tests if every element satisfies a given condition
(test) -> True if every element passes the test (test) -> True if every element passes the test
@ -252,6 +264,7 @@ Ox.$ = Ox.element = function $(value) {
every: function every() { every: function every() {
return Array.prototype.every.apply(elements, arguments); return Array.prototype.every.apply(elements, arguments);
}, },
/*@ /*@
filter <f> Filters all elements by a given condition filter <f> Filters all elements by a given condition
(test) -> Array of matching elements (test) -> Array of matching elements
@ -260,6 +273,7 @@ Ox.$ = Ox.element = function $(value) {
filter: function filter() { filter: function filter() {
return Array.prototype.filter.apply(elements, arguments); return Array.prototype.filter.apply(elements, arguments);
}, },
/*@ /*@
find <f> Find all descendant elements matching a CSS selector find <f> Find all descendant elements matching a CSS selector
([selector]) -> <[h]> Elements ([selector]) -> <[h]> Elements
@ -270,6 +284,7 @@ Ox.$ = Ox.element = function $(value) {
return Ox.slice(element.querySelectorAll(selector || '*')); return Ox.slice(element.querySelectorAll(selector || '*'));
})))); }))));
}, },
/*@ /*@
forEach <f> Loops over all elements forEach <f> Loops over all elements
(iterator) -> This DOM object (iterator) -> This DOM object
@ -279,6 +294,7 @@ Ox.$ = Ox.element = function $(value) {
Array.prototype.forEach.apply(elements, arguments); Array.prototype.forEach.apply(elements, arguments);
return this; return this;
}, },
/*@ /*@
hasClass <f> Returns true if this element has a given class hasClass <f> Returns true if this element has a given class
(className) -> <b> True if this element has the class (className) -> <b> True if this element has the class
@ -289,6 +305,7 @@ Ox.$ = Ox.element = function $(value) {
return Ox.contains(element.className.split(' '), string); return Ox.contains(element.className.split(' '), string);
}); });
}, },
/*@ /*@
height <f> Returns the height of the first element height <f> Returns the height of the first element
() -> <n> Height in px () -> <n> Height in px
@ -296,6 +313,7 @@ Ox.$ = Ox.element = function $(value) {
height: function height() { height: function height() {
return elements[0].offsetHeight; return elements[0].offsetHeight;
}, },
/*@ /*@
hide <f> Hides all elements hide <f> Hides all elements
() -> <o> This DOM object () -> <o> This DOM object
@ -304,6 +322,7 @@ Ox.$ = Ox.element = function $(value) {
previousDisplay = this.css('display'); previousDisplay = this.css('display');
return this.css({display: 'none'}); return this.css({display: 'none'});
}, },
/*@ /*@
html <f> Gets or sets the innerHTML of all elements html <f> Gets or sets the innerHTML of all elements
() -> <s> The inner HTML () -> <s> The inner HTML
@ -325,6 +344,7 @@ Ox.$ = Ox.element = function $(value) {
return this; return this;
} }
}, },
/*@ /*@
insertAfter <f> Inserts this DOM object after another DOM object insertAfter <f> Inserts this DOM object after another DOM object
(object) -> <o> This DOM object (object) -> <o> This DOM object
@ -337,6 +357,7 @@ Ox.$ = Ox.element = function $(value) {
}) })
return this; return this;
}, },
/*@ /*@
insertBefore <f> Inserts this DOM object before another DOM object insertBefore <f> Inserts this DOM object before another DOM object
(object) -> <o> This DOM object (object) -> <o> This DOM object
@ -348,6 +369,7 @@ Ox.$ = Ox.element = function $(value) {
}); });
return this; return this;
}, },
/*@ /*@
is <f> Tests if any element matches a CSS selector is <f> Tests if any element matches a CSS selector
(selector) -> <b> True if the element matches the selector (selector) -> <b> True if the element matches the selector
@ -363,10 +385,12 @@ Ox.$ = Ox.element = function $(value) {
return Ox.contains(parent.querySelectorAll(selector), element); return Ox.contains(parent.querySelectorAll(selector), element);
}); });
}, },
/*@ /*@
length <n> Number of elements length <n> Number of elements
@*/ @*/
length: elements.length, length: elements.length,
/*@ /*@
map <f> Transforms all elements map <f> Transforms all elements
(iterator) -> [] Transformed elements (iterator) -> [] Transformed elements
@ -375,6 +399,7 @@ Ox.$ = Ox.element = function $(value) {
map: function map() { map: function map() {
return Array.prototype.filter.map(elements, arguments); return Array.prototype.filter.map(elements, arguments);
}, },
/*@ /*@
next <f> Returns the unique list of siblings directly after all elements next <f> Returns the unique list of siblings directly after all elements
() -> <[h]> Siblings () -> <[h]> Siblings
@ -384,6 +409,7 @@ Ox.$ = Ox.element = function $(value) {
return element.nextSibling; return element.nextSibling;
})))); }))));
}, },
/*@ /*@
nextAll <f> Returns the unique list of siblings after all elements nextAll <f> Returns the unique list of siblings after all elements
() -> <[h]> Siblings () -> <[h]> Siblings
@ -402,6 +428,7 @@ Ox.$ = Ox.element = function $(value) {
}); });
return Ox.$(Ox.unique(siblings)); return Ox.$(Ox.unique(siblings));
}, },
/*@ /*@
off <f> Unbinds a callback from an event off <f> Unbinds a callback from an event
(event) -> <o> This DOM object (unbinds all callbacks) (event) -> <o> This DOM object (unbinds all callbacks)
@ -423,6 +450,7 @@ Ox.$ = Ox.element = function $(value) {
}); });
return this; return this;
}, },
/*@ /*@
on <f> Binds a callback to an event on <f> Binds a callback to an event
(event, callback) -> <o> This DOM object (event, callback) -> <o> This DOM object
@ -440,6 +468,7 @@ Ox.$ = Ox.element = function $(value) {
}); });
return this; return this;
}, },
/*@ /*@
one <f> Binds a callback to an event and unbinds it on first invocation one <f> Binds a callback to an event and unbinds it on first invocation
(event, callback) -> <o> This DOM object (event, callback) -> <o> This DOM object
@ -458,6 +487,7 @@ Ox.$ = Ox.element = function $(value) {
}); });
return this; return this;
}, },
/*@ /*@
parent <f> Returns the unique list of parents of all elements parent <f> Returns the unique list of parents of all elements
() -> <[h]> Parent elements () -> <[h]> Parent elements
@ -467,6 +497,7 @@ Ox.$ = Ox.element = function $(value) {
return element.parentNode; return element.parentNode;
})))); }))));
}, },
/*@ /*@
parents <f> Returns the unique list of all ancestors of all elements parents <f> Returns the unique list of all ancestors of all elements
([selector]) -> <[h]> Ancestor elements ([selector]) -> <[h]> Ancestor elements
@ -489,6 +520,7 @@ Ox.$ = Ox.element = function $(value) {
return Ox.$(parent).is(selector); return Ox.$(parent).is(selector);
}) : parents); }) : parents);
}, },
/*@ /*@
prepend <f> Prepends one or more DOM objects to this DOM object prepend <f> Prepends one or more DOM objects to this DOM object
(object[, object[, ...]]) -> <o> DOM object (object[, object[, ...]]) -> <o> DOM object
@ -506,6 +538,7 @@ Ox.$ = Ox.element = function $(value) {
}); });
return this; return this;
}, },
/*@ /*@
prependTo <f> Prepends this DOM object to another DOM object prependTo <f> Prepends this DOM object to another DOM object
(object) -> <o> This DOM object (object) -> <o> This DOM object
@ -520,6 +553,7 @@ Ox.$ = Ox.element = function $(value) {
}); });
return this; return this;
}, },
/*@ /*@
prev <f> Returns the unique list of siblings directly before all elements prev <f> Returns the unique list of siblings directly before all elements
() -> <[h]> Siblings () -> <[h]> Siblings
@ -529,6 +563,7 @@ Ox.$ = Ox.element = function $(value) {
return element.previousSibling; return element.previousSibling;
})))); }))));
}, },
/*@ /*@
prevAll <f> Returns the unique list of siblings before all elements prevAll <f> Returns the unique list of siblings before all elements
() -> <[h]> Siblings () -> <[h]> Siblings
@ -547,12 +582,14 @@ Ox.$ = Ox.element = function $(value) {
}); });
return Ox.$(Ox.unique(siblings)); return Ox.$(Ox.unique(siblings));
}, },
/*@ /*@
reduce <f> Applies `reduce` to all elements reduce <f> Applies `reduce` to all elements
@*/ @*/
reduce: function reduce() { reduce: function reduce() {
return Array.prototype.reduce.apply(elements, arguments); return Array.prototype.reduce.apply(elements, arguments);
}, },
/*@ /*@
remove <f> Removes all element from the DOM remove <f> Removes all element from the DOM
() -> <o> This DOM object () -> <o> This DOM object
@ -566,6 +603,7 @@ Ox.$ = Ox.element = function $(value) {
}); });
return this; return this;
}, },
/*@ /*@
removeAttr <f> Removes an attribute from all elements removeAttr <f> Removes an attribute from all elements
(key) -> <o> This DOM object (key) -> <o> This DOM object
@ -581,6 +619,7 @@ Ox.$ = Ox.element = function $(value) {
}); });
return this; return this;
}, },
/*@ /*@
removeClass <f> Removes a class name from all elements removeClass <f> Removes a class name from all elements
(className) -> <o> This DOM object (className) -> <o> This DOM object
@ -597,6 +636,7 @@ Ox.$ = Ox.element = function $(value) {
}); });
return this; return this;
}, },
/*@ /*@
replace <f> Replaces another DOM object with this DOM object replace <f> Replaces another DOM object with this DOM object
(object) -> <o> This DOM object (object) -> <o> This DOM object
@ -616,6 +656,7 @@ Ox.$ = Ox.element = function $(value) {
}); });
return this; return this;
}, },
/*@ /*@
replaceWith <f> Replaces this DOM object with another DOM object replaceWith <f> Replaces this DOM object with another DOM object
(object) -> <o> This DOM object (object) -> <o> This DOM object
@ -635,6 +676,7 @@ Ox.$ = Ox.element = function $(value) {
}); });
return this; return this;
}, },
/*@ /*@
show <f> Shows all elements show <f> Shows all elements
() -> This DOM object () -> This DOM object
@ -642,6 +684,7 @@ Ox.$ = Ox.element = function $(value) {
show: function show() { show: function show() {
return this.css({display: previousDisplay || 'block'}); return this.css({display: previousDisplay || 'block'});
}, },
/*@ /*@
siblings <f> Returns all siblings of all elements siblings <f> Returns all siblings of all elements
([selector]) -> <[h]> Siblings ([selector]) -> <[h]> Siblings
@ -660,6 +703,7 @@ Ox.$ = Ox.element = function $(value) {
return Ox.$(sibling).is(selector); return Ox.$(sibling).is(selector);
}) : siblings); }) : siblings);
}, },
/*@ /*@
some <f> Tests if some elements satisfy a given condition some <f> Tests if some elements satisfy a given condition
(test) -> True if some elements pass the test (test) -> True if some elements pass the test
@ -668,6 +712,7 @@ Ox.$ = Ox.element = function $(value) {
some: function some() { some: function some() {
return Array.prototype.some.apply(elements, arguments); return Array.prototype.some.apply(elements, arguments);
}, },
/*@ /*@
text <f> Gets or sets the text contents of all elements text <f> Gets or sets the text contents of all elements
() -> <s> The text contents () -> <s> The text contents
@ -690,6 +735,7 @@ Ox.$ = Ox.element = function $(value) {
return this; return this;
} }
}, },
/*@ /*@
toggleClass <f> Toggles a class name for all elements toggleClass <f> Toggles a class name for all elements
(className) -> <o> This DOM object (className) -> <o> This DOM object
@ -704,6 +750,7 @@ Ox.$ = Ox.element = function $(value) {
}) })
return this; return this;
}, },
/*@ /*@
trigger <f> Triggers an event trigger <f> Triggers an event
(event) -> <o> This DOM object (event) -> <o> This DOM object
@ -716,6 +763,7 @@ Ox.$ = Ox.element = function $(value) {
}); });
return this; return this;
}, },
/*@ /*@
val <f> Gets the value of the first or sets the value of all elements val <f> Gets the value of the first or sets the value of all elements
() -> <s> Value () -> <s> Value
@ -733,6 +781,7 @@ Ox.$ = Ox.element = function $(value) {
return this; return this;
} }
}, },
/*@ /*@
width <f> Returns the width of the first element width <f> Returns the width of the first element
() -> <n> Width in px () -> <n> Width in px
@ -740,6 +789,7 @@ Ox.$ = Ox.element = function $(value) {
width: function width() { width: function width() {
return elements[0].offsetWidth; return elements[0].offsetWidth;
} }
}) : null; }) : null;
}; };