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