namespace SAPO.Ink.Aux
Authors:
jose.p.dias AT co.sapo.pt
andre.paez AT telecom.pt Auxiliary functions for Ink.
Version:
0.1
Since:
November 2012

Property Summary
supported ink layouts

Function Summary
ajaxJSON (String endpoint, Object params, Function cb)
for convenience, this methods does an AJAX request and offers a cb(err, jsonData) interface for easy async handling
Number childIndex (DOMElement childEl)
returns the nth position the given element occupies relatively to its parent
cleanChildren (DOMElement el)
IE8 doesn't like table.innerHTML = ''
Object clone (Object o)
returns a deep copy of an object. it can't have loops
returns the current ink layout being applied
not to be invoked from Aux. Components should copy this method as its destroy method.
DOMElement elOrSelector (DOMElement|String elOrSelector, String fieldName)
applies the Sizzle selector/document.querySelectorAll if string, just returns element otherwise
Object|Object[] getInstance (String|DOMElement instanceIdOrElement)
returns an instance or several instances (if more than 1 instance is associated with the element)
auxiliary method - returns registered instance from a CSS selector rule
returns all registered instance ids
Object[] getInstances()
returns all regitered instances
hashSet (Object o)
non-destructive set of hash parameters
Boolean isDOMElement (any o)
returns true iif o is a DOM Element
Boolean isInteger (any n)
returns true iif n is an integer number
registerInstance (Object inst, DOMElement el, [String optionalPrefix])
saves component instance reference for later retrieval
restoreIdAndClasses (DOMElement toEl, Object inObj)
recovers id and classes to toEl from private attributes of inObj if present.
storeIdAndClasses (DOMElement fromEl, Object inObj)
saves id and classes on fromEl as private attributes of inObj if present.
unregisters a component - useful only for volatile stuff such as modals

Property Details

property Layouts

supported ink layouts

Function Details

function ajaxJSON

ajaxJSON(String endpoint, Object params, Function cb)
for convenience, this methods does an AJAX request and offers a cb(err, jsonData) interface for easy async handling
Parameters:
endpoint the endpoint URI
params hash of param names -> values to pass
cb function(err, data). null is passed on err if no err occurred.

function childIndex

Number childIndex(DOMElement childEl)
returns the nth position the given element occupies relatively to its parent
Parameters:
childEl

function cleanChildren

cleanChildren(DOMElement el)
IE8 doesn't like table.innerHTML = ''
Parameters:
el

function clone

Object clone(Object o)
returns a deep copy of an object. it can't have loops
Parameters:
o

function currentLayout

String currentLayout()
returns the current ink layout being applied

function destroyComponent

destroyComponent()
not to be invoked from Aux. Components should copy this method as its destroy method.

function elOrSelector

DOMElement elOrSelector(DOMElement|String elOrSelector, String fieldName)
applies the Sizzle selector/document.querySelectorAll if string, just returns element otherwise
Parameters:
elOrSelector accepts a DOMElement or a CSS selector string
fieldName the name the field occupies on the

function getInstance

Object|Object[] getInstance(String|DOMElement instanceIdOrElement)
returns an instance or several instances (if more than 1 instance is associated with the element)
Parameters:
instanceIdOrElement

function getInstanceFromSelector

getInstanceFromSelector(String selector)
auxiliary method - returns registered instance from a CSS selector rule
Parameters:
selector

function getInstanceIds

String[] getInstanceIds()
returns all registered instance ids

function getInstances

Object[] getInstances()
returns all regitered instances

function hashSet

hashSet(Object o)
non-destructive set of hash parameters
Parameters:
o object to index parameters and values to change on the hash. if other parameters were there, they are kept the same.

function isDOMElement

Boolean isDOMElement(any o)
returns true iif o is a DOM Element
Parameters:
o

function isInteger

Boolean isInteger(any n)
returns true iif n is an integer number
Parameters:
n

function registerInstance

registerInstance(Object inst, DOMElement el, [String optionalPrefix])
saves component instance reference for later retrieval
Parameters:
inst JS object instance
el DOM Element to associate with the JS object
[optionalPrefix] defaults to 'instance'

function restoreIdAndClasses

restoreIdAndClasses(DOMElement toEl, Object inObj)
recovers id and classes to toEl from private attributes of inObj if present.
Parameters:
toEl
inObj

function storeIdAndClasses

storeIdAndClasses(DOMElement fromEl, Object inObj)
saves id and classes on fromEl as private attributes of inObj if present.
Parameters:
fromEl
inObj

function unregisterInstance

unregisterInstance(String id)
unregisters a component - useful only for volatile stuff such as modals
Parameters:
id