| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> |
| 5 |
<title>Testing the ThumbnailPicker + Lightbox</title> |
| 6 |
|
| 7 |
|
| 8 |
<link rel="stylesheet" id="themeStyles" href="../../../dijit/themes/tundra/tundra.css"> |
| 9 |
<link rel="stylesheet" href="../resources/image.css"> |
| 10 |
|
| 11 |
<style type="text/css"> |
| 12 |
@import "../../../dijit/tests/css/dijitTests.css"; |
| 13 |
</style> |
| 14 |
|
| 15 |
|
| 16 |
<script type="text/javascript" src="../../../dojo/dojo.js"></script> |
| 17 |
|
| 18 |
|
| 19 |
<script type="text/javascript" src="../../../dijit/tests/_testCommon.js"></script> |
| 20 |
|
| 21 |
|
| 22 |
<script type="text/javascript" src="../ThumbnailPicker.js"></script> |
| 23 |
|
| 24 |
<script type="text/javascript"> |
| 25 |
dojo.require("dojox.image.Lightbox"); |
| 26 |
dojo.require("dojox.image.ThumbnailPicker"); |
| 27 |
dojo.require("dojo.data.ItemFileReadStore"); |
| 28 |
/* |
| 29 |
Initializes the second ThumbnailPicker widget with a data store that |
| 30 |
reads information from a JSON URL. This also tells the ThumbnailPicker |
| 31 |
the name of the JSON attributes to read from each data item retrieved |
| 32 |
from the JSON URL. |
| 33 |
*/ |
| 34 |
function initItemStoreGallery(){ |
| 35 |
var itemRequest = { |
| 36 |
query: {}, |
| 37 |
count: 20 |
| 38 |
}; |
| 39 |
var itemNameMap = { |
| 40 |
imageThumbAttr: "thumb", |
| 41 |
imageLargeAttr: "large" |
| 42 |
}; |
| 43 |
|
| 44 |
//Set the dojo.data.ItemFileReadStore on two of the dojox.image.ThumbnailPicker widgets |
| 45 |
//Note the use of the 'itemNameMap', which tells the widget what attributes to |
| 46 |
//read from the store. Look in the 'images.json' file in the same folder as this |
| 47 |
//file to see the data being read by the widget. |
| 48 |
dijit.byId('thumbPicker2').setDataStore(imageItemStore, itemRequest, itemNameMap); |
| 49 |
|
| 50 |
} |
| 51 |
|
| 52 |
//Subscribe to clicks on the thumbnails, and print out the information provided |
| 53 |
|
| 54 |
function lightboxShow(packet){ |
| 55 |
|
| 56 |
// you can just "show" this image |
| 57 |
lightbox.show({ |
| 58 |
href: packet.largeUrl, |
| 59 |
title: packet.title |
| 60 |
}); |
| 61 |
|
| 62 |
}; |
| 63 |
|
| 64 |
//When an image in the ThumbnailPicker is clicked on, it publishes |
| 65 |
//information on the image to a topic, whose name is found by calling |
| 66 |
//the 'getTopicName' function on the widget. |
| 67 |
|
| 68 |
var lightbox; |
| 69 |
dojo.addOnLoad(function(){ |
| 70 |
dojo.parser.parse(); |
| 71 |
|
| 72 |
initItemStoreGallery(); |
| 73 |
// WARNING: LightboxDialog might be the _only_ widget with "return this;" coming out of .startup() |
| 74 |
lightbox = new dojox.image.LightboxDialog().startup(); |
| 75 |
|
| 76 |
dojo.subscribe(dijit.byId('thumbPicker2').getClickTopicName(), lightboxShow); |
| 77 |
|
| 78 |
}); |
| 79 |
|
| 80 |
</script> |
| 81 |
</head> |
| 82 |
<body class="tundra"> |
| 83 |
<h1 class="testTitle">dojox.image.ThumbnailPicker + Lightbox</h1> |
| 84 |
|
| 85 |
<div id="PublishedData" style="background-color:light-grey"> |
| 86 |
</div> |
| 87 |
|
| 88 |
<h2>From ItemFileReadStore:</h2> |
| 89 |
This ThumbnailPicker should have 5 thumbnails. Clicking on a thumbnail should NOT |
| 90 |
open a URL, but rather open in a dojox.image.Lightbox. |
| 91 |
|
| 92 |
<div id="thumbPicker2" dojoType="dojox.image.ThumbnailPicker" size="400" |
| 93 |
isClickable="false"></div> |
| 94 |
<div data-dojo-id="imageItemStore" dojoType="dojo.data.ItemFileReadStore" url="images.json"></div> |
| 95 |
|
| 96 |
</body> |
| 97 |
</html> |