Introducing the new Dojo Image Widgets
Posted by Shane O'Sullivan on October 13, 2007
In previous posts (here for the Dojo 0.4.3 version, here and here), I wrote how I wrote an image gallery for version 0.4.3 of the Dojo Ajax Toolkit, and how I was translating it for the latest version of the toolkit, version 1.0.
Well, that work is now, finally, complete, and I have to say, I’m pretty damn happy with the results. The code is now part of the dojox.image project (dojox is the Dojo extensions project, for cool new code that may in the future make it into the core code base if enough people like/want it).
If you’d like to just see the gallery in action, have a look at the Photos page on my personal website, or see the links at the bottom of the post, otherwise, read on!
Update: changes have been made to the widgets since this post was written, resulting in some badly aligned images. This will be fixed in the next few days. (Oct 25th 2007)
Update: issue above has been fixed (Oct 29th 2007)
All For One….
The gallery is composed of three widgets:
- dojox.image.ThumbnailPicker – a widget to list many small images in either a horizontal or vertical orientation, scroll through them, and attach click events that other widgets can listen to
- dojox.image.SlideShow – a widget that displays one image at a time, and can run a slideshow, changing the images every ‘x’ seconds.
- dojox.image.Gallery – A wrapper around the ThumbnailPicker, and SlideShow widgets.
Both the ThumbnailPicker and Slideshow widgets can also be used on their own, and have no dependencies on each other.
Dojo Data Is Too Cool for School
One of the coolest features of all of these widgets is that they all feed off image data provided by the dojo.data API. What this basically means is that each widget can display images from any source, with no modification whatsoever. You simply pass it a Dojo data store, and is shows the pictures. Some of the data stores currently in the Dojo toolkit include:
- dojo.data.ItemFileReadStore – pull in simple JSON data in an array. You could use this if you simply have a directory of images on your own web server you would like to display
- dojox.data.FlickrRestStore (demo) – query the Flickr photo sharing website for images. This is all done on the browser, with no need for any server-side redirects. This is another of my additions to the Dojo toolkit – I love Flickr, feel free to check out my photo stream here. I previously wrote another blog post on this data store here.
- dojox.data.PicasaStore (demo) – query Google’s Picasa image sharing website for images. As with the Flickr data store, this is done on the browser, with no need for server side support.
and many more….. You can also write your own data store if you so desire, but the ones included in the toolkit should cover almost everything you might need.
Gimme, Gimme, Gimme!
So, how can I get this, you ask! Well, you can:
- Have a look at the test pages for the widgets:
- Test page for ThumbnailPicker
- Test page for SlideShow
- Test page for Gallery
- Demo page for dojox.data.FlickrRestStore
- The Gallery on my personal website – example of using the widget hosted on your own server
- The Gallery on another website – example of using the widget hosted on AOL’s cross domain CDN network.
- Demo page for all DojoX Image widgets
- Read the documentation (I know!! Documentation… in Dojo!!)
- Download the latest nightly archive from Dojo.
- Check out the code from the Subversion repository.
- Wait for Dojo 1.0 to come out (end of Oct 2007) and download the full release from the main Dojo website.
Update: Dojo 1.0 is now released. Get it at http://www.dojotoolkit.org/downloads
As always, any and all feedback is welcome. Also, a big thanks to Peter Higgins, owner of the dojox.image project, and Jared Jurkiewicz, owner of the dojo.data project, for all their helpful ideas, and for reviewing/committing my code to the Dojo project.
Share this post:digg it|kick it|Email it|bookmark it|reddit|liveIt