var_name from URL (e.g. http://domain.com/?var_name=value).
true if the current browser is Internet Explorer. Else false is returned.
true if the current browser is Netscape 7. Else false is returned.
true if the current browser is Apple Safari. Else false is returned.
true if the current browser is Opera. Else false is returned.
true if the current browser is Mozilla. Else false is returned.
true if the current system is Mac OS X. Else false is returned.
v and returns [v]. v is returned as is if it already is an array.
array. This method is useful to force arguments to act as an array instead of an object.
list into a string. The elements are separated by the specified delimiter delim.
true if the element is found in list, otherwise false is returned.
element in list. If the element isn't found -1 is returned.
eval_fn(list_elm) → boolean can be sent to evalute the element.
list. If the list is empty null is returned.
list. If the list is empty null is returned.
list1 with keys and values from list2.
list and returns the result. See the example.
[[elm1, ..., elmN], valX] and returns the [elm1, ..., elmN, valX].
fn on all elements of list. Signature of fn is: fn(element, index).
fn on all elements of list in reversed order. Signature of fn is: fn(element, index).
fn on all elements of list and returns all the elements of list where fn(elm) equals true.
id".
id1, id2, idN.
tag_name or class_name then set them to null. The whole document is searched, if parent isn't set.
element.
element's parents and return the first match.
true if the element has a parent, false otherwise. max_look_up specifies how many parents to consider. parent_to_concider is the parent we are looking for.
element's previous siblings and return the first match.
element's next siblings and return the first match.
name.
form's contents. Really useful for AJAX calls.
document.writeln.
elm1, elm2, elmN to elm.
elm1, elm2, elmN to the top of elm.
elm's child nodes with elm1, elm2, elmN.
element after reference_elm.
element before reference_elm.
elm_to_replace with the DOM of new_elm.
elm1, elm2, elmN.
name. attrs should be an array.
elm1, elm2, elmN to html.
elm1, elm2, elmN.
elm1, elm2, elmN.
true if the element is shown, false otherwise. CSS visibility and display is considered.
true if the element is hidden, false otherwise. CSS visibility and display is considered.
property of elm1, ..., elmN to new_value.
new_value can be {top: 50, left: 40}
elm1, elm2, elmN to width. width should be an integer.
elm1, elm2, elmN to height. height should be an integer.
elm1, elm2, elmN to left. left should be an integer.
elm1, elm2, elmN to right. right should be an integer.
elm1, elm2, elmN to top. top should be an integer.
elm1, elm2, elmN to className.
className to elm1, elm2, elmN.
className from elm1, elm2, elmN.
element to p. p should be 0.50 if you want 50% transparency.
html. If first_child is set to true then the first child from the html will be returned.
XMLHTTPRequest.
url and wrap it in a deferred.data could be a JSON object. type could be GET (POST is default). Both data and type are optional.
object to a JSON string.
url and get the response as a JSON object.
html.
js_txt.
{x: mouse_pos_x, y: mouse_pos_y}
integer.
{x: elm_left, y: elm_top}.
{w: window_width, h: window_height}.
true if elm1 and elm2 overlap each other, otherwise false is returned.
event.
type on the element.
fn:fn(event). event.key denotes the ASCII key if event type is keypress, keydown or keyup.
type can be:listen_once:boolean that specifies if the event should only listen once. Optional.
cancle_bubble:boolean that specifies if bubbling should be disabled. Optional.
element.
fn to scope.extra_args:array of extra parameters that should be sent to fn. Optional.
obj to itself.
Very useful for Ajax programming.
function after interval milliseconds
object as an array.
object as an array.
string.
true if object is defined. Else false is returned.
true if object is an array. Else false is returned.
true if object is a string. Else false is returned.
true if object is a number. Else false is returned.
true if object is a object. Else false is returned.
true if object is a dict (JSON). Else false is returned.
scope is null. Else export AJS to scope.
fn with scope.
A deferred gives the option to chain functions. I borrowed this idea from MochiKit that borrowed it from Twisted. My implementation is SUPER simple and is way off the initial idea of a deferred - but it's still useful and beautiful.
When you call AJS.getRequest or AJS.loadJSON you get a deferred object. This object has following methods:
addCallback(fn):fn to the end of the callback sequence.
addErrback(fn):fn to the end of the errorback sequence.
addCallbacks(callback, errback):callback to the end of the callback sequence.errback to the end of the errback sequence.
sendReq(data):data should be a JSON object.
If no error is encountered the callback sequence will be executed. If an error is encountered then the errback sequence will be executed.
The idea is best showed by an example:
var d = AJS.getRequest("http://del.icio.us/feeds/json/amix")
d.addCallback(function(res_txt, req) {
//Eval response text to get a Delicious object
AJS.evalTxt(res_txt);
return Delicious;
})
d.addCallback(function(o, req) {
//o is now Delicious object
alert('Total length of posts: ' + o.posts.length);
})
d.addErrback(function(res_txt, req) { alert("Error encountered.") })
d.addErrback(function(res_txt, req) {
alert("In here we could have some clean up code.")
})
d.sendReq()
Run this example? Deferred example with Deli.cio.us.