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.
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.
fn on all elements of list.
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.
name.
element.
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.
true if the element is hidden, false otherwise. CSS visibility is considered.
document.writeln.
element.
elm1, elm2, elmN to elm.
elm's child nodes with elm1, elm2, elmN.
element after reference_elm.
element before reference_elm.
elm1, elm2, elmN.
elm1, elm2, elmN.
elm_to_replace with the DOM of new_elm.
elm1, elm2, elmN.
name. attrs should be an array.
dimension is an integer then integer is suffixed with "px". Otherwise dimension is returned unaltered.
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 top. top should be an integer.
elm1, elm2, elmN to className.
elm1, elm2, elmN to html.
html. If first_child is set to true then the first child from the html will be returned.
element to p. p should be 0.50 if you want 50% transparency.
Learn best through examples? Check out:
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)
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.
function after interval milliseconds
Learn best through examples? Check out:
AJS.drag_obj.args:AJS.drag_obj.click_elm:AJS.drag_obj.mouse_pos:{x: mouse_pos_x, y: mouse_pos_y}.element drag able.
handler:args:args are optional.
true.true.false.true.on_mouse_up(click_elm, drag_elm, event).
on_drag(click_elm, drag_elm, event).
element.{'top': null, 'left': null}, i.e. no limit.element to a drop zone.
args:on_hover(drop_zone_elm, click_elm, drag_elm).
on_drop(drop_zone_elm, click_elm, drag_elm).
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.
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.loadJSONDoc 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.