$

Method

Queries the DOM using CSS selectors and returns an Element or Array of Elements

@param {String} arg Comma delimited string of target #id, .class, tag or selector
@param {Boolean} nodelist [Optional] True will return a NodeList (by reference) for tags & classes
@return {Mixed} Element or Array of Elements

ID: $("#id");
CSS class: $(".class");
Selector: $(selector);
Selector By Reference: $(selector, true);

alias

Method

Aliases origin onto obj

@param {Object} obj Object receiving aliasing
@param {Object} origin Object providing structure to obj
@return {Object} Object receiving aliasing

abaaso.alias($, abaaso);

allow

Method

Quick way to see if a URI allows a specific command

@param uri {String} URI
@param command {String} Command to query for
@returns {Boolean} True if the command is available

if ("uri".allow("delete")) { ... }

array

Class

Array methods

array.cast

Method

Returns an Object (NodeList, etc.) as an Array

@param {Object} obj Object to cast
@param {Boolean} key [Optional] Returns key or value, only applies to Objects without a length property
@return {Array} Object as an Array

var keys = $.array.cast(obj, true);

array.contains

Method

Finds the index of arg(s) in instance

@param {Array} obj Array to search
@param {String} arg Comma delimited string of search values
@return {Mixed} Integer or an array of integers representing the location of the arg(s)

var indexes = abaaso.array.contains(haystack, "needle1, needle2, needle3");

or

var indexes = haystack.contains("needle1, needle2, needle3");

array.diff

Method

Finds the difference between array1 and array2

@param {Array} array1 Source Array
@param {Array} array2 Comparison Array
@return {Array} Array of the differences

var difference = abaaso.array.diff(array1, array2);

or

var difference = array1.diff(array2);

array.first

Method

Returns the first Array node

@param instance {array} The array
@returns {mixed} The first node of the array

var obj = array.first();

array.index

Method

Finds the index of arg in instance. Use contains() for multiple arguments

@param {Array} obj Array to search
@param {Mixed} arg Value to find index of
@return {Integer} The position of arg in instance

var index = abaaso.array.index(haystack, "needle1");

or

var index = haystack.index("needle1");

array.indexed

Method

Returns an Associative Array as an Indexed Array

@param {Array} obj Array to index
@return {Array} Indexed Array

var indexed = abaaso.array.indexed(obj);

or

var indexed = obj.indexed();

array.intersect

Method

Finds the intersections between array1 and array2

@param {Array} array1 Source Array
@param {Array} array2 Comparison Array
@return {Array} Array of the intersections

array.keys

Method

Returns the keys in the array

@param {Array} obj Array to extract keys from
@return {Array} Array of the keys

var keys = abaaso.array.keys(array1);

or

var keys = array1.keys();

array.last

Method

Returns the last node of the array

@param {Array} obj Array
@return {Mixed} Last node of Array

var obj = array.last();

array.remove

Method

Removes indexes from an Array without recreating it

@param {Array} obj Array to remove from
@param {Integer} start Starting index
@param {Integer} end [Optional] Ending index
@return {Array} Modified Array

$.array.remove(haystack, 1, 2);

or

haystack.remove(1, 2);

array.total

Method

Gets the total keys in an Array

@param {Array} obj Array to find the length of
@return {Integer} Number of keys in Array

var total = array.total();

cache

Class

[Private] Cache for RESTful behavior

cache.get

Method

[Private] Returns the cached object {headers, response} of the URI or false

@param uri {string} The URI/Identifier for the resource to retrieve from cache
@param expire {boolean} [Optional] If 'false' the URI will not expire
@returns {mixed} Returns the URI object {headers, response} or false

var obj = cache.get("uri");

cache.items

Property

[Private] Associative array of URIs with the HTTP Response and Headers as {header:, response}

cache.set

Method

[Private] Sets, or updates an item in cache.items

@param uri {string} The URI to set or update
@param property {string} The property of the cached URI to set
@param value {mixed} The value to set

cache.set("uri", "response", "XHR response value");

clear

Method

Clears an object's innerHTML, or resets it's state

Events:
beforeClear - Fires before the Object is cleared
afterClear - Fires after the Object is cleared

@param {Mixed} obj Element or Array of Elements or $ queries
@return {Mixed} Element or Array of Elements

abaaso.clear("#id");

or

$("#id").clear();

client

Class

Client properties and methods

client.allow

Method

Quick way to see if a URI allows a specific command, to be used with URIs that are cached locally
Use $.options() to discover permissions

@param uri {String} URI
@param command {String} Command to query for
@returns {Boolean} True if the command is available

$.client.allow("uri", "get") ? $.client.get("uri") : void(0);

or

$.allow("uri", "get") ? $.get("uri") : void(0);

or

"uri".allow("get") ? $.get("uri") : void(0);

client.android

Property

Boolean indicating if the client is an Android device

($.client.android) ? alert("it's an android!") : void(0);

client.blackberry

Property

Boolean indicating if the client is a Blackberry device

($.client.blackberry) ? alert("it's a blackberry!") : void(0);

client.chrome

Property

Boolean indicating if the client is Google Chrome

(abaaso.client.chrome) ? alert("Client is Chrome!") : void(0);

client.css3

Property

Boolean indicating if the client supports CSS3+

(abaaso.client.css3) ? alert("CSS3 supported!") : void(0);

client.del

Method

Creates an XmlHttpRequest DELETE request to a URI

REST security is applied to requests, if a verb is not in the Allow header it will be blocked by abaaso

Events:
beforeXHR - Fires before the XmlHttpRequest is made
beforeDelete - Fires before the XmlHttpRequest is made
afterDelete - Fires after the XmlHttpRequest response is received
afterXHR - Fires after the XmlHttpRequest response is received
failedDelete - Fires on error
receivedDelete - Fires on XHR readystate 2, clears the timeout only!
timeoutDelete - Fires 30s after XmlHttpRequest is made

@param {String} uri URI to query
@param {Function} success A handler function to execute when an appropriate response been received
@param {Function} failure [Optional] A handler function to execute on error
@return {String} URI to query

$.client.del("uri", successFn, failureFn);

client.firefox

Property

Boolean indicating if the client is Mozilla Firefox

(abaaso.client.firefox) ? alert("Client is FireFox!") : void(0);

client.get

Method

Creates an XmlHttpRequest GET request to a URI

