-
Notifications
You must be signed in to change notification settings - Fork 88
Util
Wiki ▸ API Reference ▸ Util
Simple utility methods and helpers. Some jQuery-ish replacements.
# wb.area(elem)
Returns the area of an element.
- elem:
===
# wb.closest(elem, selector)
Find nearest parent, or self, which matches selector, because this is one thing I really missed from jQuery.
- elem:
- selector:
===
# wb.containedBy(target, container)
Returns whether the rect of target is at least 90% contained by the rect of container.
- target:
- container:
===
# wb.dist(x1, y1, x2, y2)
Distance between two points using Pythagorean theorem.
- x1:
- y1:
- x2:
- y2:
===
# wb.elem(name, attributes, children)
Utility for dynamically creating DOM elements and structures.
- name:
- attributes:
- children:
===
# wb.find(elem, selector)
Return the first decendant that matches selector.
- elem:
- selector:
===
# wb.findAll(elem, selector)
Returns a (true) array of all decendants that match selector.
- elem:
- selector:
===
# wb.findChild(elem, selector)
Find the first child which matches selector.
- elem:
- selector:
===
# wb.findChildren(elem, selector)
Find direct children which match selector as an array.
- elem:
- selector:
===
# wb.hide()
Hides an element.
===
# wb.indexOf(elem)
What is the index of this element in a list of its parents children?
- elem:
===
# wb.jsonp(url, callback)
Minimal support for jsonp, should probably be replaced by a better library ## Note: global variable wb is initialized in the HTML before any javascript files are loaded (in template/template.html)
- url:
- callback:
===
# wb.makeArray(arrayLike)
Turns an array-like into a true array.
- arrayLike:
===
# wb.matches(elem, selector)
Does elem match selector?
- elem:
- selector:
===
# wb.overlap(elem1, elem2)
Returns the area of overlap between two elements.
- elem1:
- elem2:
===
# wb.overlapRect(r1, r2)
The area of overlap between two rects.
- r1:
- r2:
===
# wb.reposition(elem, pos)
Moves an absolutely positioned element.
- elem:
- pos:
===
# wb.show()
Shows a hidden element.
===
# wb.rect(elem)
Utility for calling elem.getBoundingClientRect()
.
- elem:
===
# wb.resize(elem)
Resizes a text input based on the length of its content.
- elem: