2c79236782ef495a7ccf8a361884f603a45a693b.svn-base 5.2 KB

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