Debian Codegraph @

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

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