Debian Codegraph @

dojox/mvc/tests/1.7/doh/doh_async_mvc_mobile-demo.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>DOH Async MVC Mobile Demo Test</title>
6 <link rel="stylesheet" type="text/css" href="./mobile/demo/demo.css"/>
7 <style>
8
9 html, body{
10 height: 100%;
11 overflow: hidden;
12 position: relative;
13 }
14 .mblEdgeToEdgeList {
15 background-color: #DBDDE2;
16 }
17 </style>
18 <script type="text/javascript" djConfig="parseOnLoad:0,isDebug:1,async:1" src="../../../../../dojo/dojo.js"></script>
19
20 <script type="text/javascript">
21 var repeatModel, setRef, nextIndexToAdd, selectedIndex;
22 var setRef, setDetailsContext, insertResult, updateView, updateModel;
23
24 require([
25 'dojox/mobile/parser',
26 'dojox/mvc',
27 'dojox/mobile',
28 'dojox/mobile/ScrollableView',
29 'dojox/mobile/Button',
30 'dojox/mobile/TextArea',
31 'dojox/mvc/Group',
32 'dojox/mvc/Generate',
33 'dojox/mvc/Repeat',
34 'dojox/mobile/TextBox',
35 'dojox/mobile/ViewController',
36 'dojox/mobile/FixedSplitter',
37 'dojox/mobile/EdgeToEdgeList',
38 'dojox/mobile/EdgeToEdgeCategory',
39 'dojox/mobile/deviceTheme',
40 'dojox/mobile/RoundRectCategory',
41 'dojox/mobile/Heading',
42 'dojo/data/ItemFileWriteStore',
43 'dojo/store/DataStore'
44 ], function(){
45 require([
46 "dojox/mobile/compat"
47 ]);
48
49 var names = {
50 "Serial" : "360324",
51 "First" : "John",
52 "Last" : "Doe",
53 "Email" : "[email protected]",
54 "ShipTo" : {
55 "Street" : "123 Valley Rd",
56 "City" : "Katonah",
57 "State" : "NY",
58 "Zip" : "10536"
59 },
60 "BillTo" : {
61 "Street" : "17 Skyline Dr",
62 "City" : "Hawthorne",
63 "State" : "NY",
64 "Zip" : "10532"
65 }
66 };
67
68 selectedIndex = 0;
69
70 model = dojox.mvc.newStatefulModel({ data : names });
71 repeatmodel = null; // use store for repeat data
72 nextIndexToAdd = -1;
73
74 // used in the Ship to - Bill to demo
75 setRef = function(id, addrRef) {
76 var widget = dijit.byId(id);
77 widget.set("ref", addrRef);
78 }
79
80 // used in the Repeat Data binding demo
81 setDetailsContext = function(index){
82 selectedIndex = index;
83 var groupRoot = dijit.byId("detailsGroup");
84 groupRoot.set("ref", index);
85 }
86
87 // used in the Repeat Data binding demo
88 insertResult = function(index){
89 if (repeatmodel[index-1].First.value !== ""){ // TODO: figure out why we are getting called twice for each click
90 var insert = dojox.mvc.newStatefulModel({ "data" : {
91 "First" : "",
92 "Last" : "",
93 "Location": "CA",
94 "Office" : "",
95 "Email" : "",
96 "Tel" : "",
97 "Fax" : ""}
98 });
99 repeatmodel.add(index, insert);
100 setDetailsContext(index);
101 nextIndexToAdd++;
102 }else{
103 setDetailsContext(index-1);
104 }
105 };
106
107 // used in the Generate View demo
108 var genmodel;
109 updateView = function() {
110 try {
111 var modeldata = dojo.fromJson(dojo.byId("modelArea").value);
112 genmodel = dojox.mvc.newStatefulModel({ data : modeldata });
113 dijit.byId("view").set("ref", genmodel);
114 dojo.byId("outerModelArea").style.display = "none";
115 dojo.byId("viewArea").style.display = "";
116 }catch(err){
117 console.error("Error parsing json from model: "+err);
118 }
119 };
120
121 // used in the Generate View demo
122 updateModel = function() {
123 dojo.byId("outerModelArea").style.display = "";
124 try {
125 dojo.byId("modelArea").focus(); // hack: do this to force focus off of the textbox, bug on mobile?
126 dojo.byId("viewArea").style.display = "none";
127 dijit.byId("modelArea").set("value",(dojo.toJson(genmodel.toPlainObject(), true)));
128 } catch(e) {
129 console.log(e);
130 };
131 };
132
133
134 // The dojox.mvc.StatefulModel class creates a data model instance
135 // where each leaf within the data model is decorated with dojo.Stateful
136 // properties that widgets can bind to and watch for their changes.
137 var writeStore = new dojo.data.ItemFileWriteStore({url: dojo.moduleUrl("dojox.mvc.tests.1.7/_data", "mvcRepeatData.json")});
138 var modelPromise = dojox.mvc.newStatefulModel({store: new dojo.store.DataStore({store: writeStore}), query:{"Location" : "CA"}}); // example of using a query parm for Location
139
140 require([
141 'doh/runner', 'dijit/dijit'
142 ], function(){
143 require([
144 'dojo/domReady!'
145 ], function(){
146 modelPromise.then(function(results){
147 repeatmodel = results;
148 nextIndexToAdd = repeatmodel.data.length;
149 console.log("before call to parser.parse");
150 dojox.mobile.parser.parse();
151 console.log("before call to set the wholepage style for display");
152 dojo.byId("wholepage").style.display = "";
153 console.log("after call to set the wholepage style for display");
154 doh.register("check initial display", [{
155 name : "initial",
156 runTest : function() {
157 var x = dojo.query(".mblListItemLabel");
158 var y0 = dojo.query(".mblListItemLabel", dijit.byId("sdb").domNode)[0].innerHTML;
159 var y1 = dojo.query(".mblListItemLabel", dijit.byId("rdb").domNode)[0];
160 var y2 = dojo.query(".mblListItemLabel", dijit.byId("sfg").domNode)[0];
161 console.debug("dijit.byId(sdb).domNode)[0].innerHTML is ["+y0+"]");
162 doh.is("Simple Data Binding", dojo.trim(dojo.query(".mblListItemLabel", dijit.byId("sdb").domNode)[0].innerHTML),"first one should be Simple Data Binding");
163 doh.is("Repeat Data Binding", dojo.trim(dojo.query(".mblListItemLabel", dijit.byId("rdb").domNode)[0].innerHTML),"first one should be Simple Data Binding");
164 doh.is("Simple Form Generate", dojo.trim(dojo.query(".mblListItemLabel", dijit.byId("sfg").domNode)[0].innerHTML),"first one should be Simple Data Binding");
165 }
166 }]);
167 doh.run();
168 });
169 });
170 });
171
172 dojo.addOnLoad(function() {
173 });
174
175 }); // end function
176 </script>
177 </head>
178 <body>
179 <div id="wholepage" style="display:none">
180 <div id="foo" dojoType="dojox.mobile.View" selected="true">
181 <h1 dojoType="dojox.mobile.Heading">Mobile MVC Demo</h1>
182 <h2 dojoType="dojox.mobile.RoundRectCategory">Mobile MVC Views</h2>
183 <ul dojoType="dojox.mobile.RoundRectList">
184 <li id="sdb" dojoType="dojox.mobile.ListItem" icon="mobile/demo/images/i-icon-1.png" transition="slide" moveTo="settings">
185 Simple Data Binding
186 </li>
187 <li id="rdb" dojoType="dojox.mobile.ListItem" icon="mobile/demo/images/i-icon-2.png" transition="slide" moveTo="repeat">
188 Repeat Data Binding
189 </li>
190 <li id="sfg" dojoType="dojox.mobile.ListItem" icon="mobile/demo/images/i-icon-3.png" transition="slide" moveTo="generate">
191 Simple Form Generate
192 </li>
193 </ul>
194 </div>
195
196 <div id="settings" dojoType="dojox.mobile.ScrollableView">
197 <h1 id="home" dojoType="dojox.mobile.Heading" back="Home" moveTo="foo">Data Binding Example</h1>
198 <form name="testForm" id="testForm">
199 <div class="field-title">Ship to - Bill to Address</div>
200 <div class="fieldset" dojoType="dojox.mvc.Group" ref="model">
201 <div class="field-row">
202 <span>Order #</span>
203 <input id="lastnameInput" dojoType="dojox.mobile.TextBox"
204 placeholder="Order #" ref="'rel:Serial'"/>
205 </div>
206 <div class="field-row">
207 <span>Last</span>
208 <input id="serialInput" dojoType="dojox.mobile.TextBox"
209 placeholder="Last" ref="'rel:Last'"/>
210 </div>
211 <div class="field-row">
212 <span>Email</span>
213 <input id="emailInput1" dojoType="dojox.mobile.TextBox"
214 placeholder="Last" ref="'rel:Email'"/>
215 </div>
216 </div>
217 <div class="spacer"></div>
218 <button id="shipto" type="button" dojoType="dojox.mobile.Button" class="mblBlueButton" onclick="setRef('addrGroup', model.ShipTo)">Ship To</button>
219 <button id="billto" type="button" dojoType="dojox.mobile.Button" class="mblBlueButton" onclick="setRef('addrGroup', model.BillTo)">Bill To</button>
220 <br/>
221 <div class="fieldset" id="addrGroup" dojoType="dojox.mvc.Group" ref="model.ShipTo">
222 <div class="field-row">
223 <span>Street</span>
224 <input id="streetInput" dojoType="dojox.mobile.TextBox"
225 placeholder="Street" ref="'rel:Street'"/>
226 </div>
227 <div class="field-row">
228 <span>City</span>
229 <input id="cityInput" dojoType="dojox.mobile.TextBox"
230 placeholder="City" ref="'rel:City'"/>
231 </div>
232 <div class="field-row">
233 <span>State</span>
234 <input id="stateInput" dojoType="dojox.mobile.TextBox"
235 placeholder="State" ref="'rel:State'"/>
236 </div>
237 <div class="field-row">
238 <span>ZIP Code</span>
239 <input id="zipInput" dojoType="dojox.mobile.TextBox"
240 placeholder="ZIP Code" ref="'rel:Zip'"/>
241 </div>
242 </div>
243 <div class="spacer"></div>
244 <button id="reset1" type="button" dojoType="dojox.mobile.Button" class="mblBlueButton" onclick="model.reset()">Reset</button>
245 </form>
246 </div>
247
248 <div id="repeat" dojoType="dojox.mobile.ScrollableView">
249 <h1 dojoType="dojox.mobile.Heading" back="Home" moveTo="foo">Repeat Data Binding Example</h1>
250 <form name="repeatTestForm" id="repeatTestForm">
251 <div class="field-title">Search Results</div>
252 <div class="fieldset" dojoType="dojox.mvc.Repeat" class="row" ref="repeatmodel">
253 <div dojoType="dojox.mvc.Group" ref="'rel:${this.index}'">
254 <div class="row">
255 <input dojoType="dojox.mobile.TextBox"
256 id="nameInput${this.index}" ref="'rel:First'" placeHolder="First Name"/>
257 <button id="details${this.index}" type="button" dojoType="dojox.mobile.Button" class="mblBlueButton" onclick="setDetailsContext('${this.index}')">Details</button>
258 </div>
259 </div>
260 </div>
261 <div class="spacer"></div>
262 <div dojoType="dojox.mvc.Group" ref="repeatmodel">
263 <div id="detailsBanner">Details for selected index:</div>
264 <div class="fieldset" id="detailsGroup" dojoType="dojox.mvc.Group" ref="'rel:0'">
265 <div class="field-row">
266 <span>First Name</span>
267 <input id="firstInput" dojoType="dojox.mobile.TextBox"
268 placeholder="First Name" ref="'rel:First'"/>
269 </div>
270 <div class="field-row">
271 <span>Last Name</span>
272 <input id="lastInput" dojoType="dojox.mobile.TextBox"
273 placeholder="Last Name" ref="'rel:Last'"/>
274 </div>
275 <div class="field-row">
276 <span>Email</span>
277 <input id="emailInput2" dojoType="dojox.mobile.TextBox"
278 placeholder="Email" ref="'rel:Email'"/>
279 </div>
280 <div class="field-row">
281 <span>Telephone</span>
282 <input id="telInput" dojoType="dojox.mobile.TextBox"
283 placeholder="Telephone" ref="'rel:Tel'"/>
284 </div>
285 </div>
286 </div>
287 <div class="spacer"></div>
288 <button id="add" type="button" dojoType="dojox.mobile.Button" class="mblBlueButton" onclick="insertResult(nextIndexToAdd)">Add</button>
289 <button id="save" type="button" dojoType="dojox.mobile.Button" class="mblBlueButton" onclick="console.log(repeatmodel[selectedIndex].toPlainObject());repeatmodel[selectedIndex].commit()">Save</button>
290 <button id="reset2" type="button" dojoType="dojox.mobile.Button" class="mblBlueButton" onclick="repeatmodel.reset()">Reset</button>
291 </form>
292
293 </div>
294
295 <div id="generate" data-dojo-type="dojox.mobile.ScrollableView">
296 <h1 data-dojo-type="dojox.mobile.Heading" back="Home" moveTo="foo">Simple Form Generate Example</h1>
297 <div class="field-title"></div>
298 <div id="main">
299 <div id="leftNav"></div>
300 <div id="mainContent" class="generate-maincontent">
301 <div id="outerModelArea">
302 <h3 data-dojo-type="dojox.mobile.RoundRectCategory">Model</h3>
303 <div class="generate-textarea-row">
304 <textarea class="generate-textarea-cell" data-dojo-type="dojox.mobile.TextArea" id="modelArea">
305 {
306 "Serial": "11111",
307 "First": "John",
308 "Last": "Doe",
309 "Email": "[email protected]",
310 "Phones": [
311 {
312 "Office": "111-111-1111"
313 },
314 {
315 "Mobile": "222-222-2222"
316 }
317 ]
318 }
319 </textarea>
320 </div>
321 <div class="fieldset">
322 <div class="spacer"></div>
323 <button id="generate1" type="button" data-dojo-type="dojox.mobile.Button" class="mblBlueButton" onclick="updateView()">Generate Form</button>
324 </div>
325 </div>
326 <div id="viewArea" style="display:none">
327 <h3 data-dojo-type="dojox.mobile.RoundRectCategory">Generated View</h3>
328 <div class="fieldset">
329 <div id="view" data-dojo-type="dojox.mvc.Generate" data-dojo-props="widgetMapping:{'String' : 'dojox.mobile.TextBox'}, idNameMapping:{'String' : 'TB'}"></div>
330 </div>
331 <div class="fieldset">
332 <div class="spacer"></div>
333 <button id="updateModel" type="button" data-dojo-type="dojox.mobile.Button" class="mblBlueButton" onclick="updateModel()">Update Model</button>
334 </div>
335 </div>
336 </div>
337 </div>
338 </div>
339 </div>
340 </body>
341
342 </html>