Module core


module core
Requires modules: core.meta

The core module.

Defined in o2.core.js

Property Summary
readonly String build

Project build number.

readonly String longName

Full name of the project.

readonly String name

Short name of the framework, to be used in prefixes, class names etc.

readonly String url

URL of the project.

readonly String version

Project version.

Function Summary
static $ (Object obj)

An alias for document.getElementById.

Usage example:

 var domRef = o2.$('elementId');
 
static load (Function callback)

An alias for Event.addEventListener(window, 'load', callback).

Usage example:

 o2.load(function() {
      initializeWidget();
 });
 
static n (String tagName, DOMNode parent)

A getElementsByName wrapper.

Usage example:

 var allTags = o2.n('username', 'testForm');
 
static nill()

An empty function.

static nn (String name, DOMNode parent)

Acts similar to {link o2.n} -- with one exception: The method returns the first matched node, instead of returning a node collection.

Usage example:

 var firstDiv = o2.nn('userprefs', 'testForm');
 
static noConflict (String newName)

Exports the o2 namespace under a new name, so that it can be used together with an older version of o2.js

Usage example:

 [script type="text/javascript" charset="UTF-8" src="o2.0.21.js"][/script]
 [script type="text/javascript" charset="UTF-8"]
     // Now "o2 v.0.21" can be accessed through o3 variable
     // (or window.o3).
     o2.noConflict('o3');

     // Alternative usage without giving explicit namespace.
     myApp.o2 = o2.noConflict();
 [/script]
 [script type="text/javascript" charset="UTF-8" src="o2.0.23.js"][/script]
 
static now()

Returns the unix time (i.e. the number of milliseconds since midnight of January 1, 1970)

Usage example:

 var unixTimestamp = o2.now();
 
static ready (Function callback)

An alias for Dom.ready.

Usage example:

 o2.ready(function() {
      initializeWidget();
 });
 
static t (String tagName, DOMNode parent)

A getElementsByTagName wrapper.

Usage example:

 var allNodes = o2.t('*')
 
static tt (String tagName, DOMNode parent)

Acts similar to {link o2.t} -- with one exception: The method returns the first matched node, instead of returning a node collection.

Usage example:

 var firstDiv = o2.tt('div', 'MasterContainer');
 

Property Details

property readonly String build

Project build number.


property readonly String longName

Full name of the project.


property readonly String name

Short name of the framework, to be used in prefixes, class names etc.


property readonly String url

URL of the project.


property readonly String version

Project version.


Function Details

function $

static $(Object obj)

An alias for document.getElementById.

Usage example:

 var domRef = o2.$('elementId');
 
Parameters:
obj - the id to check.
Returns:
document.getElementById(obj) if obj is a String; obj itself otherwise.
Throws:
Exception - if obj is undefined.

function load

static load(Function callback)

An alias for Event.addEventListener(window, 'load', callback).

Usage example:

 o2.load(function() {
      initializeWidget();
 });
 
Parameters:
callback - The callback to execute when window is loaded.

function n

static n(String tagName, DOMNode parent)

A getElementsByName wrapper.

Usage example:

 var allTags = o2.n('username', 'testForm');
 
Parameters:
tagName - the name of the form item to search.
parent - (optional defaults to document) the parent container, or the id of the parent container, to search.
Returns:
a collection of matching elements.

function nill

static nill()

An empty function.


function nn

static nn(String name, DOMNode parent)

Acts similar to {link o2.n} -- with one exception: The method returns the first matched node, instead of returning a node collection.

Usage example:

 var firstDiv = o2.nn('userprefs', 'testForm');
 
Parameters:
name - the name of the element to search.
parent - (optional defaults to document) the parent container, or the id of the parent container, to search.
Returns:
the first matched element if found; null otherwise.

function noConflict

static noConflict(String newName)

Exports the o2 namespace under a new name, so that it can be used together with an older version of o2.js

Usage example:

 [script type="text/javascript" charset="UTF-8" src="o2.0.21.js"][/script]
 [script type="text/javascript" charset="UTF-8"]
     // Now "o2 v.0.21" can be accessed through o3 variable
     // (or window.o3).
     o2.noConflict('o3');

     // Alternative usage without giving explicit namespace.
     myApp.o2 = o2.noConflict();
 [/script]
 [script type="text/javascript" charset="UTF-8" src="o2.0.23.js"][/script]
 
Parameters:
newName - (Optional; a random unique namespace will be created if not given) the name of the new namespace.
Returns:
the new Object.

function now

static now()

Returns the unix time (i.e. the number of milliseconds since midnight of January 1, 1970)

Usage example:

 var unixTimestamp = o2.now();
 
Returns:
the current unix time.

function ready

static ready(Function callback)

An alias for Dom.ready.

Usage example:

 o2.ready(function() {
      initializeWidget();
 });
 
Parameters:
callback - The callback to execute when DOM is ready.

function t

static t(String tagName, DOMNode parent)

A getElementsByTagName wrapper.

Usage example:

 var allNodes = o2.t('*')
 
Parameters:
tagName - the name of the tag to search.
parent - (optional defaults to document) the parent container, or the id of the parent container, to search.
Returns:
a collection of matching elements.

function tt

static tt(String tagName, DOMNode parent)

Acts similar to {link o2.t} -- with one exception: The method returns the first matched node, instead of returning a node collection.

Usage example:

 var firstDiv = o2.tt('div', 'MasterContainer');
 
Parameters:
tagName - the name of the tag to search.
parent - (optional defaults to document) the parent container, or the id of the parent container, to search.
Returns:
the first matched element if found; null otherwise.