Responses are automatically cast to their respective Objects, e.g. JSON will become an Object or Array, XML will become an XMLDOM Object

REST security is applied to requests, if a verb is not in the Allow header it will be blocked by abaaso

Events:
beforeXHR - Fires before the XmlHttpRequest is made
beforeGet - Fires before the XmlHttpRequest is made
afterGet - Fires after the XmlHttpRequest response is received
afterXHR - Fires after the XmlHttpRequest response is received
failedGet - Fires on error
receivedGet - Fires on XHR readystate 2, clears the timeout only!
timeoutGet - Fires 30s after XmlHttpRequest is made

@param {String} uri URI to query
@param {Function} success A handler function to execute when an appropriate response been received
@param {Function} failure [Optional] A handler function to execute on error
@param {Mixed} args [Optional] Custom headers
@return {String} URI to query

$.client.get("uri", successFn, failureFn);

or

$("#id").get("uri");

client.headers

Method

Creates an XmlHttpRequest OPTIONS request to a URI

REST security is applied to requests, if a verb is not in the Allow header it will be blocked by abaaso

Events:
beforeXHR - Fires before the XmlHttpRequest is made
beforeOptions - Fires before the XmlHttpRequest is made
afterOptions - Fires after the XmlHttpRequest response is received
afterXHR - Fires after the XmlHttpRequest response is received
failedOptions - Fires on error
receivedOptions - Fires on XHR readystate 2, clears the timeout only!
timeoutOptions - Fires 30s after XmlHttpRequest is made

@param {String} uri URI to query
@param {Function} success A handler function to execute when an appropriate response been received
@param {Function} failure [Optional] A handler function to execute on error
@param {Mixed} args [Optional] Custom headers
@return {String} URI to query

$.client.options("uri", successFn, failureFn);

or

$.options("uri", successFn, failureFn);

or

"uri".options(successFn, failureFn);

client.ie

Property

Boolean indicating if the client is Microsoft Internet Explorer

(abaaso.client.ie) ? alert("Client is Internet Explorer!") : void(0);

client.ios

Property

Boolean indicating if the client is an iOS device

($.client.ios) ? alert("it's an ios!") : void(0);

client.jsonp

Method

Creates a JSONP request if CORS is not supported, otherwise a GET request is made

Events:
beforeJSONP - Fires before the SCRIPT is made
afterJSONP - Fires after the SCRIPT is received
failedJSONP - Fires on error
timeoutJSONP - Fires 30s after SCRIPT is made

@param {String} uri URI to request
@param {Function} success A handler function to execute when an appropriate response been received
@param {Function} failure [Optional] A handler function to execute on error
@param {Mixed} args Custom JSONP handler parameter name, default is "callback"; or custom headers for GET request (CORS)
@return {String} URI to query

abaaso.client.jsonp(uri, handler);

client.linux

Property

Boolean indicating if the client is a Linux device

($.client.linux) ? alert("it's running linux!") : void(0);

client.meego

Property

Boolean indicating if the client is a MeeGo device

($.client.meego) ? alert("it's running meego!") : void(0);

client.mobile

Property

Boolean indicating if the client is a mobile device (smartphone, etc.)

($.client.mobile) ? alert("it's a mobile!") : void(0);

client.ms

Property

Number of milliseconds to cache URI responses if the cache Headers are not present

client.ms = 3600;

client.opera

Property

Boolean indicating if the client is Opera

(abaaso.client.opera) ? alert("Client is Opera!") : void(0);

client.osx

Property

Boolean indicating if the client is an Apple OSX device

($.client.osx) ? alert("it's running osx!") : void(0);

client.permission

Method

Returns the permission of the cached URI

@param {String} uri URI to query
@return {Object} Contains an Array of available commands, the permission bit and a map

$.client.permission("uri");

or

$.permission("uri");

or

"uri".permission();

client.playbook

Property

Boolean indicating if the client is a Playbook tablet

($.client.playbook) ? alert("it's a playbook!") : void(0);

client.post

Method

Creates an XmlHttpRequest POST request to a URI

Responses are automatically cast to their respective Objects, e.g. JSON will become an Object or Array, XML will become an XMLDOM Object

REST security is applied to requests, if a verb is not in the Allow header it will be blocked by abaaso

Events:
beforeXHR - Fires before the XmlHttpRequest is made
beforePost - Fires before the XmlHttpRequest is made
afterPost - Fires after the XmlHttpRequest response is received
afterXHR - Fires after the XmlHttpRequest response is received
failedPost - Fires on error
receivedPost - Fires on XHR readystate 2, clears the timeout only!
timeoutPost - Fires 30s after XmlHttpRequest is made

@param {String} uri URI to query
@param {Function} success A handler function to execute when an appropriate response been received
@param {Function} failure [Optional] A handler function to execute on error
@param {Mixed} args Data to send with the request
@return {String} URI to query

$.client.post("uri", successFn, failureFn, {...});

client.put

Method

Creates an XmlHttpRequest PUT request to a URI

Responses are automatically cast to their respective Objects, e.g. JSON will become an Object or Array, XML will become an XMLDOM Object

REST security is applied to requests, if a verb is not in the Allow header it will be blocked by abaaso

Events:
beforeXHR - Fires before the XmlHttpRequest is made
beforePut - Fires before the XmlHttpRequest is made
afterPut - Fires after the XmlHttpRequest response is received
afterXHR - Fires after the XmlHttpRequest response is received
failedPut - Fires on error
receivedPut - Fires on XHR readystate 2, clears the timeout only!
timeoutPut - Fires 30s after XmlHttpRequest is made

@param {String} uri URI to query
@param {Function} success A handler function to execute when an appropriate response been received
@param {Function} failure [Optional] A handler function to execute on error
@param {Mixed} args Data to send with the request
@return {String} URI to query

$.client.put("uri", successFn, failureFn, {...});

client.request

Method

[Private] Creates an XmlHttpRequest to a URI

afterXhr - Fires after the response is received

@param uri {string} The resource to interact with
@param fn {function} A handler function to execute when an appropriate response been received
@param type {string} The type of request
@param args {mixed} Data to send with the request

client.response

Method

[Private] Receives and caches the URI response

Headers are cached, if an expiration is set it will be used to control the local cache
If abaaso.state.header is set, a state change is possible

