Debian Codegraph @

dojox/mvc/tests/1.7/mobile/demo/src-sync.js

raw symbols SCIP
1 dojo.provide("dojox.mvc.tests.mobile.demo.src");
2
3 //dojo.require("dojo.parser"); // no longer needed for repeat demo
4 dojo.require("dojox.mobile.parser");
5 dojo.require("dojox.mobile");
6 dojo.require("dojox.mobile.ScrollableView");
7 dojo.require("dojox.mobile.TextBox");
8 dojo.require("dojox.mvc");
9 dojo.require("dojox.mvc.Generate");
10 dojo.require("dojox.mvc.Group");
11 dojo.require("dojox.mvc.Repeat");
12 dojo.require("dojox.mobile.FlippableView");
13 dojo.require("dojox.mobile.ViewController");
14 dojo.require("dojox.mobile.TextArea");
15 dojo.require("dojox.mobile.Button");
16
17 dojo.require("dojox.mobile.FixedSplitter");
18 dojo.require("dojox.mobile.EdgeToEdgeList");
19 dojo.require("dojox.mobile.EdgeToEdgeCategory");
20 dojo.require("dojox.mobile.Heading");
21 dojo.require("dojox.mobile.FixedSplitterPane");
22 dojo.requireIf(!dojo.isWebKit, "dojox.mobile.compat");
23 dojo.requireIf(!dojo.isWebKit, "dojo.fx");
24 dojo.requireIf(!dojo.isWebKit, "dojo.fx.easing");
25 dojo.require("dojox.mobile.deviceTheme"); // used for device detection
26
27
28 // Initial data for Ship to - Bill demo
29 var names = {
30 "Serial" : "360324",
31 "First" : "John",
32 "Last" : "Doe",
33 "Email" : "[email protected]",
34 "ShipTo" : {
35 "Street" : "123 Valley Rd",
36 "City" : "Katonah",
37 "State" : "NY",
38 "Zip" : "10536"
39 },
40 "BillTo" : {
41 "Street" : "17 Skyline Dr",
42 "City" : "Hawthorne",
43 "State" : "NY",
44 "Zip" : "10532"
45 }
46 };
47
48 // Initial repeat data used in the Repeat Data binding demo
49 var repeatData = [
50 {
51 "First" : "Chad",
52 "Last" : "Chapman",
53 "Location": "CA",
54 "Office" : "1278",
55 "Email" : "[email protected]",
56 "Tel" : "408-764-8237",
57 "Fax" : "408-764-8228"
58 },
59 {
60 "First" : "Irene",
61 "Last" : "Ira",
62 "Location": "NJ",
63 "Office" : "F09",
64 "Email" : "[email protected]",
65 "Tel" : "514-764-6532",
66 "Fax" : "514-764-7300"
67 },
68 {
69 "First" : "John",
70 "Last" : "Jacklin",
71 "Location": "CA",
72 "Office" : "6701",
73 "Email" : "[email protected]",
74 "Tel" : "408-764-1234",
75 "Fax" : "408-764-4321"
76 }
77 ];
78
79 var selectedIndex = 0;
80
81 var model = dojox.mvc.newStatefulModel({ data : names });
82 var repeatmodel = dojox.mvc.newStatefulModel({ data : repeatData });
83 var nextIndexToAdd = repeatmodel.data.length;
84
85 // used in the Ship to - Bill to demo
86 function setRef(id, addrRef) {
87 var widget = dijit.byId(id);
88 widget.set("ref", addrRef);
89 }
90
91 // used in the Repeat Data binding demo
92 function setDetailsContext(index){
93 selectedIndex = index;
94 var groupRoot = dijit.byId("detailsGroup");
95 groupRoot.set("ref", index);
96 }
97
98 // used in the Repeat Data binding demo
99 function insertResult(index){
100 if (repeatmodel[index-1].First.value !== ""){ // TODO: figure out why we are getting called twice for each click
101 var insert = dojox.mvc.newStatefulModel({ "data" : {
102 "First" : "",
103 "Last" : "",
104 "Location": "CA",
105 "Office" : "",
106 "Email" : "",
107 "Tel" : "",
108 "Fax" : ""}
109 });
110 repeatmodel.add(index, insert);
111 setDetailsContext(index);
112 nextIndexToAdd++;
113 }else{
114 setDetailsContext(index-1);
115 }
116 };
117
118 // used in the Generate View demo
119 var genmodel;
120 function updateView() {
121 try {
122 var modeldata = dojo.fromJson(dojo.byId("modelArea").value);
123 genmodel = dojox.mvc.newStatefulModel({ data : modeldata });
124 dijit.byId("view").set("ref", genmodel);
125 dojo.byId("outerModelArea").style.display = "none";
126 dojo.byId("viewArea").style.display = "";
127 }catch(err){
128 console.error("Error parsing json from model: "+err);
129 }
130 };
131
132 // used in the Generate View demo
133 function updateModel() {
134 dojo.byId("outerModelArea").style.display = "";
135 try {
136 dojo.byId("modelArea").focus(); // hack: do this to force focus off of the textbox, bug on mobile?
137 dojo.byId("viewArea").style.display = "none";
138 dijit.byId("modelArea").set("value",(dojo.toJson(genmodel.toPlainObject(), true)));
139 } catch(e) {
140 console.log(e);
141 };
142 };
143
144 function setup() {
145 dojox.mobile.parser.parse();
146 };
147
148 dojo.ready(setup);