Debian Codegraph @

dojox/wire/demos/markup/demo_FlickrStoreWire.html

raw symbols SCIP
1 <!--
2 This file is a demo of the FlickrStore, a simple wrapper to the public feed service
3 of Flickr. This just does very basic queries against Flickr and loads the results
4 into a list viewing widget.
5 -->
6 <html>
7 <head>
8 <title>Demo of FlickrStore</title>
9 <style type="text/css">
10
11 @import "../../../../dijit/themes/tundra/tundra.css";
12 @import "../../../../dojo/resources/dojo.css";
13 @import "../../../../dijit/tests/css/dijitTests.css";
14 @import "./flickrDemo.css";
15 </style>
16
17 <script type="text/javascript" src="../../../../dojo/dojo.js" data-dojo-config="isDebug: true, parseOnLoad: true"></script>
18 <script type="text/javascript">
19 dojo.require("dojo.parser");
20 dojo.require("dijit.form.TextBox");
21 dojo.require("dijit.form.Button");
22 dojo.require("dijit.form.ComboBox");
23 dojo.require("dijit.form.NumberSpinner");
24 dojo.require("dojox.data.FlickrStore");
25 dojo.require("dojox.wire.ml.Invocation");
26 dojo.require("dojox.wire.ml.Transfer");
27 dojo.require("dojox.wire.ml.Data");
28 dojo.require("dojox.wire");
29 dojo.require("dojox.data.demos.widgets.FlickrViewList");
30
31 //Toplevel JS Object to contain a few basics for us, such as the request to pass to the store and a stub onItem and onComplete function
32 // to trap on for triggering other events.
33 var dataHolder = {
34 //Simple stub datastore request
35 request: {query: {}}
36 };
37
38 //Function to convert the input from a widget into a comma separated list.
39 //that is the format of the store parameter.
40 var tagsInputConverter = function(tags){
41 if(tags && tags !== ""){
42 var tagsArray = tags.split(" ");
43 tags = "";
44 for(var i = 0; i < tagsArray.length; i++){
45 tags = tags + tagsArray[i];
46 if(i < (tagsArray.length - 1)){
47 tags += ","
48 }
49 }
50 }
51 return tags
52 }
53 </script>
54 </head>
55
56 <body class="tundra">
57 <h1>
58 DEMO: FlickrStore Search
59 </h1>
60 <hr>
61 <h3>
62 Description:
63 </h3>
64 <p>
65 This simple demo shows how services, such as Flickr, can be wrapped by the datastore API. In this demo, you can search public
66 Flickr images through a simple FlickrStore by specifying a series of tags (separated by spaces) to search on. The results
67 will be displayed below the search box. This demo is the same as the example demo provided in dojox/data/demos/demo_FlickrStore.html,
68 except that all the interactions are implemented via Wire instead of a script that runs at dojo.addOnLoad().
69 </p>
70 <p>
71 For fun, search on the 3dny tag!
72 </p>
73
74 <blockquote>
75
76 <!--
77 Layout.
78 -->
79 <table>
80 <tbody>
81 <tr>
82 <td>
83 <b>Status:</b>
84 </td>
85 <td>
86 <div dojoType="dijit.form.TextBox" size="50" id="status" data-dojo-id="statusWidget" disabled="true"></div>
87 </td>
88 </tr>
89 <tr>
90 <td>
91 <b>ID:</b>
92 </td>
93 <td>
94 <div dojoType="dijit.form.TextBox" size="50" id="userid" data-dojo-id="idWidget"></div>
95 </td>
96 </tr>
97 <tr>
98 <td>
99 <b>Tags:</b>
100 </td>
101 <td>
102 <div dojoType="dijit.form.TextBox" size="50" id="tags" data-dojo-id="tagsWidget" value="3dny"></div>
103 </td>
104 </tr>
105 <tr>
106 <td>
107 <b>Tagmode:</b>
108 </td>
109 <td>
110 <select id="tagmode"
111 data-dojo-id="tagmodeWidget"
112 dojoType="dijit.form.ComboBox"
113 autocomplete="false"
114 value="any"
115 >
116 <option>any</option>
117 <option>all</option>
118 </select>
119 </td>
120 </tr>
121 <tr>
122 <td>
123 <b>Number of Pictures:</b>
124 </td>
125 <td>
126 <div
127 id="count"
128 data-dojo-id="countWidget"
129 dojoType="dijit.form.NumberSpinner"
130 value="20"
131 constraints="{min:1,max:20,places:0}"
132 ></div>
133 </td>
134 </tr>
135 <tr>
136 <td>
137 </td>
138 <td>
139 <div dojoType="dijit.form.Button" label="Search" id="searchButton" data-dojo-id="searchButtonWidget"></div>
140 </td>
141 </tr>
142 </tbody>
143 </table>
144 </blockquote>
145 <!--
146 The store instance used by this demo.
147 -->
148 <div dojoType="dojox.data.FlickrStore" data-dojo-id="flickrStore" label="title"></div>
149 <div dojoType="dojox.data.demos.widgets.FlickrViewList" store="flickrStore" id="flickrViews" data-dojo-id="flickrViewsWidget"></div>
150
151 <!-------------------------------- Using dojox.wire, declaratively wire up the widgets. --------------------------->
152
153 <!--
154 This is an example of using the declarative data value definition.
155 These are effectively declarative variables to act as placeholders
156 for data values.
157 -->
158 <div dojoType="dojox.wire.ml.Data"
159 id="messageData"
160 data-dojo-id="messageData">
161 <div dojoType="dojox.wire.ml.DataProperty"
162 name="processingStart"
163 value="PROCESSING REQUEST">
164 </div>
165 <div dojoType="dojox.wire.ml.DataProperty"
166 name="processingDone"
167 value="PROCESSING COMPLETE">
168 </div>
169 </div>
170
171
172 <!--
173 When the search button is clicked, do the following in order:
174 1.) Map the widget values over to the request properties.
175 2.) Set the status to processing
176 3.) Invoke the fetch on the FLickrList to repopulate the table.
177 -->
178 <div dojoType="dojox.wire.ml.Action"
179 trigger="searchButtonWidget"
180 triggerEvent="onClick">
181
182 <!--
183 Read in the values from the widgets and bind them to the appropriate data locations
184 The Transfer tag looks for a getter property before using direct access, so it calls
185 getValue() to get the data from the widget, which works well for the dijit.form.* widgets.
186 -->
187 <div dojoType="dojox.wire.ml.Transfer"
188 source="idWidget.value"
189 target="dataHolder.request.query.id">
190 </div>
191
192 <!--
193 For the tags, we need to get the value and then perform a conversion on the result
194 This is done by doing a transfer through a converter.
195 -->
196 <div dojoType="dojox.wire.ml.Transfer"
197 source="tagsWidget.value"
198 target="dataHolder.request.query.tags"
199 converter="tagsInputConverter">
200 </div>
201
202 <div dojoType="dojox.wire.ml.Transfer"
203 source="tagmodeWidget.value"
204 target="dataHolder.request.query.tagmode">
205 </div>
206
207 <div dojoType="dojox.wire.ml.Transfer"
208 source="countWidget.value"
209 target="dataHolder.request.count">
210 </div>
211
212 <!-- Now invoke the actions in order. -->
213 <div dojoType="dojox.wire.ml.Transfer" target="statusWidget.value" source="messageData.processingStart"></div>
214 <div dojoType="dojox.wire.ml.Invocation" object="flickrViewsWidget" method="fetch" parameters="dataHolder.request"></div>
215 </div>
216
217 <!--
218 When the fetch processing finishes (onComplete is called), then set status to complete.
219 -->
220 <div dojoType="dojox.wire.ml.Action"
221 trigger="flickrViewsWidget"
222 triggerEvent="onComplete">
223 <div dojoType="dojox.wire.ml.Transfer" target="statusWidget.value" source="messageData.processingDone"></div>
224 </div>
225
226 </body>
227 </html>