Events:
beforeXhr - Fires before the request is made

@param xhr {object} XMLHttpRequest object
@param uri {string} The URI.value to cache
@param fn {function} A handler function to execute once a response has been received

client.safari

Property

Boolean indicating if the client is Apple Safari

(abaaso.client.safari) ? alert("Client is Safari!") : void(0);

client.size

Method

Returns the visible area of the View

@return {Object} Describes the View {x: ?, y: ?}

var size = abaaso.client.size;

client.tablet

Property

Boolean indicating if the client is a tablet device

($.client.tablet) ? alert("it's a tablet!") : void(0);

client.version

Property

Client version (integer)

((abaaso.client.ie) && (abaaso.client.version >= 8)) ? alert("Getting better") : void(0);

client.webos

Property

Boolean indicating if the client is a WebOS device

($.client.webos) ? alert("it's a webos!") : void(0);

client.windows

Property

Boolean indicating if the client is a Microsoft Windows device

($.client.windows) ? alert("it's running windows!") : void(0);

clone

Method

Clones an Object

@param {Object} obj Object to clone
@return {Object} Clone of obj

var objClone = abaaso.clone(obj);

cookie

Class

Cookie methods

cookie.expire

Method

Expires a cookie if it exists

@param {String} name Name of the cookie to expire
@return {String} Name of the expired cookie

abaaso.cookie.expire("name");

cookie.get

Method

Gets a cookie

@param {String} name Name of the cookie to get
@return {Mixed} Cookie or undefined

var cookie = abaaso.cookie.get("name");

cookie.list

Method

Gets the cookies for the domain

@return {Object} Collection of cookies

var cookies = abaaso.cookie.list();

cookie.set

Method

Creates a cookie

The offset specifies a positive or negative span of time as day, hour, minute or second

@param {String} name Name of the cookie to create
@param {String} value Value to set
@param {String} offset A positive or negative integer followed by "d", "h", "m" or "s"
@return {Object} The new cookie

abaaso.cookie.create("name", "content", "30m");

create

Method

Creates an Element in document.body or a target Element

An id is generated if not specified with args

Events:
beforeCreate - Fires after the Element has been created, but not set
afterCreate - Fires after the Element has been appended to it's parent

@param {String} type Type of Element to create
@param {Object} args [Optional] Collection of properties to apply to the new element
@param {Mixed} target [Optional] Target object or element.id value to append to
@return {Object} Element that was created or undefined

abaaso.create("div", {innerHTML:"Hello world!"});

css

Method

Creates a CSS stylesheet in the View

@param {String} content CSS to put in a style tag
@return {Object} Element created or undefined

abaaso.css("CSS text");

data

Class

Template data store, use $.store(obj), abaaso.store(obj) or abaaso.data.register(obj) to create one on an Object

RESTful behavior is supported, by setting the 'key' & 'uri' properties (in that order)

*** Do not use this directly! ***

abaaso.data.register(obj);

OR

abaaso.store(obj);

data.batch

Method

Batch sets or deletes data in the store

Events:
beforeDataBatch - Fires before the batch is queued
afterDataBatch - Fires after the batch is queued

@param {String} type Type of action to perform
@param {Mixed} data Array of keys or indexes to delete, or Object containing multiple records to set
@param {Boolean} sync [Optional] True if called by data.sync
@return {Object} Data store

data.clear

Method

Clears the data object, unsets the uri property

Events:
beforeDataClear - Fires before the data is cleared
afterDataClear Fires after the data is cleared

@return {Object} Data store

data.del

Method

Deletes a record based on key or index

Events:
beforeDataDelete - Fires before the record is deleted
afterDataDelete - Fires after the record is deleted
syncDataDelete - Fires when the local store is updated
failedDataDelete - Fires if the store is RESTful and the action is denied

@param {Mixed} record Record key or index
@param {Boolean} reindex Default is true, will re-index the data object after deletion
@param {Boolean} sync [Optional] True if called by data.sync
@return {Object} Data store

data.find

Method

Finds needle in the haystack

Events:
beforeDataFind - Fires before the search begins
afterDataFind - Fires after the search has finished

@param {Mixed} needle String, Number or Pattern to test for
@param {Mixed} haystack [Optional] The field(s) to search
@return {Array} Array of results

data.get

Method

Retrieves a record based on key or index

If the key is an integer, cast to a string before sending as an argument!

Events:
beforeDataGet - Fires before getting the record
afterDataGet - Fires after getting the record

@param {Mixed} record Key, index or Array of pagination start & end
@return {Mixed} Individual record, or Array of records

data.key

Property

Identifies the key in a POST response

data.keys

Property

Object with record keys as properties, and indexes as values

data.records

Property

Array of records as Objects with key and data properties

data.register

Method

Registers a data store on an Object

Events:
beforeDataStore - Fires before registering the data store
afterDataStore - Fires after registering the data store

@param {Object} obj Object to register with
@param {Mixed} data [Optional] Data to set with this.batch
@return {Object} Object registered with

abaaso.data.register(obj);

or

abaaso.store(obj);

or

$.store(obj);

data.reindex

Method

Reindexes the data store

Events:
beforeDataReindex - Fires before reindexing the data store
afterDataReindex - Fires after reindexing the data store

@return {Object} Data store

data.set

Method

Creates or updates an existing record

If a POST is issued, and the data.key property is not set the first property of the response object will be used as the key

Events:
beforeDataSet - Fires before the record is set
afterDataSet - Fires after the record is set, the record is the argument for listeners
syncDataSet - Fires when the local store is updated
failedDataSet - Fires if the store is RESTful and the action is denied

@param {Mixed} key Integer or String to use as a Primary Key
@param {Object} data Key:Value pairs to set as field values
@param {Boolean} sync [Optional] True if called by data.sync
@return {Object} The data store

data.sort

Method

Returns a view, or creates a view and returns it

Events:
beforeDataSort - Fires before the record is set
afterDataSort - Fires after the record is set, the record is the argument for listeners

@param {String} query Single column sort
@param {String} create [Optional, default is true] Boolean determines whether to recreate a view if it exists
@return {Array} View of data

data.source

Property

Property of the response Object which contains the records

data.sync

Method

Syncs the data store with a URI representation

Events:
beforeDataSync - Fires before syncing the data store
afterDataSync - Fires after syncing the data store

@return {Object} Data store

data.total

