/public/javascripts/dojo/dojox/image/tests/test_ThumbnailPicker.html

http://enginey.googlecode.com/ · HTML · 146 lines · 120 code · 22 blank · 4 comment · 0 complexity · 9e03b6161b7af844bd0849a491892c45 MD5 · raw file

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