dLite documentation

There are 9 power functions in dLite, and their functionality and parameters are presented here. The idea is that each function has a semantic and self-explanatory name, so any developer looking at the code will understand what it will do.

The names are deliberately close to the native DOM methods, to make it easier to adapt to, but at the same time guaranteed to avoid name collision. Which parameters and what format they are expected to be in are described below.

elm(id)

Finds an element with the sent-in id.

Example

var container = elm("container");

Parameters

elmsByClass(className, tag, elm)

Finds an element with the sent-in className, tag and elm. Parameter tag is the desired tag name as a string, parameter elm is a DOM element set as the context to look in.

Example

var externalLinks = elmsByClass("external", a);

Parameters

DOMReady(function/functionReference)

Takes one or several function/functionReference parameters, which will be called as soon as the DOM has loaded.

Example

DOMReady(runAtDOMLoad);

Parameters

addClass(elm, className)

Adds a CSS class to an element. Parameter elm is a DOM element reference, parameter className is a string.

Example

addClass(elm("container"), "active");

Parameters

removeClass(elm, className)

Removes a CSS class from an element. Parameter elm is a DOM element reference, parameter className is a string

Example

removeClass(elm("container"), "active");

Parameters

addEvent(elm, evt, func)

Adds an event to an element. Parameter elm is a DOM element reference, parameter evt is a string, parameter func is a function or a function reference.

Example

addEvent(elm("container"), "click", handleClick);

Parameters

removeEvent(elm, evt, func)

Removes an event from an element. Parameter elm is a DOM element reference, parameter evt is a string, parameter func is a function or a function reference.

Example

removeEvent(elm("container"), "click", handleClick);

Parameters

stopDefault(evt)

Stops the default behavior of an event. Parameter evt is an event object.

Example

stopDefault(evt);

Parameters

cancelBubbling(evt)

Cancels the bubbling of an event.. Parameter evt is an event object.

Example

cancelBubbling(evt);

Parameters