Property

Total records in the store

data.uri

Property

URI the data store represents (RESTful behavior), has a getter & setter as 'uri'; IE8 has a special function setUri() because it does not support getters or setters

The value is exposed as the uri property

data.views

Property

Data sets generated by sort(), thrown away on reindex()

decode

Method

Decodes the JSON argument

@param {String} arg String to parse
@return {Mixed} Entity resulting from parsing JSON, or undefined

var obj = abaaso.decode(JSONData);

defer

Method

Defers the execution of Function by at least the supplied milliseconds

Timing may vary under "heavy load" relative to the CPU & client JavaScript engine

@param {Function} fn Function to defer execution of
@param {Integer} ms Milliseconds to defer execution
@return {Object} undefined

abaaso.defer(function, 5000);

define

Method

Allows deep setting of properties without knowing if the structure is valid

@param {String} args Dot delimited string of the structure
@param {Mixed} value Value to set
@param {Object} obj Object receiving value
@return {Object} Object receiving value

abaaso.define('module', { ... });

or

abaaso.define('class.subclass.property', value, object);

del

Method

Creates an XmlHttpRequest DELETE request to a URI

REST security is applied to requests, if a verb is not in the Allow header it will be blocked by abaaso

Events:
beforeXHR - Fires before the XmlHttpRequest is made
beforeDelete - Fires before the XmlHttpRequest is made
afterDelete - Fires after the XmlHttpRequest response is received
afterXHR - Fires after the XmlHttpRequest response is received
failedDelete - Fires on error
receivedDelete - Fires on XHR readystate 2, clears the timeout only!
timeoutDelete - Fires 30s after XmlHttpRequest is made

@param {String} uri URI to query
@param {Function} success A handler function to execute when an appropriate response been received
@param {Function} failure [Optional] A handler function to execute on error
@return {String} URI to query

abaaso.del("uri", function(){});

destroy

Method

Destroys an Element

Events:
beforeDestroy - Fires before the destroy starts
afterDestroy - Fires after the destroy ends

@method destroy
@param {Mixed} obj Element or Array of Elements or $ queries
@return {Mixed} Element, Array of Elements or undefined

abaaso.destroy("#id");

or

$("#id").destroy();

domId

Method

Encodes a String to a DOM friendly ID

@param id {string} The object.id value to encode
@returns {string} Returns a lowercase stripped string

"Make an ID".domId();

el

Class

Element methods

el.class

Method

Adds or removes a CSS class

Events:
beforeClassChange - Fires before the Object's class is changed
afterClassChange - Fires after the Object's class is changed

@param {Mixed} obj Element or Array of Elements or $ queries
@param {String} arg Class to add or remove (can be a wildcard)
@param {Boolean} add Boolean to add or remove, defaults to true
@return {Mixed} Element or Array of Elements

el.clear

Method

Clears an object's innerHTML, or resets it's state

Events:
beforeClear - Fires before the Object is cleared
afterClear - Fires after the Object is cleared

@method clear
@param {Mixed} obj Element or Array of Elements or $ queries
@return {Mixed} Element or Array of Elements

abaaso.el.clear("id");

or

$("id").clear();

el.create

Method

Creates an Element in document.body or a target Element

An id is generated if not specified with args

Events:
beforeCreate - Fires after the Element has been created, but not set
afterCreate - Fires after the Element has been appended to it's parent

@param {String} type Type of Element to create
@param {Object} args [Optional] Collection of properties to apply to the new element
@param {Mixed} target [Optional] Target object or element.id value to append to
@return {Object} Element that was created or undefined

abaaso.el.create("div", {innerHTML:"Hello world!"});

el.css

Method

Creates a CSS stylesheet in the View

@param {String} content CSS to put in a style tag
@return {Object} Element created or undefined

abaaso.el.css(".class {...}");

or

abaaso.css(".class {...}");

or

$.css(".class {...}");

el.destroy

Method

Destroys an Element

Events:
beforeDestroy - Fires before the destroy starts
afterDestroy - Fires after the destroy ends

@method destroy
@param {Mixed} obj Element or Array of Elements or $ queries
@return {Mixed} Element, Array of Elements or undefined

abaaso.el.destroy("id");

or

$("id").destroy();

el.enable

Method

Enables an Element

Events:
beforeEnable - Fires before the enable starts
afterEnable - Fires after the enable ends

@param {Mixed} obj Element or Array of Elements or $ queries
@return {Mixed} Element, Array of Elements or undefined

abaaso.el.enable("id");

or

$("id").enable();

el.hide

Method

Hides an Element if it's visible

Events:
beforeHide - Fires before the object is hidden
afterHide - Fires after the object is hidden

@param {Mixed} obj Element or Array of Elements or $ queries
@return {Mixed} Element, Array of Elements or undefined

abaaso.el.hide($("#id"));

or

$("#id").hide();

el.position

Method

Finds the position of an element

@param {Mixed} obj Element or $ query
@return {Array} Array containing the render position of the element

var pos = abaaso.el.position("id");

or

var pos = $("id").position();

el.show

Method

Shows an Element if it's not visible

Events:
beforeEnable - Fires before the object is visible
afterEnable - Fires after the object is visible

@param {Mixed} obj Element or Array of Elements or $ queries
@return {Mixed} Element, Array of Elements or undefined

abaaso.el.show($("#id"));

OR

$("#id").show();

el.size

Method

Returns the size of the Object

@param obj {Mixed} Instance, Array of Instances of $() friendly ID
@return {Object} Size {x:, y:}, Array of sizes or undefined

abaaso.el.size($("#id"));

or

$.el.size($("#id"));

or

$("#id").size();

el.update

Method

Updates an Element

Events:
beforeUpdate - Fires before the update starts
afterUpdate - Fires after the update ends

@param {Mixed} obj Element or Array of Elements or $ queries
@param {Object} args Collection of properties
@return {Mixed} Element, Array of Elements or undefined

abaaso.el.update("id", {args});

or

$("id").update({args});

encode

Method

Encodes the argument as JSON

@param {Mixed} arg Entity to encode
@return {String} JSON, or undefined

var jsonString = abaaso.encode(Array);

error

Method

Error handling, with history in abaaso.error.log

@param {Mixed} e Error object or message to display
@param {Array} args Array of arguments from the callstack
@param {Mixed} scope Entity that was "this"
@param {Boolean} warning [Optional] Will display as console warning if true
@return {Object} undefined

