Some useful javascript functions and stuff, cobbled together from various sources.
- Testing/Demo Fiddle (also included in
/examples
) - Another testing demo or here
- Logging: Safe
console.log
wrapper with debugmode toggling. Inspired by Paul Irish. - Inheritance: Object-oriented "macros" for class definition (
Define
) and inheritance (Inherits
). Inspired by this and that - Templating: simple Moustache-style template helper.
- jQuery Plugins:
- $each: "fixes"
.each
so thatthis
(and param) are jQuery, not DOM elements - createNestedDom: utility to construct multi-level DOM items for testing (particularly for selector performance tests)
- getSelector: builds list of DOM elements in inheritance chain; includes tag, id, class
- getTextSize: calculate width or height of the text within one or more elements -- specifically useful for calculating when to increase the dimensions of an input box during typing
- hasTriggers: make it so one button can trigger behaviors on multiple targets -- specifically useful for having a 'show/hide all' button to activate a bunch of bootstrap toggles
- listEvents: get all bound events (jQ 1.8+)
- triggerAny: filter namespaced triggers, like
.custom1
to fireclick.custom1
andchange.custom1
- $each: "fixes"
As-you-wish.