Debian Codegraph @

dojox/mvc/tests/1.7/doh/doh_mvc_shipto-billto-simple.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 <style>
7 @import "../../../../../dojo/resources/dojo.css";
8 @import "../../../../../dijit/tests/css/dijitTests.css";
9 @import "../css/app-format.css";
10 </style>
11 <link id="themeStyles" rel="stylesheet" href="../../../../../dijit/themes/claro/claro.css"/>
12 <script src="../../../../../dojo/dojo.js" type="text/javascript" djConfig="isDebug: true"></script>
13 <script type="text/javascript" src="../helpers.js"></script>
14 <script type="text/javascript">
15 dojo.require("dojox.mvc");
16 dojo.require("dojox.mvc.Group");
17 dojo.require("dijit.form.TextBox");
18 dojo.require("dijit.form.Button");
19 dojo.require("dojo.parser");
20
21 // Initial data
22 var master_init = {
23 "Serial" : "360324",
24 "First" : "John",
25 "Last" : "Doe",
26 "Email" : "[email protected]",
27 "ShipTo" : {
28 "Street" : "123 Valley Rd",
29 "City" : "Katonah",
30 "State" : "NY",
31 "Zip" : "10536"
32 },
33 "BillTo" : {
34 "Street" : "17 Skyline Dr",
35 "City" : "Hawthorne",
36 "State" : "NY",
37 "Zip" : "10532"
38 }
39 };
40
41 // The dojox.mvc.StatefulModel class creates a data model instance
42 // where each leaf within the data model is decorated with dojo.Stateful
43 // properties that widgets can bind to and watch for their changes.
44 var masterRecord = dojox.mvc.newStatefulModel({ data : master_init });
45 var selectedAddr = dojox.mvc.newStatefulModel({ data : "ShipTo" });
46 </script>
47
48 <script type="text/javascript">
49 dojo.require('doh.runner');
50 dojo.require("dijit.dijit"); // optimize: load dijit layer
51 dojo.require("dojo.parser"); // scan page for widgets and instantiate them
52
53 dojo.addOnLoad(function() {
54
55 doh.register("parse", function() {
56 dojo.parser.parse();
57 });
58
59 // should be able to verify all of the inputs
60 doh.register("check initial values and bindings", [{
61 name : "initial",
62 runTest : function() {
63 var serial1, bind1, addr1;
64 //test serialInput
65 serial1 = dijit.byId("serialInput");
66 if (serial1) {
67 bind1 = serial1.get("binding");
68 if (bind1 && bind1.isInstanceOf(dojox.mvc.StatefulModel)) {
69 doh.is("360324", bind1.data,"bind1.data should be set");
70 doh.is("360324", bind1.value,"bind1.value should be set");
71 }
72 }
73 //test addrLabel
74 addr1 = dijit.byId("addrLabel");
75 if (addr1) {
76 bind1 = addr1.get("binding");
77 if (bind1 && bind1.isInstanceOf(dojox.mvc.StatefulModel)) {
78 doh.is("ShipTo", bind1.data,"bind1.data should be set");
79 doh.is("ShipTo", bind1.value,"bind1.value should be set");
80 }
81 }
82 //test streetInput
83 addr1 = dijit.byId("streetInput");
84 if (addr1) {
85 bind1 = addr1.get("binding");
86 if (bind1 && bind1.isInstanceOf(dojox.mvc.StatefulModel)) {
87 doh.is("123 Valley Rd", bind1.data,"bind1.data should be set");
88 doh.is("123 Valley Rd", bind1.value,"bind1.value should be set");
89 }
90 }
91 }
92 }]);
93
94 doh.register("check BillTo", [{
95 name : "testBillTo",
96 runTest : function() {
97 setRef("addrGroup", masterRecord.BillTo);
98 var serial1, bind1, addr1;
99 //test serialInput
100 serial1 = dijit.byId("serialInput");
101 if (serial1) {
102 bind1 = serial1.get("binding");
103 if (bind1 && bind1.isInstanceOf(dojox.mvc.StatefulModel)) {
104 doh.is("360324", bind1.data,"bind1.data should be set");
105 doh.is("360324", bind1.value,"bind1.value should be set");
106 }
107 }
108 //test addrLabel
109 addr1 = dijit.byId("addrLabel");
110
111 if (addr1) {
112 bind1 = addr1.get("binding");
113 if (bind1 && bind1.isInstanceOf(dojox.mvc.StatefulModel)) {
114 doh.is("ShipTo", bind1.data,"bind1.data should be set");
115 doh.is("BillTo", bind1.value,"bind1.value should be set");
116 }
117 }
118 //test streetInput
119 addr1 = dijit.byId("streetInput");
120 if (addr1) {
121 bind1 = addr1.get("binding");
122 if (bind1 && bind1.isInstanceOf(dojox.mvc.StatefulModel)) {
123 doh.is("17 Skyline Dr", bind1.data,"bind1.data should be set");
124 doh.is("17 Skyline Dr", bind1.value,"bind1.value should be set");
125 }
126 }
127 }
128 }]);
129
130 doh.run();
131
132 });
133 </script>
134 </head>
135
136
137 <body class="claro">
138 <h1 class="testTitle">doh_mvc__shipto-billto-simple.html automated tests (non-robot)</h1>
139 <div id="wrapper">
140 <div id="header">
141 <div id="navigation"></div>
142 <div id="headerInsert">
143 <h1>Order Shipping Details</h1>
144 <h2>Data Binding Example - Group Container.</h2>
145 </div>
146 </div>
147 <div id="main">
148 <div id="leftNav"></div>
149 <div id="mainContent"><!--
150 The group container denotes some logical grouping of widgets and also serves
151 to establish a parent data binding context for its children.
152 The ref attribute for the outermost container obtains the binding from the
153 "page scope" itself.
154 -->
155 <div class="row" data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: 'masterRecord'">
156 <div class="row"><label class="cell" for="serialInput">Serial:</label>
157 <input class="cell" id="serialInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Serial'"/>
158 </div>
159 <div class="row"><label class="cell" for="lastnameInput">Last:</label>
160 <input class="cell" id="lastnameInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Last'"/>
161 </div>
162 <div class="row"><label class="cell" for="emailInput">Email:</label>
163 <input class="cell" id="emailInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Email'"/>
164 </div>
165 </div>
166 <br />
167 Choose:
168 <button id="shipto1" type="button" data-dojo-type="dijit.form.Button"
169 data-dojo-props="onClick: function(){setRef('addrGroup', masterRecord.ShipTo);}">Ship To</button>
170 <button id="billto1" type="button" data-dojo-type="dijit.form.Button"
171 data-dojo-props="onClick: function(){setRef('addrGroup', masterRecord.BillTo);}">Bill To</button>
172 <br />
173 <div class="row"><label class="cell" for="addrLabel">Selected
174 Address:</label> <input class="cell" data-dojo-type="dijit.form.TextBox"
175 id="addrLabel" data-dojo-props="ref: 'selectedAddr'"/></div>
176 <br />
177 <!--
178 For convenience, the widget hierarchy matches the data hierarchy
179 (see JSON literal above).
180 In this implementation, the child ref attributes are simple property names
181 of the parent binding context.
182 The ref attribute may support more advanced constructs, such as queries
183 over the parent widget's or other application specified binding context.
184 -->
185 <div class="row" id="addrGroup" data-dojo-type="dojox.mvc.Group"
186 data-dojo-props="ref: 'masterRecord.ShipTo'">
187 <div class="row"><label class="cell" for="streetInput">Street:</label>
188 <input class="cell" id="streetInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Street'"/>
189 </div>
190 <div class="row"><label class="cell" for="cityInput">City:</label>
191 <input class="cell" id="cityInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'City'"/>
192 </div>
193 <div class="row"><label class="cell" for="stateInput">State:</label>
194 <input class="cell" id="stateInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'State'"/>
195 </div>
196 <div class="row"><label class="cell" for="zipInput">Zipcode:</label>
197 <input class="cell" id="zipInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Zip'"/>
198 </div>
199 </div>
200 </div>
201 </div>
202 </div>
203 <script type="text/javascript">
204 function setRef(id, addrRef){
205 var widget = dijit.byId(id);
206 widget.set("ref", addrRef);
207 if(addrRef == "masterRecord.ShipTo"){
208 selectedAddr.set("value", "ShipTo");
209 }else{
210 selectedAddr.set("value", "BillTo");
211 }
212 }
213 </script>
214 </body>
215 </html>