| 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</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" data-dojo-config="isDebug:true, parseOnLoad: false"></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.ThumbnailPicker"); |
| 26 |
dojo.require("dojox.data.FlickrRestStore"); |
| 27 |
dojo.require("dojo.data.ItemFileReadStore"); |
| 28 |
dojo.require("dojo.parser"); |
| 29 |
|
| 30 |
/* |
| 31 |
Initializes the ThumbnailPicker with a data store that |
| 32 |
reads from the Flickr REST APIs. |
| 33 |
*/ |
| 34 |
function initFlickrGallery() { |
| 35 |
var flickrRestStore = new dojox.data.FlickrRestStore(); |
| 36 |
var req = { |
| 37 |
query: { |
| 38 |
userid: "44153025@N00",//The Flickr user id to use |
| 39 |
apikey: "8c6803164dbc395fb7131c9d54843627",//An API key is required. |
| 40 |
sort: [ |
| 41 |
{ |
| 42 |
descending: true //Use descending sort order, ascending is default. |
| 43 |
} |
| 44 |
], |
| 45 |
tags: ["superhorse", "redbones", "beachvolleyball","dublin","croatia"], |
| 46 |
tag_mode: "any" //Match any of the tags |
| 47 |
}, |
| 48 |
count: 20 |
| 49 |
}; |
| 50 |
|
| 51 |
//Set the flickr data store on two of the dojox.image.ThumbnailPicker widgets |
| 52 |
dijit.byId('thumbPicker1').setDataStore(flickrRestStore, req); |
| 53 |
dijit.byId('thumbPicker3').setDataStore(flickrRestStore, req); |
| 54 |
} |
| 55 |
|
| 56 |
/* |
| 57 |
Initializes the second ThumbnailPicker widget with a data store that |
| 58 |
reads information from a JSON URL. This also tells the ThumbnailPicker |
| 59 |
the name of the JSON attributes to read from each data item retrieved |
| 60 |
from the JSON URL. |
| 61 |
*/ |
| 62 |
function initItemStoreGallery(){ |
| 63 |
var itemRequest = { |
| 64 |
query: {}, |
| 65 |
count: 20 |
| 66 |
}; |
| 67 |
var itemNameMap = { |
| 68 |
imageThumbAttr: "thumb", |
| 69 |
imageLargeAttr: "large" |
| 70 |
}; |
| 71 |
|
| 72 |
//Set the dojo.data.ItemFileReadStore on two of the dojox.image.ThumbnailPicker widgets |
| 73 |
//Note the use of the 'itemNameMap', which tells the widget what attributes to |
| 74 |
//read from the store. Look in the 'images.json' file in the same folder as this |
| 75 |
//file to see the data being read by the widget. |
| 76 |
dijit.byId('thumbPicker2').setDataStore(imageItemStore, itemRequest, itemNameMap); |
| 77 |
dijit.byId('thumbPicker4').setDataStore(imageItemStore, itemRequest, itemNameMap); |
| 78 |
} |
| 79 |
|
| 80 |
//Subscribe to clicks on the thumbnails, and print out the information provided |
| 81 |
function doSubscribe(){ |
| 82 |
function updateDiv(packet){ |
| 83 |
dojo.byId('PublishedData').innerHTML = "You selected the thumbnail:" |
| 84 |
+ "<br/><b>Index:</b> " + packet.index |
| 85 |
+ "<br/><b>Url:</b> " + packet.url |
| 86 |
+ "<br/><b>Large Url:</b> " + packet.largeUrl |
| 87 |
+ "<br/><b>Title:</b> " + packet.title |
| 88 |
+ "<br/><b>Link:</b> " + packet.link |
| 89 |
; |
| 90 |
}; |
| 91 |
|
| 92 |
//When an image in the ThumbnailPicker is clicked on, it publishes |
| 93 |
//information on the image to a topic, whose name is found by calling |
| 94 |
//the 'getTopicName' function on the widget. |
| 95 |
dojo.subscribe(dijit.byId('thumbPicker1').getClickTopicName(), updateDiv); |
| 96 |
dojo.subscribe(dijit.byId('thumbPicker2').getClickTopicName(), updateDiv); |
| 97 |
} |
| 98 |
|
| 99 |
dojo.addOnLoad(function(){ |
| 100 |
dojo.parser.parse(); |
| 101 |
initFlickrGallery(); |
| 102 |
initItemStoreGallery(); |
| 103 |
doSubscribe(); |
| 104 |
}); |
| 105 |
|
| 106 |
function changeStore(){ |
| 107 |
var flickrRestStore = new dojox.data.FlickrRestStore(); |
| 108 |
var req = { |
| 109 |
query: { |
| 110 |
userid: "44153025@N00", |
| 111 |
apikey: "8c6803164dbc395fb7131c9d54843627", |
| 112 |
sort: [ |
| 113 |
{ |
| 114 |
attribute: "interestingness", |
| 115 |
descending: true |
| 116 |
} |
| 117 |
], |
| 118 |
tag_mode: "any" |
| 119 |
}, |
| 120 |
count: 20 |
| 121 |
}; |
| 122 |
dijit.byId('thumbPicker2').setDataStore(flickrRestStore, req, { |
| 123 |
imageThumbAttr: "imageUrlThumb", |
| 124 |
imageLargeAttr: "imageUrl", |
| 125 |
titleAttr: "title" |
| 126 |
|
| 127 |
}); |
| 128 |
} |
| 129 |
|
| 130 |
</script> |
| 131 |
</head> |
| 132 |
<body> |
| 133 |
<h1 class="testTitle">dojox.image.ThumbnailPicker</h1> |
| 134 |
|
| 135 |
<div id="PublishedData" style="background-color:light-grey"> |
| 136 |
When you click on a thumbnail image, it's information is placed here |
| 137 |
</div> |
| 138 |
|
| 139 |
<h2>From FlickrRestStore:</h2> |
| 140 |
This ThumbnailPicker should have 8 thumbnails, with each of them linking |
| 141 |
to a URL when clicked on. The cursor should also change when over an image. |
| 142 |
<div id="thumbPicker1" dojoType="dojox.image.ThumbnailPicker" size="500" |
| 143 |
useHyperlink="true" ></div> |
| 144 |
|
| 145 |
<h2>From ItemFileReadStore:</h2> |
| 146 |
This ThumbnailPicker should have 5 thumbnails. Clicking on a thumbnail should NOT |
| 147 |
open a URL, and the cursor should not change when over an image that is not an arrow. |
| 148 |
|
| 149 |
|
| 150 |
<button onclick="changeStore()">Change Datastore</button> |
| 151 |
<div id="thumbPicker2" dojoType="dojox.image.ThumbnailPicker" size="400" |
| 152 |
isClickable="false"></div> |
| 153 |
<div data-dojo-id="imageItemStore" dojoType="dojo.data.ItemFileReadStore" url="images.json"></div> |
| 154 |
|
| 155 |
<h2>From FlickrRestStore:</h2> |
| 156 |
This ThumbnailPicker should have 6 thumbnails, with each of them linking |
| 157 |
to a URL when clicked on. The cursor should also change when over an image. |
| 158 |
Unlike the ThumbnailPicker above, when these links are clicked on, this page |
| 159 |
changes, instead of a popup window. |
| 160 |
|
| 161 |
<div id="thumbPicker3" dojoType="dojox.image.ThumbnailPicker" size="600" |
| 162 |
useHyperLink="true" hyperlinkTarget="this"></div> |
| 163 |
|
| 164 |
<h2>From ItemFileReadStore, and vertical:</h2> |
| 165 |
This ThumbnailPicker should have 5 thumbnails. Clicking on a thumbnail should NOT |
| 166 |
open a URL, and the cursor should not change when over an image that is not an arrow. |
| 167 |
The thumbnails should also be aligned vertically. |
| 168 |
<div id="thumbPicker4" dojoType="dojox.image.ThumbnailPicker" size="300" |
| 169 |
isClickable="false" isHorizontal="false"></div> |
| 170 |
|
| 171 |
</body> |
| 172 |
</html> |