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);
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);
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 methods
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);
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");
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);
Returns the first Array node
@param instance {array} The array
@returns {mixed} The first node of the array
var obj = array.first();
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");
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();
Finds the intersections between array1 and array2
@param {Array} array1 Source Array
@param {Array} array2 Comparison Array
@return {Array} Array of the intersections
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();
Returns the last node of the array
@param {Array} obj Array
@return {Mixed} Last node of Array
var obj = array.last();
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);
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();
[Private] Cache for RESTful behavior
[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");
[Private] Associative array of URIs with the HTTP Response and Headers as {header:, response}
[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");
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 properties and methods
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);
Boolean indicating if the client is an Android device
($.client.android) ? alert("it's an android!") : void(0);
Boolean indicating if the client is a Blackberry device
($.client.blackberry) ? alert("it's a blackberry!") : void(0);
Boolean indicating if the client is Google Chrome
(abaaso.client.chrome) ? alert("Client is Chrome!") : void(0);
Boolean indicating if the client supports CSS3+
(abaaso.client.css3) ? alert("CSS3 supported!") : void(0);
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);
Boolean indicating if the client is Mozilla Firefox
(abaaso.client.firefox) ? alert("Client is FireFox!") : void(0);
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");
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);
Boolean indicating if the client is Microsoft Internet Explorer
(abaaso.client.ie) ? alert("Client is Internet Explorer!") : void(0);
Boolean indicating if the client is an iOS device
($.client.ios) ? alert("it's an ios!") : void(0);
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);
Boolean indicating if the client is a Linux device
($.client.linux) ? alert("it's running linux!") : void(0);
Boolean indicating if the client is a MeeGo device
($.client.meego) ? alert("it's running meego!") : void(0);
Boolean indicating if the client is a mobile device (smartphone, etc.)
($.client.mobile) ? alert("it's a mobile!") : void(0);
Number of milliseconds to cache URI responses if the cache Headers are not present
client.ms = 3600;
Boolean indicating if the client is Opera
(abaaso.client.opera) ? alert("Client is Opera!") : void(0);
Boolean indicating if the client is an Apple OSX device
($.client.osx) ? alert("it's running osx!") : void(0);
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();
Boolean indicating if the client is a Playbook tablet
($.client.playbook) ? alert("it's a playbook!") : void(0);
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, {...});
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, {...});
[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
[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
Boolean indicating if the client is Apple Safari
(abaaso.client.safari) ? alert("Client is Safari!") : void(0);
Returns the visible area of the View
@return {Object} Describes the View {x: ?, y: ?}
var size = abaaso.client.size;
Boolean indicating if the client is a tablet device
($.client.tablet) ? alert("it's a tablet!") : void(0);
Client version (integer)
((abaaso.client.ie) && (abaaso.client.version >= 8)) ? alert("Getting better") : void(0);
Boolean indicating if the client is a WebOS device
($.client.webos) ? alert("it's a webos!") : void(0);
Boolean indicating if the client is a Microsoft Windows device
($.client.windows) ? alert("it's running windows!") : void(0);
Clones an Object
@param {Object} obj Object to clone
@return {Object} Clone of obj
var objClone = abaaso.clone(obj);
Cookie methods
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");
Gets a cookie
@param {String} name Name of the cookie to get
@return {Mixed} Cookie or undefined
var cookie = abaaso.cookie.get("name");
Gets the cookies for the domain
@return {Object} Collection of cookies
var cookies = abaaso.cookie.list();
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");
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!"});
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");
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);
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
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
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
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
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
Identifies the key in a POST response
Object with record keys as properties, and indexes as values
Array of records as Objects with key and data properties
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);
Reindexes the data store
Events:
beforeDataReindex - Fires before reindexing the data store
afterDataReindex - Fires after reindexing the data store
@return {Object} Data store
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
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
Property of the response Object which contains the records
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
Total records in the store
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 sets generated by sort(), thrown away on reindex()
Decodes the JSON argument
@param {String} arg String to parse
@return {Mixed} Entity resulting from parsing JSON, or undefined
var obj = abaaso.decode(JSONData);
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);
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);
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(){});
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();
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();
Element methods
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
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();
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!"});
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 {...}");
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();
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();
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();
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();
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();
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();
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});
Encodes the argument as JSON
@param {Mixed} arg Entity to encode
@return {String} JSON, or undefined
var jsonString = abaaso.encode(Array);
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);
}
Garbage collector for the cached URI representations
@return {Undefined} undefined
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");
Generates an ID value
@param {Mixed} obj [Optional] Object to receive id
@return {Mixed} Object or id
this.genId();
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");
Generates a GUID
@return {String} GUID
Namespace ID with a value of "abaaso"
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 methods
Decodes the argument
@param {String} arg String to parse
@return {Mixed} Entity resulting from parsing JSON, or undefined
var obj = json.decode(xhrResponse);
Encodes the argument as JSON
@param {Mixed} arg Entity to encode
@return {String} JSON, or undefined
var jString = jsone.encode(obj);
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);
Labels for localization
Override this with another language pack
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"
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."
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"
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();
Static class used to render a loading icon in the Window.
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();
The Element instance of the loading image
Loading icon URL
abaaso.loading.url = "url";
Messaging between iframes
Clears the message listener
@returns {Object} abaaso
Sets a handler for recieving a message
@param {Function} fn Callback function
@return {Object} abaaso
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 tracking
Boolean indicating whether mouse tracking is enabled
if (abaaso.mouse.enabled) {
var x = abaaso.mouse.pos.x,
var y = abaaso.mouse.pos.y;
...
}
Boolean indicating whether to try logging co-ordinates to the console
abaaso.mouse.log = true;
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;
...
}
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 methods
Returns the difference of arg
@param {Number} arg Number to compare
@return {Number} The absolute difference
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);
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);
Global Observer wired to a State Machine
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"]);
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");
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();
[Private] Array of event listeners
If true, events fired are written to the console
abaaso.observer.log = true;
[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
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]);
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
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();
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});
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.
Methods added to the Array.prototype Object to aid in working with Arrays.
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
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");
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);
Returns the first Array node
@returns {mixed} The first node of the array
var obj = array.first();
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");
Returns an Associative Array as an Indexed Array
@param returns {array} The indexed array
var indexed = array.indexed();
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);
Returns the keys in the array
@returns {array} An array of the keys in obj
var keys = array.keys();
Returns the last node of the array
@returns {mixed} The last node of the array
var obj = array.last();
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(){ ... });
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);
Gets the total keys in an Array
@returns {integer} The number of keys in the Array
var total = array.total();
Methods added to the Element.prototype Object to simplify working with the abaaso library.
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!"});
Disables an Element
Events:
beforeDisable - Fires before the disable starts
afterDisable - Fires after the disable ends
@return {Mixed} Element
$("#id").disable();
Enables an element
Events:
beforeEnable - Fires before the enable starts
afterEnable - Fires after the enable ends
$("#id").enable();
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");
Hides an Element if it's visible
@returns {mixed} Instance or Array of Instances
$("#id").hide();
Returns True if the Element value or innerText is alphanumeric
@returns {Boolean} True if the Element is alphanumeric
if ($("#id").isAlphaNum()) { ... }
Returns True if the Element value or innerText is a boolean
@returns {Boolean} True if the Element is a boolean
if ($("#id").isBoolean()) { ... }
Returns True if the Element value or innerText is a date
@returns {Boolean} True if the Element is a date
if ($("#id").isDate()) { ... }
Returns True if the Element value or innerText is a domain
@returns {Boolean} True if the Element is a domain
if ($("#id").isDomain()) { ... }
Returns True if the Element value or innerText is an email
@returns {Boolean} True if the Element is an email
if ($("#id").isEmail()) { ... }
Returns True if the Element value or innerText is empty
@returns {Boolean} True if the Element is empty
if ($("#id").isEmpty()) { ... }
Returns True if the Element value or innerText is an integer
@returns {Boolean} True if the Element is an integer
if ($("#id").isInt()) { ... }
Returns True if the Element value or innerText is an IP
@returns {Boolean} True if the Element is an IP
if ($("#id").isIP()) { ... }
Returns True if the Element value or innerText is a number
@returns {Boolean} True if the Element is a number
if ($("#id").isNumber()) { ... }
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()) { ... }
Returns True if the Element value or innerText is valid
@returns {Boolean} True if the Element is valid
if ($("#id").isString()) { ... }
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);
Renders a loading icon in a target element
$("#id").loading();
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(){ ... });
Finds the position of an element
@returns {array} An array containing the render position of the element
var pos = $("#id").position();
Shows an Element if it's not visible
@returns {mixed} Instance or Array of Instances
$("#id").show();
Updates an element's innerHTML with the supplied string
@param arg {string} The string to set
$("#id").text("Hello world");
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({ ... });
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();
Methods added to the Number.prototype to aid in math operations and comparisons.
Returns true if the number is even
@returns {boolean}
number.isEven() ? alert("it's even"); : void(0);
Returns true if the number is odd
@returns {boolean}
number.isOdd() ? alert("it's odd") : void(0);
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(){ ... });
Methods applied to Array.prototype, Element.prototype, Number.prototype and String.prototype
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();
Destroys an element
Alias to el.destroy
Events:
beforeDestroy - Fires before the destroy starts
afterDestroy - Fires after the destroy ends
obj.destroy();
Fires an event for the Observer
@param event {string} The event being fired
@returns {object} The object
$("#id").fire("event");
Generates an ID property prefixed with "abaaso_" if the Object does not have one
@returns {object} The object
obj.genId();
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();
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");
Methods added to the String.prototype Object to simplify common operations
Capitalizes the first character of the string
string.capitalize();
Returns True if the String is alphanumeric
@returns {Boolean} True if the string is alphanumeric
if (string.isAlphaNum()) { ... }
Returns True if the String is a boolean
@returns {Boolean} True if the string is a boolean
if (string.isBoolean()) { ... }
Returns True if the String is a date
@returns {Boolean} True if the string is a date
if (string.isDate()) { ... }
Returns True if the String is a domain
@returns {Boolean} True if the string is a domain
if (string.isDomain()) { ... }
Returns True if the String is an email address
@returns {Boolean} True if the string is an email address
if (string.isEmail()) { ... }
Returns True if the String is empty
@returns {Boolean} True if the string is empty
if (string.isEmpty()) { ... }
Returns True if the String is an integer
@returns {Boolean} True if the string is an integer
if (string.isInt()) { ... }
Returns True if the String is an IP address
@returns {Boolean} True if the string is an IP address
if (string.isIP()) { ... }
Returns True if the String is a number
@returns {Boolean} True if the string is a number
if (string.isNumber()) { ... }
Returns True if the String is a phone number
@returns {Boolean} True if the string is phone number
if (string.isPhone()) { ... }
Returns True if the String is valid
@returns {Boolean} True if the string is valid
if (string.isString()) { ... }
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(){ ... });
Reformats the String as camelCase
var cc = "This string will be camel case".toCamelCase();
Trims leading and trailing whitespace from a string
@param arg {string} The string to trim
var trimmed = string.trim();
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});
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
Boolean indicating that abaaso is initialized
if (abaaso.ready) {
// do some operations
}
Application state methods and properties
Internet Explorer 8 only method to change the application state
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 ***
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
The previous application state, default is null
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);
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
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"]);
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});
Validation methods and patterns
Regular expression patterns to test against
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 of abaaso
var version = abaaso.version;
or
var version = $.version;
XML methods
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("... ");
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);