Debian Codegraph @

dojox/mvc/tests/doh/WidgetList_tests/doh_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 MVC Mobile Demo Test</title>
6 <link rel="stylesheet" type="text/css" href="../../1.7/mobile/demo/demo.css"/>
7 <style>
8 html, body{
9 height: 100%;
10 overflow: hidden;
11 position: relative;
12 }
13 .mblEdgeToEdgeList {
14 background-color: #DBDDE2;
15 }
16 </style>
17 <script type="text/javascript" data-dojo-config="parseOnLoad:0,isDebug:1,async:1, mvc: {debugBindings: 1}" src="../../../../../dojo/dojo.js"></script>
18 <script type="text/javascript">
19 var ctrl, listCtrl;
20 var updateView, updateModel;
21
22 require([
23 "doh/runner",
24 "dojo/_base/declare",
25 "dojo/_base/json",
26 "dojo/when",
27 "dojo/dom",
28 "dojo/store/JsonRest",
29 "dojo/store/Memory",
30 "dojox/mvc/at",
31 "dijit/registry",
32 "dojox/mobile/parser",
33 "dojox/mvc/getPlainValue",
34 "dojox/mvc/getStateful",
35 "dojox/mvc/EditModelRefController",
36 "dojox/mvc/ListController",
37 "dojox/mvc/StoreRefController",
38 "dojox/mobile",
39 "dojox/mobile/compat",
40 "dojox/mobile/ScrollableView",
41 "dojox/mobile/Button",
42 "dojox/mobile/TextArea",
43 "dojox/mobile/TextBox",
44 "dojox/mobile/ViewController",
45 "dojox/mobile/FixedSplitter",
46 "dojox/mobile/EdgeToEdgeList",
47 "dojox/mobile/EdgeToEdgeCategory",
48 "dojox/mobile/deviceTheme",
49 "dojox/mobile/RoundRectCategory",
50 "dojox/mobile/Heading",
51 "dojox/mvc/Group",
52 "dojox/mvc/Generate",
53 "dojox/mvc/WidgetList",
54 "dojox/mvc/_InlineTemplateMixin",
55 "dojo/domReady!"
56 ], function(doh, declare, djson, when, ddom, JsonRest, Memory, at, registry, parser, getPlainValue, getStateful, EditModelRefController, ListController, StoreRefController){
57 window.at = at;
58
59 ctrlClass = declare([EditModelRefController, ListController], {});
60 ctrl = new ctrlClass({sourceModel: getStateful({
61 Serial: "360324",
62 First: "John",
63 Last: "Doe",
64 Email: "[email protected]",
65 ShipTo: {
66 Street: "123 Valley Rd",
67 City: "Katonah",
68 State: "NY",
69 Zip: "10536"
70 },
71 BillTo: {
72 Street: "17 Skyline Dr",
73 City: "Hawthorne",
74 State: "NY",
75 Zip: "10532"
76 }
77 })});
78 ctrl.set("cursorIndex", "ShipTo");
79
80 // used in the Generate View demo
81 var genmodel;
82 updateView = function() {
83 try {
84 genmodel = getStateful(djson.fromJson(ddom.byId("modelArea").value));
85 registry.byId("view").set("children", genmodel);
86 ddom.byId("outerModelArea").style.display = "none";
87 ddom.byId("viewArea").style.display = "";
88 }catch(err){
89 console.error("Error parsing json from model: "+err);
90 }
91 };
92
93 // used in the Generate View demo
94 updateModel = function() {
95 ddom.byId("outerModelArea").style.display = "";
96 try {
97 ddom.byId("modelArea").focus(); // hack: do this to force focus off of the textbox, bug on mobile?
98 ddom.byId("viewArea").style.display = "none";
99 registry.byId("modelArea").set("value", djson.toJson(getPlainValue(genmodel), true));
100 } catch(e) {
101 console.log(e);
102 };
103 };
104
105 var listCtrlClass = declare([StoreRefController, EditModelRefController, ListController], {
106 addEmpty: function(){
107 var modelToInsert = getStateful({
108 First: "",
109 Last: "",
110 Location: "CA",
111 Office: "",
112 Email: "",
113 Tel: "",
114 Fax: ""
115 });
116 this.model.push(modelToInsert);
117 this.set("cursor", modelToInsert);
118 }
119 });
120
121 listCtrl = new listCtrlClass({cursorIndex: 0});
122
123 parser.parse();
124 ddom.byId("wholepage").style.display = "";
125
126 when((new JsonRest({target: require.toUrl("dojox/mvc/tests/_data/mvcRepeatData.json")})).query({}), function(results){
127 listCtrl.set("store", new Memory({data: results.items}));
128 when(listCtrl.queryStore({Location: "CA"}), function(results){
129 doh.register("Ship to - Bill to Address page", [{
130 name: "Initial",
131 runTest: function(){
132 registry.byId("settings").show();
133 doh.is("360324", registry.byId("serialInput").get("value"), "Order# should be set");
134 doh.is("123 Valley Rd", registry.byId("streetInput").get("value"), "Street should be set of Ship To");
135 }
136 }, {
137 name: "TestBillTo",
138 runTest : function(){
139 ctrl.set("cursorIndex", "BillTo");
140 doh.is("17 Skyline Dr", registry.byId("streetInput").get("value"), "Street should be set of Bill To");
141 }
142 }, {
143 name: "TestReset",
144 runTest: function(){
145 var addr1 = registry.byId("streetInput");
146 addr1.set("value", "Foo");
147 doh.is("Foo", ctrl.get("Street"), "Street should be Foo");
148 ctrl.reset();
149 doh.is("17 Skyline Dr", addr1.get("value"), "Street should be set back to of Bill To");
150 }
151 }]);
152
153 doh.register("Repeat Data Binding Example page", [{
154 name: "Initial",
155 runTest: function(){
156 registry.byId("repeat").show();
157 doh.is("Chad", registry.byId("nameInput0").get("value"), "nameInput0 should be Chad");
158 doh.is("Hunter", registry.byId("nameInput1").get("value"), "nameInput1 should be Hunter");
159 doh.is("John", registry.byId("nameInput2").get("value"), "nameInput2 should be John");
160 }
161 }, {
162 name: "ChangeCursor",
163 runTest: function(){
164 listCtrl.set("cursorIndex", 1);
165 doh.is("Hunter", registry.byId("firstnameInputDetail").get("value"), "firstnameInputDetail should be Hunter");
166 }
167 }, {
168 name : "ResetAll",
169 runTest : function(){
170 var first = registry.byId("firstnameInputDetail");
171 first.set("value", "Foo");
172 doh.is("Foo", listCtrl.get("First"), "First should be Foo");
173 listCtrl.reset();
174 doh.is("Hunter", registry.byId("firstnameInputDetail").get("value"), "firstnameInputDetail should be Hunter");
175 }
176 }]);
177
178 doh.register("Simple Form Generate Example page", [{
179 name: "Initial",
180 runTest: function(){
181 registry.byId("generate").show();
182 updateView();
183 var tb0 = registry.byId("TB0");
184 doh.is("11111", tb0 && tb0.get("value"), "Serial should be 11111");
185 var tb6 = registry.byId("TB6");
186 doh.is("111-111-1111", tb6 && tb6.get("value"), "Office should be 111-111-1111");
187 tb6.set("value", "333-333-3333");
188 updateModel();
189 doh.t(ddom.byId("modelArea").value.indexOf("\"Office\": \"333-333-3333\""), "Model should be updated with newer Office phone number");
190 }
191 }]);
192
193 doh.run();
194 });
195 });
196 }); // end function
197 </script>
198 </head>
199 <body>
200 <div id="wholepage" style="display:none">
201 <div id="foo" data-dojo-type="dojox.mobile.View" selected="true">
202 <h1 data-dojo-type="dojox.mobile.Heading">Mobile MVC Demo</h1>
203 <h2 data-dojo-type="dojox.mobile.RoundRectCategory">Mobile MVC Views</h2>
204 <ul data-dojo-type="dojox.mobile.RoundRectList">
205 <li id="sdb" data-dojo-type="dojox.mobile.ListItem" icon="../../1.7/mobile/demo/images/i-icon-1.png" transition="slide" moveTo="settings">
206 Simple Data Binding
207 </li>
208 <li id="rdb" data-dojo-type="dojox.mobile.ListItem" icon="../../1.7/mobile/demo/images/i-icon-2.png" transition="slide" moveTo="repeat">
209 Repeat Data Binding
210 </li>
211 <li id="sfg" data-dojo-type="dojox.mobile.ListItem" icon="../../1.7/mobile/demo/images/i-icon-3.png" transition="slide" moveTo="generate">
212 Simple Form Generate
213 </li>
214 </ul>
215 </div>
216 <div id="settings" data-dojo-type="dojox.mobile.ScrollableView">
217 <h1 id="home" data-dojo-type="dojox.mobile.Heading" back="Home" moveTo="foo">Data Binding Example</h1>
218 <form name="testForm" id="testForm">
219 <div class="field-title">Ship to - Bill to Address</div>
220 <div class="fieldset" data-dojo-type="dojox.mvc.Group" data-dojo-props="target: at(ctrl, 'model')">
221 <div class="field-row">
222 <span>Order #</span>
223 <input id="serialInput" placeholder="Order #" data-dojo-type="dojox.mobile.TextBox" data-dojo-props="value: at('rel:', 'Serial')" />
224 </div>
225 <div class="field-row">
226 <span>Last</span>
227 <input placeholder="Last" data-dojo-type="dojox.mobile.TextBox" data-dojo-props="value: at('rel:', 'Last')" />
228 </div>
229 <div class="field-row">
230 <span>Email</span>
231 <input placeholder="Last" data-dojo-type="dojox.mobile.TextBox" data-dojo-props="value: at('rel:', 'Email')" />
232 </div>
233 </div>
234 <div class="spacer"></div>
235 <button id="shipto" type="button" data-dojo-type="dojox.mobile.Button" class="mblBlueButton" onclick="ctrl.set('cursorIndex', 'ShipTo');">Ship To</button>
236 <button id="billto" type="button" data-dojo-type="dojox.mobile.Button" class="mblBlueButton" onclick="ctrl.set('cursorIndex', 'BillTo');">Bill To</button>
237 <br/>
238 <div class="fieldset" id="addrGroup" data-dojo-type="dojox.mvc.Group" data-dojo-props="target: at(ctrl, 'cursor')">
239 <div class="field-row">
240 <span>Street</span>
241 <input id="streetInput" placeholder="Street" data-dojo-type="dojox.mobile.TextBox" data-dojo-props="value: at('rel:', 'Street')" />
242 </div>
243 <div class="field-row">
244 <span>City</span>
245 <input placeholder="City" data-dojo-type="dojox.mobile.TextBox" data-dojo-props="value: at('rel:', 'City')" />
246 </div>
247 <div class="field-row">
248 <span>State</span>
249 <input placeholder="State" data-dojo-type="dojox.mobile.TextBox" data-dojo-props="value: at('rel:', 'State')" />
250 </div>
251 <div class="field-row">
252 <span>ZIP Code</span>
253 <input placeholder="ZIP Code" data-dojo-type="dojox.mobile.TextBox" data-dojo-props="value: at('rel:', 'Zip')" />
254 </div>
255 </div>
256 <div class="spacer"></div>
257 <button id="reset1" type="button" data-dojo-type="dojox.mobile.Button" class="mblBlueButton" onclick="ctrl.reset()">Reset</button>
258 </form>
259 </div>
260 <div id="repeat" data-dojo-type="dojox.mobile.ScrollableView">
261 <h1 data-dojo-type="dojox.mobile.Heading" back="Home" moveTo="foo">Repeat Data Binding Example</h1>
262 <form name="repeatTestForm" id="repeatTestForm">
263 <div class="field-title">Search Results</div>
264 <div class="fieldset" class="row"
265 data-dojo-type="dojox/mvc/WidgetList"
266 data-dojo-mixins="dojox/mvc/_InlineTemplateMixin"
267 data-dojo-props="children: at(listCtrl, 'model')">
268 <script type="dojox/mvc/InlineTemplate">
269 <div class="row">
270 <input id="nameInput${indexAtStartup}" placeHolder="First Name" data-dojo-type="dojox.mobile.TextBox" data-dojo-props="value: at('rel:', 'First')" />
271 <button id="details${indexAtStartup}" type="button" data-dojo-type="dojox.mobile.Button" class="mblBlueButton" onclick="listCtrl.set('cursorIndex', '${indexAtStartup}')">Details</button>
272 </div>
273 </script>
274 </div>
275 <div class="spacer"></div>
276 <div id="detailsBanner">Details for selected index:</div>
277 <div class="fieldset" id="detailsGroup" data-dojo-type="dojox.mvc.Group" data-dojo-props="target: at(listCtrl, 'cursor')">
278 <div class="field-row">
279 <span>First Name</span>
280 <input id="firstnameInputDetail" placeholder="First Name" data-dojo-type="dojox.mobile.TextBox" data-dojo-props="value: at('rel:', 'First')" />
281 </div>
282 <div class="field-row">
283 <span>Last Name</span>
284 <input placeholder="Last Name" data-dojo-type="dojox.mobile.TextBox" data-dojo-props="value: at('rel:', 'Last') "/>
285 </div>
286 <div class="field-row">
287 <span>Email</span>
288 <input placeholder="Email" data-dojo-type="dojox.mobile.TextBox" data-dojo-props="value: at('rel:', 'Email')" />
289 </div>
290 <div class="field-row">
291 <span>Telephone</span>
292 <input placeholder="Telephone" data-dojo-type="dojox.mobile.TextBox" data-dojo-props="value: at('rel:', 'Tel')" />
293 </div>
294 </div>
295 <div class="spacer"></div>
296 <button id="add" type="button" data-dojo-type="dojox.mobile.Button" class="mblBlueButton" onclick="listCtrl.addEmpty();">Add</button>
297 <button id="save" type="button" data-dojo-type="dojox.mobile.Button" class="mblBlueButton" onclick="listCtrl.commit();">Save</button>
298 <button id="reset2" type="button" data-dojo-type="dojox.mobile.Button" class="mblBlueButton" onclick="listCtrl.reset();">Reset</button>
299 </form>
300 </div>
301 <div id="generate" data-dojo-type="dojox.mobile.ScrollableView">
302 <h1 data-dojo-type="dojox.mobile.Heading" back="Home" moveTo="foo">Simple Form Generate Example</h1>
303 <div class="field-title"></div>
304 <div id="main">
305 <div id="leftNav"></div>
306 <div id="mainContent" class="generate-maincontent">
307 <div id="outerModelArea">
308 <h3 data-dojo-type="dojox.mobile.RoundRectCategory">Model</h3>
309 <div class="generate-textarea-row">
310 <textarea class="generate-textarea-cell" data-dojo-type="dojox.mobile.TextArea" id="modelArea">
311 {
312 "Serial": "11111",
313 "First": "John",
314 "Last": "Doe",
315 "Email": "[email protected]",
316 "Phones": [
317 {
318 "Office": "111-111-1111"
319 },
320 {
321 "Mobile": "222-222-2222"
322 }
323 ]
324 }
325 </textarea>
326 </div>
327 <div class="fieldset">
328 <div class="spacer"></div>
329 <button id="generate1" type="button" data-dojo-type="dojox.mobile.Button" class="mblBlueButton" onclick="updateView()">Generate Form</button>
330 </div>
331 </div>
332 <div id="viewArea" style="display:none">
333 <h3 data-dojo-type="dojox.mobile.RoundRectCategory">Generated View</h3>
334 <div class="fieldset">
335 <div id="view" data-dojo-type="dojox.mvc.Generate" data-dojo-props="widgetMapping: {'String': 'dojox.mobile.TextBox'}, idNameMapping: {'String' : 'TB'}"></div>
336 </div>
337 <div class="fieldset">
338 <div class="spacer"></div>
339 <button id="updateModel" type="button" data-dojo-type="dojox.mobile.Button" class="mblBlueButton" onclick="updateModel()">Update Model</button>
340 </div>
341 </div>
342 </div>
343 </div>
344 </div>
345 </div>
346 </div>
347 </body>
348 </html>