Debian Codegraph @

dojox/mvc/tests/doh/doh_mvc_shipto-billto-hierarchical.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" data-dojo-config="parseOnLoad: 0, isDebug: 1, mvc: {debugBindings: 1}"></script>
13 <script type="text/javascript" src="./helpers.js"></script>
14 <script type="text/javascript">
15 require([
16 "doh/runner",
17 "dojo/parser",
18 "dojo/when",
19 "dojox/mvc/getStateful",
20 "dojox/mvc/ListController",
21 "dijit/registry",
22 "dijit/form/Button",
23 "dijit/form/TextBox",
24 "dojox/mvc/Group",
25 "dojo/domReady!"
26 ], function(doh, parser, when, getStateful, ListController, registry){
27
28 ctrl = new ListController({model: getStateful({
29 Serial: "360324",
30 First: "John",
31 Last: "Doe",
32 Email: "[email protected]",
33 ShipTo: {
34 Type: "Home",
35 Address: {
36 Street: "123 Valley Rd",
37 City: "Katonah",
38 State: "NY",
39 Zip: "10536"
40 },
41 Telephone: {
42 AreaCode: "123",
43 Landline: {
44 Number: "456-7890",
45 Extension: "42"
46 },
47 Cell: {
48 Number: "765-4321"
49 }
50 }
51 },
52 BillTo: {
53 Type: "Office",
54 Address: {
55 Street: "17 Skyline Dr",
56 City: "Hawthorne",
57 State: "NY",
58 Zip: "10532"
59 },
60 Telephone: {
61 AreaCode: "098",
62 Landline: {
63 Number: "765-4321",
64 Extension: "24"
65 },
66 Cell: {
67 Number: "123-4567"
68 }
69 }
70 }
71
72 }), cursorIndex: "ShipTo"});
73
74 when(parser.parse(), function(){
75 // should be able to verify all of the inputs
76 doh.register("Check values and bindings", [{
77 name: "Initial",
78 runTest: function(){
79 doh.is("360324", registry.byId("serialInput").get("value"), "serial1 should be set");
80 doh.is("ShipTo", registry.byId("addrLabel").get("value"), "addr1 should be set");
81 doh.is("123 Valley Rd", registry.byId("streetInput").get("value"), "street1 should be set");
82 }
83 }, {
84 name: "TestBillTo",
85 runTest: function(){
86 ctrl.set("cursorIndex", "BillTo");
87 doh.is("360324", registry.byId("serialInput").get("value"), "serial1 should be set");
88 doh.is("BillTo", registry.byId("addrLabel").get("value"), "addr1 should be set");
89 doh.is("17 Skyline Dr", registry.byId("streetInput").get("value"), "street1 should be set");
90 }
91 }, {
92 name: "TestShipTo",
93 runTest: function(){
94 ctrl.set("cursorIndex", "ShipTo");
95 doh.is("360324", registry.byId("serialInput").get("value"), "serial1 should be set");
96 doh.is("ShipTo", registry.byId("addrLabel").get("value"), "addr1 should be set");
97 doh.is("123 Valley Rd", registry.byId("streetInput").get("value"), "street1 should be set");
98 }
99 }, {
100 name: "ChangeShipTo",
101 runTest: function(){
102 ctrl.set("cursorIndex", "ShipTo");
103 registry.byId("streetInput").set("value","456 Mountain Rd");
104 ctrl.set("cursorIndex", "BillTo");
105 ctrl.set("cursorIndex", "ShipTo");
106 doh.is("360324", registry.byId("serialInput").get("value"), "serial1 should be set");
107 doh.is("ShipTo", registry.byId("addrLabel").get("value"), "addr1 should be set");
108 doh.is("456 Mountain Rd", registry.byId("streetInput").get("value"), "street1 should be set");
109 doh.is("Katonah", registry.byId("cityInput").get("value"), "city1 should be set");
110 }
111 }]);
112
113 doh.run();
114 });
115 });
116
117 </script>
118 </head>
119 <body class="claro">
120 <script type="dojo/require">at: "dojox/mvc/at"</script>
121 <div id="wrapper">
122 <div id="header">
123 <div id="navigation"></div>
124 <div id="headerInsert">
125 <h1>Order Shipping Details</h1>
126 <h2>Data Binding Example - Hierarchical data.</h2>
127 </div>
128 </div>
129 <div id="main">
130 <div id="leftNav"></div>
131 <div id="mainContent">
132 <!--
133 The group container denotes some logical grouping of widgets and also serves
134 to establish a parent data binding context for its children.
135 The ref attribute for the outermost container obtains the binding from the
136 "page scope" itself.
137 -->
138 <div class="row" data-dojo-type="dojox.mvc.Group" data-dojo-props="target: at(ctrl, 'model')">
139 <div class="row">
140 <label class="cell" for="serialInput">Order #:</label>
141 <input class="cell" id="serialInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Serial')"/>
142 </div>
143 <div class="row">
144 <label class="cell" for="lastnameInput">Last name:</label>
145 <input class="cell" id="lastnameInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Last')"/>
146 </div>
147 <div class="row">
148 <label class="cell" for="emailInput">Email:</label>
149 <input class="cell" id="emailInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Email')"/>
150 </div>
151 </div>
152 <br/>
153 Choose:
154 <button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){ ctrl.set('cursorIndex', 'ShipTo'); }">Ship To</button>
155 <button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){ ctrl.set('cursorIndex', 'BillTo'); }">Bill To</button>
156 <br/>
157 <div class="row">
158 <label class="cell" for="addrLabel">Selected Address:</label>
159 <input class="cell" id="addrLabel" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at(ctrl, 'cursorIndex')"/>
160 </div>
161 <br/>
162 <!--
163 For convenience, the widget hierarchy matches the data hierarchy
164 (see JSON literal above).
165 In this implementation, the child ref attributes are simple property names
166 of the parent binding context.
167 The ref attribute may support more advanced constructs, such as queries
168 over the parent widget's or other application specified binding context.
169 -->
170 <div id="addrGroup" data-dojo-type="dojox.mvc.Group" data-dojo-props="target: at(ctrl, 'cursor')">
171 <div class="row">
172 <label class="cell" for="typeInput">Type:</label>
173 <input class="cell" id="typeInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Type')"/>
174 </div>
175 <div id="postalGroup" data-dojo-type="dojox.mvc.Group" data-dojo-props="target: at('rel:', 'Address')">
176 <div class="row">
177 <label class="cell" for="streetInput">Street:</label>
178 <input class="cell" id="streetInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Street')"/>
179 </div>
180 <div class="row">
181 <label class="cell" for="cityInput">City:</label>
182 <input class="cell" id="cityInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'City')"/>
183 </div>
184 <div class="row">
185 <label class="cell" for="stateInput">State:</label>
186 <input class="cell" id="stateInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'State')"/>
187 </div>
188 <div class="row">
189 <label class="cell" for="zipInput">Zipcode:</label>
190 <input class="cell" id="zipInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Zip')"/>
191 </div>
192 </div>
193 <div id="telGroup" data-dojo-type="dojox.mvc.Group" data-dojo-props="target: at('rel:', 'Telephone')">
194 <div class="row">
195 <label class="cell" for="areacodeInput">Area code:</label>
196 <input class="cell" id="areacodeInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'AreaCode')"/>
197 </div>
198 <div id="llGroup" data-dojo-type="dojox.mvc.Group" data-dojo-props="target: at('rel:', 'Landline')">
199 <div class="row">
200 <label class="cell" for="numberInput">Landline Number:</label>
201 <input class="cell" id="numberInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Number')"/>
202 </div>
203 <div class="row">
204 <label class="cell" for="extInput">Extension:</label>
205 <input class="cell" id="extInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Extension')"/>
206 </div>
207 </div>
208 <div class="row" id="cellGroup" data-dojo-type="dojox.mvc.Group" data-dojo-props="target: at('rel:', 'Cell')">
209 <label class="cell" for="cellInput">Cell Number:</label>
210 <input class="cell" id="cellInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Number')"/>
211 </div>
212 </div>
213 </div>
214 </div>
215 </div>
216 </div>
217 </body>
218 </html>