What is it?
Ojay is an open-source JavaScript library developed by London web agency the OTHER media for use in all its ongoing client projects. It acts as a wrapper for YUI, providing a more intuitive programming model and some additional features. It is built for compatibility with YUI 2.4.0 onwards, and is released under a BSD-style license.
One of its key features is the ability to chain function calls together, even when asynchronicity is involved. So, you can write lists of instructions where you would normally have nested callbacks:
$('a#run-this-code').on('click', $.stopEvent)
.setContent('Running...')
._('#example').animate({
height: {to: 0},
opacity: {from: 1, to: 0}
}, 0.5)
._($.HTTP).GET('/service/hello.html')
.insertInto('#example')
._('#example').animate({
height: {to: 80},
opacity: {from: 0, to: 1}
}, 0.7);
Download version 0.2.1
0.2.x is fully backward-compatible with 0.1.x. It adds a few small new features to the Ojay core, and four
new add-on packages: Forms, Keyboard, Overlay and Paginator.
How do I use it?
To start with, you’ll need to include the following YUI modules on your page: YAHOO.util.Dom, YAHOO.util.Event,
and YAHOO.util.Selector. The first two form the base for interacting with the page via script, and the latter is
YUI’s CSS selector engine, used by Ojay to grab element references.
Various Ojay features have further dependencies – these are highlighted in the documentation for each feature.
With those files in place, the articles in the sidebar should get you started. YUI libraries and all of Ojay is built into every page of this site, so you can try stuff out in Firebug as you read through the examples.
Development
Ojay is an open-source project, released under the BSD license. You can browse the source code, file bug reports and contribute patches on our Google Code site. We also have a mailing list, or you can get in touch with the library’s author at james.coglan@othermedia.com.
