Debian Codegraph @

dijit/tests/form/ExpandingTextAreaMixin.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/>
5 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
6 <title>_ExpandingTextAreaMixin tests</title>
7
8 <style type="text/css">
9 @import "../../themes/claro/document.css";
10 @import "../../themes/dijit.css";
11
12 #table {
13 margin: 0;
14 padding: 2px;
15 }
16 #table, TEXTAREA {
17 font-family: monospace;
18 font-size: 12pt;
19 }
20 #table .layout {
21 padding: 2px;
22 font-size: 100%;
23 margin: 0;
24 }
25 </style>
26 <link id="themeStyles" rel="stylesheet" href="../../../dijit/themes/claro/claro.css"/>
27
28 <script type="text/javascript" src="../../../dojo/dojo.js"
29 data-dojo-config="parseOnLoad: true, isDebug: true"></script>
30
31 <script type="text/javascript">
32 dojo.require("doh.runner");
33 dojo.require("dijit.dijit"); // optimize: load dijit layer
34 dojo.require("dijit.form.Textarea");
35 dojo.require("dojox.mobile.ExpandingTextArea");
36
37 dojo.ready(function(){
38
39 var maxLengthNativeSupport = "maxLength" in document.createElement("textarea");
40
41 doh.register("attributes", [
42 {
43 name: "dijit",
44 runTest: function(){
45 var dijit_attributes = dijit.byId('dijit_attributes');
46 doh.is("", dijit_attributes.textbox.value, "dijit original value");
47 doh.is("", dijit_attributes.get('value'), "dijit original get('value')");
48 if(maxLengthNativeSupport){
49 doh.is("20", dijit_attributes.textbox.getAttribute("maxlength"), "dijit original maxLength");
50 }
51 doh.is("20", dijit_attributes.get('maxLength'), "dijit original get('maxLength')");
52 dijit_attributes.set('maxLength', "9");
53 doh.is("", dijit_attributes.textbox.value, "dijit value");
54 doh.is("", dijit_attributes.get('value'), "dijit get('value')");
55 if(maxLengthNativeSupport){
56 doh.is("9", dijit_attributes.textbox.getAttribute("maxlength"), "dijit maxLength");
57 }
58 doh.is("9", dijit_attributes.get('maxLength'), "dijit get('maxLength')");
59 // cols
60 doh.is("20", dijit_attributes.textbox.getAttribute("cols"), "dijit original cols");
61 doh.is("20", dijit_attributes.get('cols'), "dijit original get('cols')");
62 dijit_attributes.set('cols', "19");
63 doh.is("19", dijit_attributes.textbox.getAttribute("cols"), "dijit cols");
64 doh.is("19", dijit_attributes.get('cols'), "dijit get('cols')");
65 }
66 },
67 {
68 name: "mobile",
69 runTest: function(){
70 var mobile_attributes = dijit.byId('mobile_attributes');
71 doh.is("", mobile_attributes.textbox.value, "mobile original value");
72 doh.is("", mobile_attributes.get('value'), "mobile original get('value')");
73 if(maxLengthNativeSupport){
74 doh.is("20", mobile_attributes.textbox.getAttribute("maxlength"), "mobile original maxLength");
75 }
76 doh.is("20", mobile_attributes.get('maxLength'), "mobile original get('maxLength')");
77 mobile_attributes.set('maxLength', "9");
78 doh.is("", mobile_attributes.textbox.value, "mobile value");
79 doh.is("", mobile_attributes.get('value'), "mobile get('value')");
80 if(maxLengthNativeSupport){
81 doh.is("9", mobile_attributes.textbox.getAttribute("maxlength"), "mobile maxLength");
82 }
83 doh.is("9", mobile_attributes.get('maxLength'), "mobile get('maxLength')");
84 // cols
85 doh.is("20", mobile_attributes.textbox.getAttribute("cols"), "mobile original cols");
86 doh.is("20", mobile_attributes.get('cols'), "mobile original get('cols')");
87 mobile_attributes.set('cols', "19");
88 doh.is("19", mobile_attributes.textbox.getAttribute("cols"), "mobile cols");
89 doh.is("19", mobile_attributes.get('cols'), "mobile get('cols')");
90 }
91 }
92 ]);
93
94 doh.register("events", [
95 {
96 name: "dijit",
97 timeout: 5000,
98 runTest: function(){
99 var
100 d = new doh.Deferred(),
101 dijit_events = dijit.byId('dijit_events'),
102 nop = function(){ return false; };
103
104 function onFocus(){
105 dijit_events.set('onFocus', nop);
106 dijit_events.set("value", "Focus");
107 dijit_events.set('onBlur', onBlur);
108 dijit.byId('mobile_events').focus();
109 }
110 function onBlur(){
111 dijit_events.set('onChange', onChange);
112 dijit_events.set('onBlur', nop);
113 dijit_events.set("value", "Blur");
114 }
115 function onChange(){
116 dijit_events.set('onChange', nop);
117 dijit_events.set("value", "Change");
118 dijit_events.focus();
119 d.callback(true);
120 }
121 doh.is(nop.toString(), dijit_events.get('onFocus').toString(), "get('onFocus')");
122 doh.is(nop.toString(), dijit_events.get('onBlur').toString(), "get('onBlur')");
123 doh.is(nop.toString(), dijit_events.get('onChange').toString(), "get('onChange')");
124 dijit_events.set('onFocus', onFocus);
125 setTimeout(dojo.hitch(dijit_events, "focus"), 0);
126
127 return d;
128 }
129 },
130 {
131 name: "mobile",
132 timeout: 10000,
133 runTest: function(){
134 var
135 d = new doh.Deferred(),
136 mobile_events = dijit.byId('mobile_events'),
137 focusHandle, blurhandle,
138 nop = function(){ return false; };
139
140 function onFocus(){
141 mobile_events.disconnect(focusHandle);
142 mobile_events.set("value", "Focus");
143 blurhandle = mobile_events.connect(mobile_events, '_onBlur', onBlur);
144 dijit.byId('dijit_events').focus();
145 }
146 function onBlur(){
147 mobile_events.set('onChange', onChange);
148 mobile_events.disconnect(blurhandle);
149 mobile_events.set("value", "Blur");
150 }
151 function onChange(){
152 mobile_events.set('onChange', nop);
153 mobile_events.set("value", "Change");
154 mobile_events.focus();
155 d.callback(true);
156 }
157 doh.is(nop.toString(), mobile_events.get('onChange').toString(), "get('onChange')");
158 mobile_events.textbox.value = "changing";
159 focusHandle = mobile_events.connect(mobile_events, '_onFocus', onFocus);
160 setTimeout(dojo.hitch(mobile_events, "focus"), 0);
161
162 return d;
163 }
164 }
165 ]);
166
167 doh.register("programmatic", [
168 {
169 name: "dijit",
170 timeout: 5000,
171 runTest: function(){
172 new dijit.form.Textarea({id:"dijit_programmatic", value:"No srcNodeRef", "aria-label":"dijit_programmatic"}).placeAt("dijit_programmatic_container", "first");
173 var dijit_programmatic = dijit.byId('dijit_programmatic');
174 dijit_programmatic.resize();
175 var focushandle = dijit_programmatic.connect(dijit_programmatic, '_onFocus',
176 function(){
177 d.getTestCallback(function(){
178 dijit_programmatic.disconnect(focushandle);
179 var pos = dojo.position(dijit_programmatic.domNode, true);
180 doh.t(pos.w > 0 && pos.h > 0 && pos.x > 0 && pos.y > 0, 'dijit position');
181 doh.is("No srcNodeRef", dijit_programmatic.textbox.value, 'dijit textbox value');
182 doh.is("No srcNodeRef", dijit_programmatic.get('value'), 'dijit widget value');
183 })();
184 }
185 );
186 var d = new doh.Deferred();
187 setTimeout(dojo.hitch(dijit_programmatic, "focus"), 0);
188 return d;
189 }
190 },
191 {
192 name: "mobile",
193 timeout: 5000,
194 runTest: function(){
195 new dojox.mobile.ExpandingTextArea({id:"mobile_programmatic", value:"No srcNodeRef","aria-label":"mobile_programmatic"}).placeAt("mobile_programmatic_container", "first");
196 var mobile_programmatic = dijit.byId('mobile_programmatic');
197 mobile_programmatic.resize();
198 var focushandle = mobile_programmatic.connect(mobile_programmatic, '_onFocus',
199 function(){
200 d.getTestCallback(function(){
201 mobile_programmatic.disconnect(focushandle);
202 var pos = dojo.position(mobile_programmatic.domNode, true);
203 doh.t(pos.w > 0 && pos.h > 0 && pos.x > 0 && pos.y > 0, 'mobile position');
204 doh.is("No srcNodeRef", mobile_programmatic.textbox.value, 'mobile textbox value');
205 doh.is("No srcNodeRef", mobile_programmatic.get('value'), 'mobile widget value');
206 })();
207 }
208 );
209 var d = new doh.Deferred();
210 setTimeout(dojo.hitch(mobile_programmatic, "focus"), 0);
211 return d;
212 }
213 }
214 ]);
215
216 doh.register("sizes", [
217 {
218 name: "dijit",
219 runTest: function(){
220 var dijit_size = dijit.byId('dijit_size');
221 var originalH = dijit_size.domNode.offsetHeight;
222 var originalVal = dijit_size.value;
223 dijit_size.set('value', originalVal + "\n");
224 var newH = dijit_size.domNode.offsetHeight;
225 doh.t(newH > originalH, "expand: " + newH + ' ' + originalH);
226 dijit_size.set('value', originalVal);
227 newH = dijit_size.domNode.offsetHeight;
228 doh.is(newH, originalH, "shrink: " + newH + ' ' + originalH);
229 }
230 },
231 {
232 name: "mobile",
233 runTest: function(){
234 var mobile_size = dijit.byId('mobile_size');
235 var originalH = mobile_size.domNode.offsetHeight;
236 var originalVal = mobile_size.value;
237 mobile_size.set('value', originalVal + "\n");
238 var newH = mobile_size.domNode.offsetHeight;
239 doh.t(newH > originalH, "expand: " + newH + ' ' + originalH);
240 mobile_size.set('value', originalVal);
241 newH = mobile_size.domNode.offsetHeight;
242 }
243 }
244 ]);
245
246 doh.run();
247 });
248 </script>
249 </head>
250 <body class="claro" role="main">
251 <h1 class="testTitle">_ExpandingTextAreaMixin (dijit and mobile) non-robot tests</h1>
252 <table id="table">
253 <tr>
254 <th class="layout">&nbsp;</th>
255 <th class="layout">dijit</th>
256 <th class="layout">mobile</th>
257 </tr>
258 <tr>
259 <td class="layout">attributes</td>
260 <td class="layout"><input id="dijit_attributes" aria-label="dijit_attr" data-dojo-type="dijit/form/Textarea" data-dojo-props='value:"", placeHolder:"original", maxLength:"20", cols:20'/></td>
261 <td class="layout"><textarea id="mobile_attributes" aria-label="mobilet_attr" data-dojo-type="dojox.mobile.ExpandingTextArea" data-dojo-props='cols:20, placeHolder:"original", maxLength:20'></textarea></td>
262 </tr>
263 <tr>
264 <td class="layout">Events</td>
265 <td class="layout"><input id="dijit_events" aria-label="dijit_events"data-dojo-type="dijit/form/Textarea" data-dojo-props='value:"", onFocus:function(){ return false; }, onBlur:function(){ return false; }, onChange:function(){ return false; }'/></td>
266 <td class="layout"><textarea id="mobile_events" aria-label="mobile_events" data-dojo-type="dojox.mobile.ExpandingTextArea" data-dojo-props='onChange:function(){ return false; }'></textarea></td>
267 </tr>
268 <tr>
269 <td class="layout">Programmatic</td>
270 <td class="layout" id="dijit_programmatic_container"></td>
271 <td class="layout" id="mobile_programmatic_container"></td>
272 </tr>
273 <tr>
274 <td class="layout">Size</td>
275 <td class="layout"><textarea id="dijit_size" aria-label="dijit_size" data-dojo-type="dijit/form/Textarea" data-dojo-props=''
276 >line 1
277 line 2
278 line 3</textarea></td>
279 <td class="layout"><textarea id="mobile_size" aria-label="mobile_size" data-dojo-type="dojox.mobile.ExpandingTextArea" data-dojo-props=''
280 >line 1
281 line 2
282 line 3</textarea></td>
283 </tr>
284 </table>
285 </body>
286 </html>