Debian Codegraph @

dojox/mvc/tests/doh/doh_mvc_new_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>Static Master/Detail Pattern -- Multiple Address Detail example</title>
6 <style type="text/css">
7 @import "../css/app-format.css";
8 @import "../../../../dijit/themes/claro/claro.css";
9 </style>
10 <script type="text/javascript" data-dojo-config="parseOnLoad:0,isDebug:1,async:1, mvc: {debugBindings: 1}" src="../../../../dojo/dojo.js"></script>
11 <script type="text/javascript">
12 var ctrl, ctrlDetail, model, data;
13
14 require([
15 "doh/runner",
16 "dojo/parser",
17 "dojo/when",
18 "dojo/Stateful",
19 "dijit/registry",
20 "dojox/mvc/at",
21 "dojox/mvc/getStateful",
22 "dojox/mvc/ModelRefController",
23 "dijit/form/TextBox",
24 "dijit/form/Button",
25 "dojox/mvc/Group",
26 "dojox/mvc/Output"
27 ], function(doh, parser, when, Stateful, registry, at, getStateful, ModelRefController){
28
29 ctrl = new ModelRefController();
30 ctrlDetail = new ModelRefController();
31
32 when(parser.parse(), function(){
33 data = {
34 "Serial": "360324",
35 "First": "John",
36 "Last": "Doe",
37 "Email": "[email protected]",
38 "ShipTo": {
39 "Street": "123 Valley Rd-ShipTo",
40 "City": "Katonah",
41 "State": "NY",
42 "Zip": "10536"
43 },
44 "BillTo": {
45 "Street": "17 Skyline Dr-BillTo",
46 "City": "Hawthorne",
47 "State": "NY",
48 "Zip": "10532"
49 }
50 };
51
52 ctrl.set("model", getStateful(data));
53 ctrlDetail.set("model", ctrl.model.get("ShipTo"));
54
55 doh.register("Switch between ShipTo and BillTo", [{
56 name: "Switch-to-BillTo",
57 runTest: function(){
58 ctrlDetail.set("model", ctrl.model.get("BillTo"));
59 doh.is("17 Skyline Dr-BillTo", registry.byId("streetInput").get("value"), "Street should be of BillTo");
60 doh.is("Hawthorne", registry.byId("cityInput").get("value"), "City should be of BillTo");
61 }
62 }, {
63 name: "Switch-to-ShipTo",
64 runTest: function(){
65 ctrlDetail.set("model", ctrl.model.get("ShipTo"));
66 doh.is("123 Valley Rd-ShipTo", registry.byId("streetInput").get("value"), "Street should be of ShipTo");
67 doh.is("Katonah", registry.byId("cityInput").get("value"), "City should be of ShipTo");
68 }
69 }]);
70
71 doh.register("Setting a plain object to group", [{
72 name: "Switch-to-BillTo",
73 setUp: function(){
74 registry.byId("streetInput").set("value", at("rel:", "Street"));
75 registry.byId("cityInput").set("value", at("rel:", "City"));
76 registry.byId("stateInput").set("value", at("rel:", "State"));
77 registry.byId("zipInput").set("value", at("rel:", "Zip"));
78 },
79 runTest: function(){
80 ctrlDetail.set("model", data.BillTo);
81 doh.is("17 Skyline Dr-BillTo", registry.byId("streetInput").get("value"), "Street should be of BillTo");
82 doh.is("Hawthorne", registry.byId("cityInput").get("value"), "City should be of BillTo");
83 }
84 }, {
85 name: "Switch-to-ShipTo",
86 runTest: function(){
87 ctrlDetail.set("model", data.ShipTo);
88 doh.is("123 Valley Rd-ShipTo", registry.byId("streetInput").get("value"), "Street should be of ShipTo");
89 doh.is("Katonah", registry.byId("cityInput").get("value"), "City should be of ShipTo");
90 }
91 }]);
92
93 doh.run();
94 });
95 });
96 </script>
97 </head>
98 <body class="claro">
99 <script type="dojo/require">at: "dojox/mvc/at"</script>
100 <div id="wrapper">
101 <div id="header">
102 <div id="navigation">
103 </div>
104 <div id="headerInsert">
105 <h1>Order Shipping Details</h1>
106 <h2>Data Binding Example - Group Container.</h2>
107 </div>
108 </div>
109 <div id="main">
110 <div id="leftNav"></div>
111 <div id="mainContent">
112 <!--
113 The group container denotes some logical grouping of widgets and also serves
114 to establish a parent data binding context for its children.
115 The ref attribute for the outermost container obtains the binding from the
116 "page scope" itself.
117 -->
118 <!-- data-dojo-props="ref: 'model'"> -->
119 <!-- data-dojo-props="ref: 'Serial'"/> -->
120 <!-- data-dojo-props="ref: 'Last'"/> -->
121 <!-- data-dojo-props="ref: 'Email'"/> -->
122 <!-- data-dojo-props="value: at('rel:Serial', 'value')"> -->
123 <div class="row" data-dojo-type="dojox.mvc.Group" data-dojo-props="target: at(ctrl, 'model')">
124 <div class="row">
125 <label class="cell" for="serialInput">Order #:</label>
126 <input class="cell" id="serialInput" data-dojo-type="dijit.form.TextBox"
127 data-dojo-props="value: at('rel:', 'Serial')">
128 </div>
129 <div class="row">
130 <label class="cell" for="lastnameInput">Last:</label>
131 <input class="cell" id="lastnameInput" data-dojo-type="dijit.form.TextBox"
132 data-dojo-props="value: at('rel:', 'Last')">
133 </div>
134 <div class="row">
135 <label class="cell" for="emailInput">Email:</label>
136 <input class="cell" id="emailInput" data-dojo-type="dijit.form.TextBox"
137 data-dojo-props="value: at('rel:', 'Email')">
138 </div>
139 </div>
140 <br/>
141 <!--
142 For convenience, the widget hierarchy matches the data hierarchy
143 (see JSON literal above).
144 In this implementation, the child ref attributes are simple property names
145 of the parent binding context.
146 The ref attribute may support more advanced constructs, such as queries
147 over the parent widget's or other application specified binding context.
148 -->
149 <div class="row" id="addrGroup" data-dojo-type="dojox.mvc.Group" data-dojo-props="target: at(ctrlDetail, 'model')">
150 <div class="row">
151 <label class="cell" for="streetInput">Street:</label>
152 <input class="cell" id="streetInput" data-dojo-type="dijit.form.TextBox"
153 data-dojo-props="value: at('rel:', 'Street')">
154 </div>
155 <div class="row">
156 <label class="cell" for="cityInput">City:</label>
157 <input class="cell" id="cityInput" data-dojo-type="dijit.form.TextBox"
158 data-dojo-props="value: at('rel:', 'City')">
159 </div>
160 <div class="row">
161 <label class="cell" for="stateInput">State:</label>
162 <input class="cell" id="stateInput" data-dojo-type="dijit.form.TextBox"
163 data-dojo-props="value: at('rel:', 'State')">
164 </div>
165 <div class="row">
166 <label class="cell" for="zipInput">Zipcode:</label>
167 <input class="cell" id="zipInput" data-dojo-type="dijit.form.TextBox"
168 data-dojo-props="value: at('rel:', 'Zip')">
169 </div>
170 </div>
171 </div></div></div>
172 </body>
173 </html>