try {
// Do some operations
}
catch (e) {
$.error(e, arguments, this);
}

expires

Method

Garbage collector for the cached URI representations

@return {Undefined} undefined

fire

Method

Fires an event

@param {Mixed} obj Entity or Array of Entities or $ queries
@param {String} event Event being fired
@param {Mixed} arg [Optional] Argument supplied to the listener
@return {Mixed} Entity, Array of Entities or undefined

abaaso.fire("event");

or

$("#id").fire("event");

genId

Method

Generates an ID value

@param {Mixed} obj [Optional] Object to receive id
@return {Mixed} Object or id

this.genId();

get

Method

Sends a GET to the URI

Alias to client.get

Events:
beforeGet - Fires before the GET request is made
afterGet - Fires after the GET response is received

@param uri {string} URI to submit to
@param fn {function} A handler function to execute once a response has been received

abaaso.get("uri", function(){});

or

$("#id").get("uri");

guid

Method

Generates a GUID

@return {String} GUID

id

Property

Namespace ID with a value of "abaaso"

init

Method

This method sets up the library

It is safe to construct a GUI on this Event

Events:
ready - Fires when the DOM is ready

json

Class

JSON methods

json.decode

Method

Decodes the argument

@param {String} arg String to parse
@return {Mixed} Entity resulting from parsing JSON, or undefined

var obj = json.decode(xhrResponse);

json.encode

Method

Encodes the argument as JSON

@param {Mixed} arg Entity to encode
@return {String} JSON, or undefined

var jString = jsone.encode(obj);

jsonp

Method

Creates a JSONP request if CORS is not supported, otherwise a GET request is made

Events:
beforeJSONP - Fires before the SCRIPT is made
afterJSONP - Fires after the SCRIPT is received
failedJSONP - Fires on error
timeoutJSONP - Fires 30s after SCRIPT is made

@param {String} uri URI to request
@param {Function} success A handler function to execute when an appropriate response been received
@param {Function} failure [Optional] A handler function to execute on error
@param {Mixed} args Custom JSONP handler parameter name, default is "callback"; or custom headers for GET request (CORS)
@return {String} URI to query

abaaso.jsonp(uri, handler);

label

Class

Labels for localization

Override this with another language pack

label.common

Property

Common labels

back : "Back"
cancel : "Cancel"
clear : "Clear"
close : "Close"
cont : "Continue"
del : "Delete"
edit : "Edit"
find : "Find"
gen : "Generate"
go : "Go"
loading : "Loading"
next : "Next"
login : "Login"
ran : "Random"
save : "Save"
search : "Search"
submit : "Submit"

label.error

Property

Error messages

databaseNotOpen : "Failed to open the Database, possibly exceeded Domain quota."
databaseNotSupported : "Client does not support local database storage."
databaseWarnInjection : "Possible SQL injection in database transaction, use the ? placeholder."
elementNotCreated : "Could not create the Element."
elementNotFound : "Could not find the Element."
expectedArray : "Expected an Array."
expectedArrayObject : "Expected an Array or Object."
expectedBoolean : "Expected a Boolean value."
expectedObject : "Expected an Object."
invalidArguments : "One or more arguments is invalid."
invalidDate : "Invalid Date."
invalidFields : "The following required fields are invalid: "
serverError : "A server error has occurred."

label.months

Property

Months of the Year

"1" : "January"
"2" : "February"
"3" : "March"
"4" : "April"
"5" : "May"
"6" : "June"
"7" : "July"
"8" : "August"
"9" : "September"
"10" : "October"
"11" : "November"
"12" : "December"

listeners

Method

Gets the listeners for an event

@param {Mixed} obj Entity or Array of Entities or $ queries
@param {String} event Event being queried
@return {Array} Array of listeners for the event

var listeners = abaaso.listeners([obj, ]"event");

or

var listeners = $("#id").listeners();

loading

Class

Static class used to render a loading icon in the Window.

loading.create

Method

Renders a loading icon in a target element, with a class of "loading"

@param {Mixed} obj Entity or Array of Entities or $ queries
@return {Mixed} Entity, Array of Entities or undefined

$("#id").loading();

loading.image

Property

The Element instance of the loading image

loading.url

Property

Loading icon URL

abaaso.loading.url = "url";

message

Class

Messaging between iframes

message.clear

Method

Clears the message listener

@returns {Object} abaaso

message.recv

Method

Sets a handler for recieving a message

@param {Function} fn Callback function
@return {Object} abaaso

message.send

Method

Posts a message to the target

@param {Object} target Object to receive message
@param {Mixed} arg Entity to send as message
@returns {Object} target

mouse

Class

Mouse tracking

mouse.enabled

Property

Boolean indicating whether mouse tracking is enabled

if (abaaso.mouse.enabled) {
var x = abaaso.mouse.pos.x,
var y = abaaso.mouse.pos.y;

...
}

mouse.log

Property

Boolean indicating whether to try logging co-ordinates to the console

abaaso.mouse.log = true;

mouse.pos

Property

Mouse co-ordinates stored as an object with 'x' and 'y' properties

if (abaaso.mouse.enabled) {
var x = abaaso.mouse.pos.x,
var y = abaaso.mouse.pos.y;

...
}

mouse.track

Method

Enables or disables mouse co-ordinate tracking

@param {Mixed} n Boolean to enable/disable tracking, or Mouse Event
@return {Object} abaaso.mouse

abaaso.mouse.track(true);

number

Class

Number methods

number.diff

Method

Returns the difference of arg

@param {Number} arg Number to compare
@return {Number} The absolute difference

number.even

Method

Tests if an number is even

@param {Number} arg Number to test
@return {Boolean} True if even, or undefined

abaaso.number.even(i) ? /* it's even */ : void(0);

or

i.even() ? /* it's even */ : void(0);

number.odd

Method

Tests if a number is odd

@param {Number} arg Number to test
@return {Boolean} True if odd, or undefined

abaaso.number.odd(i) ? /* it's odd */ : void(0);

or

i.odd() ? /* it's odd */ : void(0);

observer

Class

Global Observer wired to a State Machine

observer.add

Method

Adds a handler to an event

