class SAPO
Defined in 0.1/lib.js

Nested Class Summary
requires SAPO SAPO Widget class : all widgets should be subclasses of this one

Function Summary
Function Class (string class, baseClass, properties)
- This function returns a new Class (function) which will create object instances with the given properties as prototype, supporting hierarchy, using baseClass ad the base class. If properties has a property named abstract which evaluates to true, then the class cannot be instantiated directly, like an abstract class.
Function bindObj (Object obj, [Array args])
Extends the native Function object. Creates a delegate (callback) that sets the scope to obj. Call directly on any function.
Example: this.myFunction.bindObj(this)
Will create a function that is automatically scoped to this.
Function bindObjEvent (Object event, Object obj, [Array args])
Extends the native Function object. Creates a delegate (callback) that sets the scope to obj. Call directly on any function.
Example: this.myFunction.bindObjEvent(this)
Will create a function that is automatically scoped to this.
Object extendObj (Object destination, Object source)
Extends a given Object with a given set of properties
Object namespace (string ns)
Creates the SAPO namespace
DOMElement|Array s$ (string|Array element)
Shortcut for document.getElementById
safeCall (Object object, String|Function listener)
Safely calls a callback function. Verifies that the callback is well defined and traps errors.
Object verify (string ns, string minVersion)
verifies that a dependency has been loaded. Throws exception if not

Function Details

function Class

Function Class(string class, baseClass, properties)
- This function returns a new Class (function) which will create object instances with the given properties as prototype, supporting hierarchy, using baseClass ad the base class. If properties has a property named abstract which evaluates to true, then the class cannot be instantiated directly, like an abstract class.
Parameters:
class name, useful just for debugging.
baseClass prototype, super class.
properties methods and properties of the new class.

function bindObj

Function bindObj(Object obj, [Array args])
Extends the native Function object. Creates a delegate (callback) that sets the scope to obj. Call directly on any function.
Example: this.myFunction.bindObj(this)
Will create a function that is automatically scoped to this.
Parameters:
obj The object for which the scope is set
[args] Overrides arguments for the call. (Defaults to the arguments passed by the caller)
Returns:
The new function

function bindObjEvent

Function bindObjEvent(Object event, Object obj, [Array args])
Extends the native Function object. Creates a delegate (callback) that sets the scope to obj. Call directly on any function.
Example: this.myFunction.bindObjEvent(this)
Will create a function that is automatically scoped to this.
Parameters:
event The default event
obj The object for which the scope is set
[args] Overrides arguments for the call. (Defaults to the arguments passed by the caller)
Returns:
The new function

function extendObj

Object extendObj(Object destination, Object source)
Extends a given Object with a given set of properties
Parameters:
destination - The original objecty
source - The new properties
Returns:
The extended object

function namespace

Object namespace(string ns)
Creates the SAPO namespace
Parameters:
ns - namespace path
Returns:
Object with SAPO namespace

function s$

DOMElement|Array s$(string|Array element)
Shortcut for document.getElementById
Parameters:
element - Receives either an id or an Array of id's
Returns:
Either the DOM element for the given id or an array of elements for the given ids

function safeCall

safeCall(Object object, String|Function listener)
Safely calls a callback function. Verifies that the callback is well defined and traps errors.
Parameters:
object to be used as this. If null, the global object is used. If function, then it's called with window as this.
listener member function to be called. If string, then member is looked up.

function verify

Object verify(string ns, string minVersion)
verifies that a dependency has been loaded. Throws exception if not
Parameters:
ns - namespace path
minVersion - minimum version, optional
Returns:
Object with SAPO namespace