M
Matt Kruse
I have released version 1.0 of my "Utils" package:
http://www.javascripttoolbox.com/lib/util/
It contains many useful functions which can be used to build more advanced
functionality.
Many of these functions already exist in some form (indeed, most experiences
javascript programmers will probably have their own versions of most of
these) but hopefully it will help out some who have not built up their own
repository of util functions yet.
Suggestions and code critiques are welcome from experienced developers who
are actually trying to help
This is a list of functions provided:
Global Functions
isArray (object) : boolean
isObject (object) : boolean
defined (val) : boolean
map (function, object*) : Array
setDefaultValues (objectToChange, objectDefaultValues) : Object
DOM Methods
DOM.getParentByTagName (HTMLElement, stringTagName) : HTMLElement
DOM.removeNode (HTMLElement) : boolean
DOM.getOuterWidth (HTMLElement) : int
DOM.getOuterHeight (HTMLElement) : int
DOM.resolve (*) : *
CSS Methods
CSS.rgb2hex (stringRGB) : string
CSS.hyphen2camel (stringProperty) : string
CSS.hasClass ([string|HTMLElement], stringClassName) : boolean
CSS.addClass (HTMLElement, stringClassName) : boolean
CSS.removeClass (HTMLElement, stringClassName) : boolean
CSS.replaceClass (HTMLElement, stringOldClassName, stringNewClassName) :
boolean
CSS.getStyle (HTMLElement, property-name) : string ( alias: CSS.get() )
CSS.setStyle (HTMLElement, property-name, value) : boolean ( alias:
CSS.set() )
CSS.createId ([HTMLElement]) : string
Event Methods
Event.resolve (EventObject) : EventObject
Event.add (HTMLElement, stringEventType, function, booleanCapture) : boolean
Event.getMouseX (EventObject) : int
Event.getMouseY (EventObject) : int
Event.cancelBubble (EventObject) ( alias: Event.stopPropagation() )
Screen Methods
Screen.getBody() : HTMLBodyElement
Screen.getScrollTop() : int
Screen.getScrollLeft() : int
Screen.getDocumentWidth() : int
Screen.getDocumentHeight() : int
Screen.getViewportWidth() : int
Screen.getViewportHeight() : int
Sort Methods
Sort.AlphaNumeric
Sort.Numeric
Sort.IgnoreCase
Sort.Currency
Sort.Date
http://www.javascripttoolbox.com/lib/util/
It contains many useful functions which can be used to build more advanced
functionality.
Many of these functions already exist in some form (indeed, most experiences
javascript programmers will probably have their own versions of most of
these) but hopefully it will help out some who have not built up their own
repository of util functions yet.
Suggestions and code critiques are welcome from experienced developers who
are actually trying to help
This is a list of functions provided:
Global Functions
isArray (object) : boolean
isObject (object) : boolean
defined (val) : boolean
map (function, object*) : Array
setDefaultValues (objectToChange, objectDefaultValues) : Object
DOM Methods
DOM.getParentByTagName (HTMLElement, stringTagName) : HTMLElement
DOM.removeNode (HTMLElement) : boolean
DOM.getOuterWidth (HTMLElement) : int
DOM.getOuterHeight (HTMLElement) : int
DOM.resolve (*) : *
CSS Methods
CSS.rgb2hex (stringRGB) : string
CSS.hyphen2camel (stringProperty) : string
CSS.hasClass ([string|HTMLElement], stringClassName) : boolean
CSS.addClass (HTMLElement, stringClassName) : boolean
CSS.removeClass (HTMLElement, stringClassName) : boolean
CSS.replaceClass (HTMLElement, stringOldClassName, stringNewClassName) :
boolean
CSS.getStyle (HTMLElement, property-name) : string ( alias: CSS.get() )
CSS.setStyle (HTMLElement, property-name, value) : boolean ( alias:
CSS.set() )
CSS.createId ([HTMLElement]) : string
Event Methods
Event.resolve (EventObject) : EventObject
Event.add (HTMLElement, stringEventType, function, booleanCapture) : boolean
Event.getMouseX (EventObject) : int
Event.getMouseY (EventObject) : int
Event.cancelBubble (EventObject) ( alias: Event.stopPropagation() )
Screen Methods
Screen.getBody() : HTMLBodyElement
Screen.getScrollTop() : int
Screen.getScrollLeft() : int
Screen.getDocumentWidth() : int
Screen.getDocumentHeight() : int
Screen.getViewportWidth() : int
Screen.getViewportHeight() : int
Sort Methods
Sort.AlphaNumeric
Sort.Numeric
Sort.IgnoreCase
Sort.Currency
Sort.Date