@param {Mixed} obj Entity or Array of Entities or $ queries
@param {String} event Event being fired
@param {Function} fn Event handler
@param {String} id [Optional / Recommended] The id for the listener
@param {String} scope [Optional / Recommended] The id of the object or element to be set as 'this'
@param {String} state [Optional] The state the listener is for
@return {Mixed} Entity, Array of Entities or undefined

abaaso.observer.add("#id", "event", function(){}[, "name", this, false]);

or

$("#id").on("event", function(){}[, "name", this, false]);

or

obj.on("event", function(){}[, "name"]);

observer.fire

Method

Fires an event

@param {Mixed} obj Entity or Array of Entities or $ queries
@param {String} event Event being fired
@param {Mixed} arg [Optional] Argument supplied to the listener
@return {Mixed} Entity, Array of Entities or undefined

abaaso.observer.fire(obj, "event");

or

$("#id").fire("event");

or

obj.fire("event");

observer.list

Method

Gets the listeners for an event

@param {Mixed} obj Entity or Array of Entities or $ queries
@param {String} event Event being queried
@return {Array} Array of listeners for the event

var listeners = abaaso.observer.list([obj, ]"event");

or

var listeners = $("#id").listeners();

or

var listeners = obj.listeners();

observer.listeners

Property

[Private] Array of event listeners

observer.log

Property

If true, events fired are written to the console

abaaso.observer.log = true;

observer.replace

Method

[Private] Replaces an active listener, moving it to the standby collection (state machine)

This is how Hypermedia As The Engine Of Application State is implemented

@param obj {mixed} The object.id or instance of object firing the event
@param event {string} The event
@param id {string} The identifier for the active listener
@param sId {string} The identifier for the new standby listener
@param listener {mixed} The standby id (string), or the new event listener (function)
@returns {object} The object

on

Method

Adds a handler to an event

@param {Mixed} obj Entity or Array of Entities or $ queries
@param {String} event Event being fired
@param {Function} fn Event handler
@param {String} id [Optional / Recommended] The id for the listener
@param {String} scope [Optional / Recommended] The id of the object or element to be set as 'this'
@param {String} state [Optional] The state the listener is for
@return {Mixed} Entity, Array of Entities or undefined

abaaso.on(obj, "event", function(){}[, "name", this, false]);

or

$("#id").on("event", function(){}[, "name"]);

or

