/MyJsUtilities

Useful utility functions and such, cobbled together from various sources.

Primary LanguageJavaScript

MyJsUtilities

Some useful javascript functions and stuff, cobbled together from various sources.

Contents

  • 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 that this (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 fire click.custom1 and change.custom1

License

As-you-wish.