The dojox.image.SlideShow widget displays a series of images, one at a time. It provides controls to move from image to the next or the previous image. It can also run an automated slideshow, moving from one image to the next every specified number of seconds.
The Slideshow widget has the following features.
It is possible to define the number of seconds between image transitions when running an automated slideshow. To do this, set the slideshowInterval attribute. For example, to set a three second interval between changing the displayed image, use the code below
<div dojoType="dojox.image.SlideShow" id="slideshow1" slideshowInterval="3"> </div>
The Slideshow widget has a default title template that is used to display the title of the current image, as well as it's relative position. To do this, set the titleTemplate attribute. The supported place holders are :
For example:
<div dojoType="dojox.image.SlideShow" id="slideshow1"
titleTemplate="My title is '@title', this is image @current out of @total"
> </div>
To override the default height and width of the widget, set the imageHeight and imageWidth attributes. Images are automatically scaled to fit either the max height or width, depending on which of their dimensions is greater. E.g
<div dojoType="dojox.image.SlideShow" id="slideshow1"
imageWidth="600" imageHeight="300"
> </div>
The Slideshow widget automatically preloads a number of images in the background. While this generally provides a better user experience, it uses more bandwidth, so some users may want to disable it. To do so, set the autoLoad parameter to "false". e.g.
<div dojoType="dojox.image.SlideShow" id="slideshow1"
autoLoad="false"
> </div>
This causes a delay when the user attempts to view an image, since it must wait to be loaded.
By default, if an image is less tall than the Slideshow widget, the widget resizes itself to fit to the image. In some circumstances this may be undesireable, such as when using an inflexible, fixed page layout. To disable this resizing behaviour, set the fixedHeight attribute to "true", e.g.
<div dojoType="dojox.image.SlideShow" id="slideshow1"
fixedHeight="true"
> </div>
The Slideshow widget reads the image information from dojo.data objects. To set the data source for the Slideshow widget, first create one of the available data stores, such as the dojo.data.ItemFileReadStore or dojox.data.FlickrRestStore. Next, create a request object, which optionally contains a query. e.g.
<div dojoType="dojox.image.SlideShow" id="slideshow1" > </div>
<div jsId="imageItemStore" dojoType="dojo.data.ItemFileReadStore" url="images.json"></div>
<script type="text/javascript">
dojo.addOnLoad(function() {
//Define the request, saying that 20 records should be fetched at a time,
//and to start at record 0
var request= {count:20, start:0};
//Tell the widget to request the "large" parameter, as different
//stores may use different parameter names
var itemNameMap = {imageLargeAttr: "large"};
//Call the setDataStore function, passing it the data store, the request object,
//and the name map.
dijit.byId('slideshow1').setDataStore(imageItemStore, request, itemNameMap);
});
</script>
The Slideshow publishes information about its state, that can be subscribed to using Dojo's Publish/Subscribe system. Two pieces of information are published to a named topic:
dojo.subscribe(
dijit.byId('slideshow1').getShowTopicName(),
function(packet) {
alert("Got index: " + packet.index
+ ", url: " + packet.url
+ ", and title: " + packet.title);
});
dojo.subscribe(
dijit.byId('slideshow1').getLoadTopicName(),
function(index) {
alert("Got index: " +index);
});