Debian Codegraph @

dojox/mvc/tests/1.7/doh/doh_mvc_search-results-repeat.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
5 <title>MVC DOH Test</title>
6
7 <style>
8 @import "../../../../../dojo/resources/dojo.css";
9 @import "../../../../../dijit/tests/css/dijitTests.css";
10 @import "../css/app-format.css";
11 </style>
12
13 <!-- required: the default dijit theme: -->
14 <link id="themeStyles" rel="stylesheet" href="../../../../../dijit/themes/claro/claro.css"/>
15
16 <!-- required: dojo.js -->
17 <script src="../../../../../dojo/dojo.js" type="text/javascript"
18 djConfig="isDebug: true">
19 </script>
20 <script type="text/javascript" src="../helpers.js"></script>
21
22 <script type="text/javascript" >
23 dojo.require("dojox.mvc");
24 dojo.require("dojox.mvc.Group");
25 dojo.require("dojox.mvc.Repeat");
26 dojo.require("dijit.form.TextBox");
27 dojo.require("dijit.form.Button");
28 dojo.require("dojo.parser");
29
30 // Raw records for the master detail
31 var search_results_init =
32 {
33 "Query" : "Engineers",
34 "Results" : [
35 {
36 "First" : "Anne",
37 "Last" : "Ackerman",
38 "Location": "NY",
39 "Office" : "1S76",
40 "Email" : "[email protected]",
41 "Tel" : "123-764-8237",
42 "Fax" : "123-764-8228"
43 },
44 {
45 "First" : "Ben",
46 "Last" : "Beckham",
47 "Location": "NY",
48 "Office" : "5N47",
49 "Email" : "[email protected]",
50 "Tel" : "123-764-8599",
51 "Fax" : "123-764-8600"
52 },
53 {
54 "First" : "Chad",
55 "Last" : "Chapman",
56 "Location": "CA",
57 "Office" : "1278",
58 "Email" : "[email protected]",
59 "Tel" : "408-764-8237",
60 "Fax" : "408-764-8228"
61 },
62 {
63 "First" : "David",
64 "Last" : "Durham",
65 "Location": "NJ",
66 "Office" : "C12",
67 "Email" : "[email protected]",
68 "Tel" : "514-764-8237",
69 "Fax" : "514-764-8228"
70 },
71 {
72 "First" : "Emma",
73 "Last" : "Eklof",
74 "Location": "NY",
75 "Office" : "4N76",
76 "Email" : "[email protected]",
77 "Tel" : "123-764-1234",
78 "Fax" : "123-764-4321"
79 },
80 {
81 "First" : "Fred",
82 "Last" : "Fisher",
83 "Location": "NJ",
84 "Office" : "V89",
85 "Email" : "[email protected]",
86 "Tel" : "514-764-8567",
87 "Fax" : "514-764-8000"
88 },
89 {
90 "First" : "George",
91 "Last" : "Garnett",
92 "Location": "NY",
93 "Office" : "7S11",
94 "Email" : "[email protected]",
95 "Tel" : "123-999-8599",
96 "Fax" : "123-999-8600"
97 },
98 {
99 "First" : "Hunter",
100 "Last" : "Huffman",
101 "Location": "CA",
102 "Office" : "6532",
103 "Email" : "[email protected]",
104 "Tel" : "408-874-8237",
105 "Fax" : "408-874-8228"
106 },
107 {
108 "First" : "Irene",
109 "Last" : "Ira",
110 "Location": "NJ",
111 "Office" : "F09",
112 "Email" : "[email protected]",
113 "Tel" : "514-764-6532",
114 "Fax" : "514-764-7300"
115 },
116 {
117 "First" : "John",
118 "Last" : "Jacklin",
119 "Location": "CA",
120 "Office" : "6701",
121 "Email" : "[email protected]",
122 "Tel" : "408-764-1234",
123 "Fax" : "408-764-4321"
124 }
125 ]
126 };
127
128 // The dojox.mvc.StatefulModel class creates a data model instance
129 // where each leaf within the data model is decorated with dojo.Stateful
130 // properties that widgets can bind to and watch for their changes.
131 var searchRecords = dojox.mvc.newStatefulModel({ data : search_results_init });
132 </script>
133
134 <script type="text/javascript">
135 dojo.require('doh.runner');
136 dojo.require("dijit.dijit"); // optimize: load dijit layer
137 dojo.require("dojo.parser"); // scan page for widgets and instantiate them
138
139 dojo.addOnLoad(function(){
140
141 doh.register("parse", function(){
142 dojo.parser.parse();
143 });
144
145 // should be able to verify all of the inputs
146 doh.register("Check initial values and bindings", [
147 {
148 name: "initial",
149 runTest: function(){
150 var name1, bind1, firstInput;
151 name1 = dijit.byId("nameInput0");
152 if (name1) {
153 bind1 = name1.get("binding");
154 if (bind1 && bind1.isInstanceOf(dojox.mvc.StatefulModel)) {
155 doh.is("Anne",bind1.data,"bind1.data should be set");
156 doh.is("Anne",bind1.value,"bind1.value should be set");
157 }
158 }
159
160 firstInput = dijit.byId("firstInput");
161 if (firstInput) {
162 bind1 = firstInput.get("binding");
163 if (bind1 && bind1.isInstanceOf(dojox.mvc.StatefulModel)) {
164 doh.is("Anne",bind1.data,"bind1.data should be set");
165 doh.is("Anne",bind1.value,"bind1.value should be set");
166 }
167 }
168 }
169 }
170 ]);
171
172 doh.register("select Ben", [
173 {
174 name: "testBen",
175 runTest: function(){
176 setDetailsContext(1);
177 var name1, bind1, firstInput;
178 name1 = dijit.byId("nameInput1");
179 if (name1) {
180 bind1 = name1.get("binding");
181 if (bind1 && bind1.isInstanceOf(dojox.mvc.StatefulModel)) {
182 doh.is("Ben",bind1.data,"bind1.data is wrong");
183 doh.is("Ben",bind1.value,"bind1.value is wrong");
184 }
185 }
186
187 firstInput = dijit.byId("firstInput");
188 if (firstInput) {
189 bind1 = firstInput.get("binding");
190 if (bind1 && bind1.isInstanceOf(dojox.mvc.StatefulModel)) {
191 console.debug("firstInput.value="+firstInput.value);
192 doh.is("Ben",bind1.data,"firstInput bind1.data is wrong");
193 doh.is("Ben",bind1.value,"firstInput bind1.value is wrong");
194 }
195 }
196 }
197 }
198 ]);
199
200 doh.run();
201
202 });
203 </script>
204 </head>
205 <body class="claro">
206 <h1 class="testTitle">doh_mvc_search-results-repeat.html automated tests (non-robot)</h1>
207 <div id="wrapper">
208 <div id="header">
209 <div id="navigation">
210 </div>
211 <div id="headerInsert">
212 <h1>Employee Search</h1>
213 <h2>Master Detail Example - With repeat container.</h2>
214 </div>
215 </div>
216 <div id="main">
217 <div id="leftNav">
218 </div>
219 <div id="mainContent">
220 <!--
221 The group container denotes some logical grouping of widgets and also serves
222 to establish a parent data binding context for its children.
223 The ref attribute for the outermost container obtains the binding from the
224 "page scope" itself.
225 -->
226 <div data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: 'searchRecords'">
227 <div class="row">
228 <label class="cell" for="queryInput">Search for:</label>
229 <input class="cell" id="queryInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Query'"/>
230 <button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){setSearchBanner();}">Search</button>
231 </div>
232 <div class="spacer"></div>
233
234 <div id="searchBanner">Search Results for term: Engineers</div>
235
236 <!--
237 The repeat container denotes a templated UI that operates over a collection
238 of data records.
239 The UI can be customized for each iteration using properties such as
240 ${this.index} for the iteration index.
241 -->
242 <div data-dojo-type="dojox.mvc.Repeat" data-dojo-props="ref: 'Results'">
243 <div class="row" data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: '${this.index}'">
244 <label class="cell" for="nameInput${this.index}">Name:</label>
245 <input class="cell" data-dojo-type="dijit.form.TextBox" id="nameInput${this.index}" data-dojo-props="ref: 'First'"/>
246 <button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){setDetailsContext('${this.index}');}">Details</button>
247 </div>
248 </div>
249 <div class="spacer"></div>
250
251 <div data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: 'Results'">
252 <div id="detailsBanner">Details for result index: 0</div>
253
254 <div id="detailsGroup" data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: '0'">
255 <div class="row">
256 <label class="cell" for="firstInput">First Name:</label>
257 <input class="cell" id="firstInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'First'"/>
258 </div>
259 <div class="row">
260 <label class="cell" for="lastInput">Last Name:</label>
261 <input class="cell" id="lastInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Last'"/>
262 </div>
263 <div class="row">
264 <label class="cell" for="locationInput">Location:</label>
265 <input class="cell" id="locationInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Location'"/>
266 </div>
267 <div class="row">
268 <label class="cell" for="officeInput">Office:</label>
269 <input class="cell" id="officeInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Office'"/>
270 </div>
271 <div class="row">
272 <label class="cell" for="emailInput">Email:</label>
273 <input class="cell" id="emailInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Email'"/>
274 </div>
275 <div class="row">
276 <label class="cell" for="telInput">Telephone:</label>
277 <input class="cell" id="telInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Tel'"/>
278 </div>
279 <div class="row">
280 <label class="cell" for="faxInput">Fax:</label>
281 <input class="cell" id="faxInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Fax'"/>
282 </div>
283 </div>
284 </div>
285 </div>
286 </div>
287 </div>
288 <script type="text/javascript">
289 function setDetailsContext(index) {
290 var widget = dijit.byId("detailsGroup");
291 widget.set("ref", index);
292 var detailsBanner = dojo.byId("detailsBanner");
293 detailsBanner.innerHTML = "Details for result index: " + index;
294 }
295 function setSearchBanner() {
296 var searchBanner = dojo.byId("searchBanner");
297 searchBanner.innerHTML = "Search Results for term: " + searchRecords.Query.get("value");
298 }
299 </script>
300 </body>
301 </html>