obj.on("event", function(){}[, "name]);

permissions

Method

Returns the permission of the cached URI

@param {String} uri URI to query
@return {Object} Contains an Array of available commands, the permission bit and a map

position

Method

Finds the position of an element

@param {Mixed} obj Element or $ query
@return {Array} Array containing the render position of the element

var pos = abaaso.position("#id");

or

var pos = $("#id").position();

post

Method

Creates an XmlHttpRequest POST request to a URI

Responses are automatically cast to their respective Objects, e.g. JSON will become an Object or Array, XML will become an XMLDOM Object

REST security is applied to requests, if a verb is not in the Allow header it will be blocked by abaaso

Events:
beforeXHR - Fires before the XmlHttpRequest is made
beforePost - Fires before the XmlHttpRequest is made
afterPost - Fires after the XmlHttpRequest response is received
afterXHR - Fires after the XmlHttpRequest response is received
failedPost - Fires on error
receivedPost - Fires on XHR readystate 2, clears the timeout only!
timeoutPost - Fires 30s after XmlHttpRequest is made

@param {String} uri URI to query
@param {Function} success A handler function to execute when an appropriate response been received
@param {Function} failure [Optional] A handler function to execute on error
@param {Mixed} args Data to send with the request
@return {String} URI to query

abaaso.post("uri", function(){}, {args});

prototypes

Class

Collection of methods applied to Prototype objects, extending the functionality of the DOM with abaaso.

Most methods will have defaults applied, such as scope if not specified.

prototypes.array

Class

Methods added to the Array.prototype Object to aid in working with Arrays.

prototypes.array.cast

Method

Returns an Object (NodeList, etc.) as an Array

@param {Object} obj Object to cast
@param {Boolean} key [Optional] Returns key or value, only applies to Objects without a length property
@return {Array} Object as an Array

prototypes.array.contains

Method

Finds the index of arg(s) in instance

@param arg {string} Comma delimited string of search values
@returns {mixed} Integer or an array of integers representing the location of the arg(s)

var indexes = haystack.contains("needle1, needle2, needle3");

prototypes.array.diff

Method

Finds the difference between array1 and array2

@param array2 {array} An array to compare against
@returns {array} An array of the differences

var difference = array1.diff(array2);

prototypes.array.first

Method

Returns the first Array node

@returns {mixed} The first node of the array

var obj = array.first();

prototypes.array.index

Method

Finds the index of arg in instance. Use contains() for multiple arguments

@param arg {mixed} The argument to find (string or integer)
@returns {integer} The position of arg in instance

var index = haystack.index("needle1");

prototypes.array.indexed

Method

Returns an Associative Array as an Indexed Array

@param returns {array} The indexed array

var indexed = array.indexed();

prototypes.array.intersect

Method

Finds the intersections between array1 and array2

@param {Array} array1 Source Array
@param {Array} array2 Comparison Array
@return {Array} Array of the intersections

var x = array1.intersect(array2);

prototypes.array.keys

Method

Returns the keys in the array

@returns {array} An array of the keys in obj

var keys = array.keys();

prototypes.array.last

Method

Returns the last node of the array

@returns {mixed} The last node of the array

var obj = array.last();

prototypes.array.on

Method

Adds a handler to an event

@param event {string} The event being fired
@param fn {function} The event handler
@param id {string} [Optional / Recommended] The id for the listener
@param scope {string} [Optional / Recommended] The id of the object or element to be set as 'this'
@param standby {boolean} [Optional] Add to the standby collection; the id parameter is [Required] if true
@returns {object} The array

array.on("event", function(){ ... });

prototypes.array.remove

Method

Removes arg from instance without destroying and re-creating instance

Events:
beforeRemove - Fires before modifying the array
afterRemove - Fires after modifying the array

@param start {integer} The starting position
@param end {integer} The ending position (optional)
@returns {array} A scrubbed array

array.remove(1, 2);

prototypes.array.total

Method

Gets the total keys in an Array

@returns {integer} The number of keys in the Array

var total = array.total();

prototypes.element

Class

Methods added to the Element.prototype Object to simplify working with the abaaso library.

prototypes.element.create

Method

Creates an Element in document.body or a target Element

An id is generated if not specified with args

Events:
beforeCreate - Fires after the Element has been created, but not set
afterCreate - Fires after the Element has been appended to it's parent

@param {String} type Type of Element to create
@param {Object} args [Optional] Collection of properties to apply to the new element
@param {Mixed} target [Optional] Target object or element.id value to append to
@return {Object} Element that was created or undefined

$("#id").create("div", {innerHTML:"Hello world!"});

prototypes.element.disable

Method

Disables an Element

Events:
beforeDisable - Fires before the disable starts
afterDisable - Fires after the disable ends

@return {Mixed} Element

$("#id").disable();

prototypes.element.enable

Method

Enables an element

Events:
beforeEnable - Fires before the enable starts
afterEnable - Fires after the enable ends

$("#id").enable();

prototypes.element.get

Method

Sends a GET to the URI, and sets the response as the innerHTML value of the element

Alias to client.get

Events:
beforeGet - Fires before the GET request is made
afterGet - Fires after the GET response is received

@param uri {string} URI to submit to

$("#id").get("uri");

prototypes.element.hide

Method

Hides an Element if it's visible

@returns {mixed} Instance or Array of Instances

$("#id").hide();

prototypes.element.isAlphaNum

Method

Returns True if the Element value or innerText is alphanumeric

@returns {Boolean} True if the Element is alphanumeric

if ($("#id").isAlphaNum()) { ... }

prototypes.element.isBoolean

Method

Returns True if the Element value or innerText is a boolean

@returns {Boolean} True if the Element is a boolean

if ($("#id").isBoolean()) { ... }

prototypes.element.isDate

Method

Returns True if the Element value or innerText is a date

@returns {Boolean} True if the Element is a date

if ($("#id").isDate()) { ... }

prototypes.element.isDomain

Method

Returns True if the Element value or innerText is a domain

@returns {Boolean} True if the Element is a domain

if ($("#id").isDomain()) { ... }

prototypes.element.isEmail

Method

Returns True if the Element value or innerText is an email

@returns {Boolean} True if the Element is an email

if ($("#id").isEmail()) { ... }

prototypes.element.isEmpty

Method

Returns True if the Element value or innerText is empty

@returns {Boolean} True if the Element is empty

if ($("#id").isEmpty()) { ... }

prototypes.element.isInt

Method

Returns True if the Element value or innerText is an integer

@returns {Boolean} True if the Element is an integer

if ($("#id").isInt()) { ... }

prototypes.element.isIP

Method

Returns True if the Element value or innerText is an IP

@returns {Boolean} True if the Element is an IP

if ($("#id").isIP()) { ... }

prototypes.element.isNumber

Method

Returns True if the Element value or innerText is a number

@returns {Boolean} True if the Element is a number

if ($("#id").isNumber()) { ... }

prototypes.element.isPhone

Method

Returns True if the Element value or innerText is a phone number

@returns {Boolean} True if the Element is a phone number

if ($("#id").isPhone()) { ... }

prototypes.element.isString

Method

Returns True if the Element value or innerText is valid

@returns {Boolean} True if the Element is valid

if ($("#id").isString()) { ... }

prototypes.element.jsonp

Method

Cross-site JSONP request to inject a textual value into the Element

Events:
beforeJSONP - Fires before the JSONP request is made
afterJSONP - Fires after the JSONP response is received

@param uri {string} URI to load as a SCRIPT element
@param property {string} The JSON property to set as the Element's innerHTML value
@param callback {string} [Optional] The name of the callback variable

abaaso.create("div").jsonp(uri, property);

prototypes.element.loading

Method

Renders a loading icon in a target element

$("#id").loading();

prototypes.element.on

Method

Adds a handler to an event

@param event {string} The event being fired
@param fn {function} The event handler
@param id {string} [Optional / Recommended] The id for the listener
@param scope {string} [Optional / Recommended] The id of the object or element to be set as 'this'
@param standby {boolean} [Optional] Add to the standby collection; the id parameter is [Required] if true
@returns {object} The element

$("#id").on("event", function(){ ... });

prototypes.element.position

Method

Finds the position of an element

@returns {array} An array containing the render position of the element

var pos = $("#id").position();

prototypes.element.show

Method

Shows an Element if it's not visible

@returns {mixed} Instance or Array of Instances

$("#id").show();

prototypes.element.text

Method

Updates an element's innerHTML with the supplied string

@param arg {string} The string to set

$("#id").text("Hello world");

prototypes.element.update

Method

Updates an object or element

Events:
beforeUpdate - Fires before the update starts
afterUpdate - Fires after the update ends

@param args {object} A collection of properties

$("id").update({ ... });

prototypes.element.validate

Method

Validates a Form with an attempt at matching patterns to field.name, or performs isEmpty() on the value or innerText

@returns {Object}

$("form")[0].validate();

OR

$("#formId").validate();

OR

$("#Id").validate();

prototypes.number

Class

Methods added to the Number.prototype to aid in math operations and comparisons.

prototypes.number.isEven

Method

Returns true if the number is even

@returns {boolean}

number.isEven() ? alert("it's even"); : void(0);

prototypes.number.isOdd

Method

Returns true if the number is odd

@returns {boolean}

number.isOdd() ? alert("it's odd") : void(0);

prototypes.number.on

Method

Adds a handler to an event

@param event {string} The event being fired
@param fn {function} The event handler
@param id {string} [Optional / Recommended] The id for the listener
@param scope {string} [Optional / Recommended] The id of the object or element to be set as 'this'
@param standby {boolean} [Optional] Add to the standby collection; the id parameter is [Required] if true
@returns {object} The number

number.on("event", function(){ ... });

prototypes.shared

Class

Methods applied to Array.prototype, Element.prototype, Number.prototype and String.prototype

prototypes.shared.clear

Method

Clears an object's innerHTML, or resets it's state

Alias to el.clear

Events:
beforeClear - Fires before the Object is cleared
afterClear - Fires after the Object is cleared

obj.clear();

prototypes.shared.destroy

Method

Destroys an element

Alias to el.destroy

Events:
beforeDestroy - Fires before the destroy starts
afterDestroy - Fires after the destroy ends

obj.destroy();

prototypes.shared.fire

Method

Fires an event for the Observer

@param event {string} The event being fired
@returns {object} The object

$("#id").fire("event");

prototypes.shared.genId

Method

Generates an ID property prefixed with "abaaso_" if the Object does not have one

@returns {object} The object

obj.genId();

prototypes.shared.listeners

Method

Lists the active and standby listeners for an object event

@param event {string} The event being fired
@returns {array} The listeners for the object

var listeners = $("#id").listeners();

prototypes.shared.un

Method

Removes an event listener, or listeners

@param event {string} The event being fired
@param id {string} [Optional] The identifier for the listener
@returns {object} The object

$("#id").un("event");

prototypes.string

Class

Methods added to the String.prototype Object to simplify common operations

prototypes.string.capitalize

Method

Capitalizes the first character of the string

string.capitalize();

prototypes.string.isAlphaNum

Method

Returns True if the String is alphanumeric

@returns {Boolean} True if the string is alphanumeric

if (string.isAlphaNum()) { ... }

prototypes.string.isBoolean

Method

Returns True if the String is a boolean

@returns {Boolean} True if the string is a boolean

if (string.isBoolean()) { ... }

prototypes.string.isDate

Method

Returns True if the String is a date

@returns {Boolean} True if the string is a date

if (string.isDate()) { ... }

prototypes.string.isDomain

Method

Returns True if the String is a domain

@returns {Boolean} True if the string is a domain

if (string.isDomain()) { ... }

prototypes.string.isEmail

Method

Returns True if the String is an email address

@returns {Boolean} True if the string is an email address

if (string.isEmail()) { ... }

prototypes.string.isEmpty

Method

Returns True if the String is empty

@returns {Boolean} True if the string is empty

if (string.isEmpty()) { ... }

prototypes.string.isInt

Method

Returns True if the String is an integer

@returns {Boolean} True if the string is an integer

if (string.isInt()) { ... }

prototypes.string.isIP

Method

Returns True if the String is an IP address

@returns {Boolean} True if the string is an IP address

if (string.isIP()) { ... }

prototypes.string.isNumber

Method

Returns True if the String is a number

@returns {Boolean} True if the string is a number

if (string.isNumber()) { ... }

prototypes.string.isPhone

Method

Returns True if the String is a phone number

@returns {Boolean} True if the string is phone number

if (string.isPhone()) { ... }

prototypes.string.isString

Method

Returns True if the String is valid

@returns {Boolean} True if the string is valid

if (string.isString()) { ... }

prototypes.string.on

Method

Adds a handler to an event

@param event {string} The event being fired
@param fn {function} The event handler
@param id {string} [Optional / Recommended] The id for the listener
@param scope {string} [Optional / Recommended] The id of the object or element to be set as 'this'
@param standby {boolean} [Optional] Add to the standby collection; the id parameter is [Required] if true
@returns {object} The string

string.on("event", function(){ ... });

prototypes.string.toCamelCase

Method

Reformats the String as camelCase

var cc = "This string will be camel case".toCamelCase();

prototypes.string.trim

Method

Trims leading and trailing whitespace from a string

@param arg {string} The string to trim

var trimmed = string.trim();

put

Method

Sends a PUT to the URI

Alias to client.put

Events:
beforePut - Fires before the POST request is made
afterPut - Fires after the POST response is received

@param uri {string} URI submit to
@param fn {function} A handler function to execute once a response has been received
@param {args} PUT variables to include

abaaso.put("uri", function(){}, {args});

queryString

Method

Returns an Object containing 1 or all key:value pairs from the querystring

@param {String} arg [Optional] Key to find in the querystring
@return {Object} Object of 1 or all key:value pairs in the querystring

ready

Method

Boolean indicating that abaaso is initialized

if (abaaso.ready) {
// do some operations
}

state

Class

Application state methods and properties

state.change

Method

Internet Explorer 8 only method to change the application state

state.current

Property

Current application state

Setting this property will trigger an application state change fired from abaaso; stateful binding will occur

*** All stateful listeners must be registered before setting this property ***

state.header

Property

User defined HTTP header which triggers Hyper Media As The Engine Of Application State (HATEOAS)

This (custom) header will imply a state change from the Server, and the Client will respond accordingly in a dynamic way via stateful binding

state.previous

Property

The previous application state, default is null

store

Method

Registers a data store on an Object

Events:
beforeDataStore - Fires before registering the data store
afterDataStore - Fires after registering the data store

@param {Object} obj Object to register with
@return {Object} Object registered with

abaaso.store(obj);

tpl

Method

Transforms JSON to HTML and appends to Body or target Element

@param {Object} data JSON Object describing HTML
@param {Mixed} target [Optional] Target Element or Element.id to receive the HTML
@return {Object} Target Element

un

Method

Removes an event listener, or Array of event listeners

@param {Mixed} obj Entity or Array of Entities or $ queries
@param {String} event Event being fired
@param {String} id [Optional] Listener id
@return {Mixed} Entity, Array of Entities or undefined

abaaso.un(obj, "event"[, "name"]);

or

$("#id").un("event"[, "name"]);

or

obj.un("event"[, "name"]);

update

Method

Updates an Element

Events:
beforeUpdate - Fires before the update starts
afterUpdate - Fires after the update ends

@param {Mixed} obj Element or Array of Elements or $ queries
@param {Object} args Collection of properties
@return {Mixed} Element, Array of Elements or undefined

abaaso.update("#id", {args});

or

$("#id").update({args});

validate

Class

Validation methods and patterns

validate.pattern

Property

Regular expression patterns to test against

validate.test

Method

Validates args based on the type or pattern specified

@param {Object} args Object to test {(pattern[name] || /pattern/) : (value || #object.id)}
@return {Object} Results

var result = abaaso.validate.test({date: "2011/06/05"});

OR

var result = "2011/06/05".isDate();

version

Property

Version of abaaso

var version = abaaso.version;

or

var version = $.version;

xml

Class

XML methods

xml.decode

Method

Returns XML (Document) Object from a String

@param {String} arg XML String
@return {Object} XML Object or undefined

var xml = abaaso.xml.decode("...");

or

var xml = $.xml.decode("...");

xml.encode

Method

Returns XML String from an Object or Array

@param {Mixed} arg Object or Array to cast to XML String
@return {String} XML String or undefined

var xml = abaaso.xml.encode(obj);

or

var xml = $.xml.encode(obj);