Debian Codegraph @

dojox/mvc/tests/test_mvc_new_bindings-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 -- Binding Test</title>
6
7 <style type="text/css">
8 @import "css/app-format.css";
9 @import "../../../dijit/themes/claro/claro.css";
10 </style>
11 <script type="text/javascript" data-dojo-config="parseOnLoad:1,isDebug:1,async:1,mvc:{debugBindings:1}" src="../../../dojo/dojo.js"></script>
12 <script type="text/javascript">
13
14 var model;
15
16 require([
17 'dojo/_base/kernel',
18 'dojo/parser',
19 'dojo/ready',
20 "dojox/mvc/getStateful",
21 "dojox/mvc/EditModelRefController",
22 'dijit/form/TextBox',
23 'dijit/form/Button',
24 'dijit/form/ValidationTextBox',
25 'dijit/form/NumberTextBox',
26 'dojox/mvc/Group',
27 'dojox/mvc/Output'
28 ], function(dojo, parser, ready, getStateful, EditModelRefController){
29
30 model = new EditModelRefController({sourceModel: getStateful({ "First" : "John",
31 "Last" : "Doe",
32 "Email" : "[email protected]",
33 "Num" : 3
34 })});
35
36 console.log("model is ");
37 console.log(model);
38
39 function noParse(){
40 throw new Error();
41 }
42 nameReadOnlyConverter = {
43 format: function(value){
44 return value === "2" || value === "3";
45 },
46 parse: noParse
47 };
48 nameRelevanceConverter = {
49 format: function(value){
50 return value == "0";
51 },
52 parse: noParse
53 };
54 nameRequiredConverter = {
55 format: function(value){
56 return value === "4";
57 },
58 parse: noParse
59 };
60 numValidConverter = {
61 format: function(value){
62 return value - 0 !== 1 && value !== "3";
63 },
64 parse: noParse
65 };
66 disabledDisplayConverter = {
67 format: function(value){
68 // if(value){
69 return "disabled is "+value;
70 // }
71 // return value - 0 !== 1 && value !== "3";
72 },
73 parse: function(value){
74 // if(value){
75 return "disabled is "+value;
76 // }
77 // return value - 0 !== 1 && value !== "3";
78 }
79 };
80 });
81
82 </script>
83 </head>
84 <body class="claro">
85 <script type="dojo/require">at: "dojox/mvc/at"</script>
86 <div id="wrapper">
87 <div id="header">
88 <div id="navigation">
89 </div>
90 <div id="headerInsert">
91 <h1>Binding Tests</h1>
92 </div>
93 </div>
94 <div id="main">
95 <div id="leftNav">
96 </div>
97 <div id="mainContent">
98 <h2>Bind Self Tests</h2>
99 <div class="row">
100 <label style="display:inline-block; width:100%; text-align:left;">First: Enter 0 to test for disable false (disabled) (use Reset to re-enable)</label>
101 <label style="display:inline-block; width:100%; text-align:left;">First: Enter 1 to test for Valid false.</label>
102 <label style="display:inline-block; width:100%; text-align:left;">First: Enter 2 to test for Read-only false (use Reset to re-enable)</label>
103 <label style="display:inline-block; width:100%; text-align:left;">First: Enter 3 to test for Read-only false and Valid false (use Reset to re-enable)</label>
104 </div>
105 <div class="row">
106 <label class="cell" for="firstnameInput">First:</label>
107 <input class="cell" id="firstnameInput" data-dojo-type="dijit.form.ValidationTextBox"
108 data-dojo-props="value: at(model, 'First'),
109 readOnly: at(model, 'First').transform(nameReadOnlyConverter),
110 disabled: at(model, 'First').transform(nameRelevanceConverter),
111 valid: at(model, 'First').transform(numValidConverter)"></input>
112 <!-- Content in output below will always be in sync with value of textbox above -->
113 <span id="tout" data-dojo-type="dojox.mvc.Output" data-dojo-props="value: at(model, 'First')">
114 (first name is: ${this.value})
115 </span>
116
117 </div>
118 <div class="row">
119 <label class="cell" for="firstnameInput"></label>
120 <!-- <span data-dojo-type="dojox.mvc.Output" data-dojo-props="value: at(model, 'First')">
121 disable is: ${this.ref.disable}, Valid is: ${this.ref.valid}, Read-only is: ${this.ref.readOnly})
122 </span>
123 -->
124 </div>
125 <div class="row">
126 <label style="display:inline-block; width:100%; text-align:left;">Num: Enter 1 for Valid false</label>
127 </div>
128 <div class="row">
129 <label class="cell" for="numInput">Num:</label>
130 <input class="cell" id="numInput" data-dojo-type="dijit.form.NumberTextBox"
131 data-dojo-props="value: at(model, 'Num'),
132 valid: at(model, 'Num').transform(numValidConverter)"></input>
133 <span data-dojo-type="dojox.mvc.Output" data-dojo-props="value: at(model, 'Num')">
134 (num is: ${this.value})
135 </span>
136 </div>
137 <h2>Bind Tests</h2>
138 <div class="row">
139 <label style="display:inline-block; width:100%; text-align:left;">Last: Enter 0 to test for disable false (disabled) for Email.</label>
140 <label style="display:inline-block; width:100%; text-align:left;">Last: Enter 1 to test for Valid false for Email.</label>
141 <label style="display:inline-block; width:100%; text-align:left;">Last: Enter 2 to test for Read-only true for Email.</label>
142 <label style="display:inline-block; width:100%; text-align:left;">Last: Enter 3 to test for Read-only true and Valid false for Email.</label>
143 <label style="display:inline-block; width:100%; text-align:left;">Last: Enter 4 to test for Required true for Email.</label>
144 </div>
145
146 <div class="row">
147 <label class="cell" for="lastnameInput">Last:</label>
148 <input class="cell" id="lastnameInput" data-dojo-type="dijit.form.TextBox"
149 data-dojo-props="value: at(model, 'Last')"></input>
150 <span data-dojo-type="dojox.mvc.Output" data-dojo-props="value: at(model, 'Last')">
151 (last name is: ${this.value})
152 </span>
153 </div>
154 <div class="row">
155 <label class="cell" for="emailInput">Email:</label>
156 <input class="cell" id="emailInput" data-dojo-type="dijit.form.ValidationTextBox"
157 data-dojo-props="value: at(model, 'Email'),
158 readOnly: at(model, 'Last').transform(nameReadOnlyConverter),
159 disabled: at(model, 'Last').transform(nameRelevanceConverter),
160 valid: at(model, 'Last').transform(numValidConverter),
161 required: at(model, 'Last').transform(nameRequiredConverter)"></input>
162 <span data-dojo-type="dojox.mvc.Output" data-dojo-props="value: at(model, 'Email')">
163 (email is: ${this.value})
164 </span>
165 </div>
166 <!-- <div class="row">
167 <label class="cell" for="emailInput"></label>
168 <span id="emailOut" data-dojo-type="dojox.mvc.Output" data-dojo-props="value: at(model, 'Email'),
169 readOnly: at(model, 'Email'),
170 disabled: at(model, 'Email').transform(disabledDisplayConverter),
171 required: at(model, 'Email')">
172 disabled is: ${this.disabled}, Valid is: ${this.valid}, Read-only is: ${this.readOnly}, Required is: ${this.required})
173 </span>
174 </div>
175 -->
176 <br/>Model:
177 <button id="reset" type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){doReset()}">Reset</button>
178 </div>
179 </div></div>
180 <script type="text/javascript">
181 function doReset() {
182 model.reset();
183 }
184 </script>
185
186 </body>
187 </html>