Namespace o2


namespace o2
Root namespace – magic goes here ;)

Class Summary

A static class for making AJAX GET and POST requests.

A class to modify collections.

A cookie helper class.

A date/time utilities class.

A static object for debugging purposes.

Usage example:

 // note: initalize Debugger only once,
 // possibly on window.load or dom content ready
 o2.Debugger.init(someDomNode, true);

 //then inside your code use this syntax.
 o2.Debugger.println('stuff to debug');
 
A cross-browser DOM manipulation helper.

A cross-browser event handling and event utilities class.

An object to make JSONP calls.

A method helper class.

A helper class for JavaScript Object inheritance.

Used for parsing the browser's query string.

Custom delegates for Array.sort method.

A String helper class.

Checks support for various objects and properties like DOM and cookies.

A really fast template engine.

A class for executing repeated timed actions.

Usage example:

 // A unique id for the timer.
 var kCheckId = 'my_timer';

 // Auto start timer with id kCheckId to repeat doStuff approximately
 // every 500 milliseconds, please note that this is an approximation.
 // for further details see John Resig's excellent article on this:
 // http://ejohn.org/blog/how-javascript-timers-work/
 o2.Timer.set(kCheckId, doStuff, 500, {start: true, repeat: true});

 // Stops the timer (i.e. doStuff will not be executed further).
 o2.Timer.stop(kCheckId);

 // Restarts the timer (i.e. doStuff will be periodically executed again).
 o2.Timer.start(kCheckId);
 

Used for consequentially executing a set of Functions.

The functions are guaranteed to be called.

Even if an error occurs when calling a Function, the next Function will be tried, disregarding the error.

A "unit test" runner.

Runs UnitTests.

A simple class for validating various kinds of objects.

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.