Debian Codegraph @

dijit/tests/form/_autoComplete.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
5 <title>dijit.form.ComboBox Unit Test</title>
6
7 <style>
8 @import "../../themes/claro/document.css";
9 @import "../../../util/doh/robot/robot.css";
10 @import "../css/dijitTests.css";
11 </style>
12
13 <!-- required: the default dijit theme: -->
14 <link id="themeStyles" rel="stylesheet" href="../../../dijit/themes/claro/claro.css"/>
15
16 <!-- required: dojo.js -->
17 <script type="text/javascript" src="../../../dojo/dojo.js"
18 data-dojo-config="isDebug: true, parseOnLoad: false"></script>
19
20 <!-- only needed for alternate theme testing: -->
21 <script type="text/javascript" src="../_testCommon.js"></script>
22
23 <script type="text/javascript">
24 var isUnitTest = false;
25 var testWidget = "dijit.form.ComboBox";
26 var qstr = window.location.search.substr(1);
27 if(qstr.length){
28 var qparts = qstr.split("&");
29 for(var x=0; x<qparts.length; x++){
30 var tp = qparts[x].split("=");
31 if(tp[0] == "testWidget"){
32 testWidget = tp[1];
33 document.title = testWidget + " Unit Test";
34 }else if(tp[0] == "mode"){
35 isUnitTest = tp[1] == "test";
36 }
37 }
38 }
39 var isComboBox = testWidget == "dijit.form.ComboBox";
40 dojo.require("dojo.store.Memory");
41 dojo.require("dojo._base.Deferred");
42 dojo.require("dojo.data.ItemFileReadStore");
43 dojo.require("dijit.tests._data.SlowStore");
44 dojo.require("dijit.dijit"); // optimize: load dijit layer
45 dojo.require(testWidget);
46 dojo.require("dojo.parser"); // scan page for widgets and instantiate them
47 dojo.require("doh.runner");
48
49 function setVal2(val){
50 dojo.byId('value2').value=val;
51 var w = dijit.byId('datatest');
52 var item = w.item;
53 console.debug("Value changed to ["+val+"] in second box (#1652): datastore item label = " + (item?w.store.getLabel(item):'no item'));
54 }
55 function setVal3(val){
56 dojo.byId('value3').value=val;
57 }
58 function setVal4(val){
59 dojo.byId('value4').value=val;
60 }
61 var combo;
62 function myLabelFunc(item, store){
63 var label=store.getValue(item, 'name');
64 // DEMO: uncomment to chop off a character
65 //label=label.substr(0, label.length-1);
66 // DEMO: uncomment to set to lower case
67 label = label.toLowerCase();
68 return label;
69 }
70
71 // Test Custom Store
72 dojo.declare("StateSelect", isComboBox ? dijit.form.ComboBox : dijit.form.FilteringSelect , {
73 placeHolder: "Select a State",
74 searchAttr: "name",
75 label: "State:",
76 name: "state",
77 style: "width: 160px",
78 store: new dojo.data.ItemFileReadStore({ url: dojo.moduleUrl("dijit.tests._data", "states.json") }),
79 value: ''
80 });
81
82 function init(){
83 var combo;
84
85 var testClass = dojo.getObject(testWidget);
86 // substitute testWidget for each data-dojo-type=$testWidget
87 dojo.query('[data-dojo-type="$testWidget"]').forEach(function(node){
88 node.setAttribute('data-dojo-type', testWidget);
89 });
90 dojo.parser.parse(dojo.body());
91 store = new dojo.data.ItemFileReadStore({url: dojo.moduleUrl("dijit.tests._data", "states.json")});
92 combo = new testClass({
93 name:"prog",
94 title: "title attribute used for label",
95 autoComplete:false,
96 store: store,
97 searchAttr:"name"
98 }, dojo.byId("progCombo"));
99 store2 = new dojo.data.ItemFileReadStore({url: dojo.moduleUrl("dijit.tests._data", "countries.json")});
100 combo = new testClass({
101 name:"prog2",
102 autoComplete:false,
103 store:store2,
104 query:{type:'country'},
105 searchAttr:"name"
106 }, dojo.byId("progCombo2"));
107
108 new testClass({
109 name:"prog3",
110 autoComplete:false,
111 store:store2,
112 query:{type:'country'},
113 searchAttr:"name",
114 fetchProperties: {sort:[{attribute: 'name', descending: true}]}
115 }, dojo.byId("progCombo3"));
116
117 // change Memory store to have an asynchronous total
118 var oldMemoryQuery = dojo.store.Memory.prototype.query;
119 dojo.store.Memory.extend({
120 query: function(){
121 var results = oldMemoryQuery.apply(this, arguments);
122 var total = results.total;
123 results.total = new dojo.Deferred();
124 setTimeout(function(){
125 results.total.resolve(total);
126 }, 100);
127 return results;
128 }
129 });
130
131 if(!isUnitTest){ return; }
132
133 doh.register("label", [
134 {
135 name: "user-specified id",
136 runTest: function(){
137 combo = dijit.byId("setvaluetest");
138 var labelId = combo.domNode.getAttribute('aria-labelledby');
139 doh.is("setvaluetest_mylabel", labelId, "labelledby");
140 doh.is(labelId, dojo.byId(labelId).id, "label id");
141 }
142 },
143 {
144 name: "generated id",
145 runTest: function(){
146 combo = dijit.byId("datatest");
147 var labelId = combo.domNode.getAttribute('aria-labelledby');
148 doh.is("datatest_label", labelId, "labelledby");
149 doh.is(labelId, dojo.byId(labelId).id, "label id");
150 }
151 },
152 {
153 name: "aria roles and attributes",
154 timeout: 5000,
155 runTest:function(){
156 var d = new doh.Deferred();
157 combo = dijit.byId("setvaluetest");
158 // ComboBox and FilteringSelect have the same roles and attributes
159 doh.is("combobox", combo._popupStateNode.getAttribute("role"), "combo _popupStateNode role");
160 doh.t(combo._popupStateNode.getAttribute("aria-haspopup"), "aria-haspopup on combo");
161 doh.is("setvaluetest_mylabel", combo._popupStateNode.getAttribute("aria-labelledby"), "aria-labelledby");
162 doh.f(combo._popupStateNode.getAttribute("aria-expanded"), "initially missing aria-expanded");
163 doh.f(combo._popupStateNode.getAttribute("aria-owns"), "initally missing aria-owns");
164
165 // Type is "text" by default but app should be able to override it.
166 // Except it doesn't work on IE9 and below; the type is always text.
167 if(!(dojo.isIE <= 9)){
168 doh.is("text", combo.focusNode.type, "default type");
169 doh.is("url", dijit.byId("url").focusNode.type, "override type");
170 }
171
172 var handler = dojo.connect(combo, "openDropDown", function(){
173 dojo.disconnect(handler);
174 setTimeout(d.getTestCallback(function(){
175 doh.t(combo._popupStateNode.getAttribute("aria-expanded"), "now aria-expanded should be true");
176 doh.is("setvaluetest_popup", combo._popupStateNode.getAttribute("aria-owns"), "should aria-own the popup");
177
178 doh.is("listbox", combo.dropDown.domNode.getAttribute("role"), "dropDown.domNode should have a role");
179 doh.is("setvaluetest", combo.dropDown.domNode.getAttribute("aria-labelledby"), "aria-labelledby should point back to button");
180 doh.is("region", dojo.byId("widget_setvaluetest_dropdown").getAttribute("role"), "popup wrapper should have role=region since it gets appended to the end of the body");
181 doh.is("setvaluetest_popup", dojo.byId("widget_setvaluetest_dropdown").getAttribute("aria-label"), "popup wrapper should have aria-label since role=region");
182 }), 500);
183 });
184
185 combo.loadDropDown();
186 return d;
187 },
188 tearDown:function(){
189 combo.closeDropDown();
190 }
191 }
192 ]);
193
194 doh.register("placeHolder", [
195 {
196 timeout: 2000,
197 name: "focus enpty",
198 combo: "placeholdertest",
199 setUp: function(){
200 dojo.byId('native').focus(); // blur combo so onfocus fires
201 combo = dijit.byId(this.combo);
202 },
203 runTest: function(){
204 var d = new doh.Deferred();
205 doh.is("", combo.get("value"), "value");
206 doh.is("", combo.get('displayedValue'), "displayedValue");
207 doh.is("Select a New England State", combo._phspan.innerHTML, "_phspan.innerHTML");
208 doh.isNot("none", combo._phspan.style.display, "_phspan.style.display 1");
209
210 var handler = dojo.connect(combo.textbox, "onfocus", function(){
211 dojo.disconnect(handler);
212 setTimeout(d.getTestCallback(function(){
213 doh.isNot("none", combo._phspan.style.display, "_phspan.style.display 2");
214 }), 0);
215 });
216 combo.focus();
217 return d;
218 }
219 },
220 {
221 timeout: 5000,
222 name: "blur empty",
223 runTest: function(){
224 var d = new doh.Deferred();
225 var handler = dojo.connect(dojo.byId('native'), "onfocus", function(){
226 dojo.disconnect(handler);
227 setTimeout(d.getTestCallback(function(){
228 doh.is("", combo.get("value"), "value");
229 doh.is("", combo.get('displayedValue'), "displayedValue");
230 doh.isNot("none", combo._phspan.style.display, "_phspan.style.display");
231 }), 0);
232 });
233 dojo.byId('native').focus(); // blur combo
234 return d;
235 }
236 },
237 {
238 timeout: 5000,
239 name: "focus non enpty",
240 combo: "placeholdertest",
241 setUp: function(){
242 dojo.byId('native').focus(); // blur combo so onfocus fires
243 combo = dijit.byId(this.combo);
244 },
245 runTest: function(){
246 var d = new doh.Deferred();
247 var value = isComboBox? 'Connecticut' : 'ct';
248 combo.set("value", value);
249 doh.is(value, combo.get("value"), "value");
250 doh.is("none", combo._phspan.style.display, "_phspan.style.display 1");
251
252 var handler = dojo.connect(combo.textbox, "onfocus", function(){
253 dojo.disconnect(handler);
254 setTimeout(d.getTestCallback(function(){
255 doh.is("none", combo._phspan.style.display, "_phspan.style.display 2");
256 }), 0);
257 });
258 combo.focus();
259 return d;
260 }
261 },
262 {
263 timeout: 5000,
264 name: "blur non empty",
265 runTest: function(){
266 var d = new doh.Deferred();
267 var value = isComboBox? 'Connecticut' : 'ct';
268 var handler = dojo.connect(dojo.byId('native'), "onfocus", function(){
269 dojo.disconnect(handler);
270 setTimeout(d.getTestCallback(function(){
271 doh.is(value, combo.get("value"), "value");
272 doh.is("none", combo._phspan.style.display, "_phspan.style.display");
273 doh.is('Connecticut', combo.textbox.value, "textbox.value");
274 }), 0);
275 });
276 dojo.byId('native').focus(); // blur combo
277 return d;
278 }
279 },
280 {
281 timeout: 5000,
282 name: "re-empty",
283 runTest: function(){
284 var d = new doh.Deferred();
285 var handler = dojo.connect(combo, "onChange", function(){
286 dojo.disconnect(handler);
287 setTimeout(d.getTestCallback(function(){
288 doh.is("", combo.get("value"), "value");
289 doh.is("", combo.get("displayedValue"), "displayedValue");
290 doh.isNot("none", combo._phspan.style.display, "_phspan.style.display");
291 }), 0);
292 });
293 combo.set("value", '');
294 return d;
295 }
296 }
297 ]);
298
299 if(!isComboBox) {
300
301 var fsStore;
302
303 doh.register("FilteringSelect data", [
304 function setupMemoryStore() {
305 fsStore = new dojo.store.Memory({
306 data: [{
307 id: 1,
308 name: "one",
309 value: "one"
310 }, {
311 id: 2,
312 name: "two",
313 value: "two"
314 }, {
315 id: 3,
316 name: "three",
317 value: "three"
318 }]
319 });
320 },{
321 timeout: 5000,
322 name: "set store after construction",
323 runTest: function() {
324 var fs = new dijit.form.FilteringSelect({});
325 fs.set('store', fsStore);
326 doh.is(fs.get('store'), fsStore);
327 fs.destroy();
328 }
329 },{
330 timeout: 5000,
331 name: "set store and place after construction",
332 runTest: function() {
333 var fs = new dijit.form.FilteringSelect({});
334 var ele = document.getElementById("filteringSelect");
335 fs.set('store', fsStore);
336 fs.placeAt(ele);
337 doh.is(fs.domNode, ele.firstChild);
338 fs.destroy();
339 }
340 }, {
341 timeout: 5000,
342 name: "set store and value after construction",
343 runTest: function() {
344 var fs = new dijit.form.FilteringSelect({});
345 var ele = document.getElementById("filteringSelect");
346 fs.set('store', fsStore);
347 fs.placeAt(ele);
348 fs.set('value', 2);
349 doh.is(fs.get("displayedValue"), fsStore.get(2).name);
350 fs.destroy();
351 }
352 }
353 ]);
354 }
355
356 doh.register("asynchronous data store", [
357 {
358 timeout:5000,
359 name:"total",
360 runTest: function(){
361 var d = new doh.Deferred();
362 var combo = dijit.byId("slow");
363 var handler = dojo.connect(combo, "onSearch", function(results, query, options){
364 dojo.disconnect(handler);
365 d.getTestCallback(function(){
366 doh.is(30, options.start, "start");
367 doh.is(4, results.length, "count");
368 doh.is(61, results.total, "total");
369 })();
370 });
371 combo._set('fetchProperties', { start:30, count:4 });
372 combo._startSearch("");
373 return d;
374 },
375 tearDown:function(){
376 dijit.byId("slow").closeDropDown();
377 }
378 }
379 ]);
380
381 doh.run();
382 }
383 dojo.ready(init);
384
385 function toggleDisabled(button, widget){
386 widget = dijit.byId(widget);
387 button = dojo.byId(button);
388 widget.set('disabled',!widget.disabled);
389 button.innerHTML= widget.disabled ? "Enable" : "Disable";
390 }
391
392 function getValue(){
393 var f = document.getElementById("form1");
394 var s = "";
395 for(var i = 0; i < f.elements.length; i++){
396 var elem = f.elements[i];
397 if(elem.nodeName.toLowerCase() == "button" || elem.type=="submit" || elem.type=="button") { continue; }
398 s += elem.name + ": " + elem.value + "\n";
399 }
400 return s;
401 }
402
403 // formSubmitted flag is for benefit of DOH test harneess
404 formSubmitted = false;
405 function onFormSubmit(){
406 formSubmitted = true;
407 console.log(getValue());
408 return false;
409 }
410 </script>
411 </head>
412
413 <body class="claro" role="main">
414
415 <h1 class="testTitle" id="title"></h1>
416 <script>dojo.byId('title').appendChild(document.createTextNode(testWidget+" Unit Test"))</script>
417 <form id="form1" action="#" method="GET" onsubmit="return onFormSubmit();">
418
419 <!--
420 Need a submit button like this (rather than onsubmit handler on <form>) to get
421 IE to submit when the ENTER key is pressed.
422
423 And (at least on IE8) when ComboBox_a11y.html is run via runTests.html,
424 it only seems to work if the button is at the top of the form, not at the bottom.
425 -->
426 <button type="reset">reset</button>
427 <button type="submit">fake submit</button><br/>
428 <hr>
429
430 <p>Option tags, autoComplete=false, selectOnClick=true, default value of California, pageSize=30, custom labelFunc method</p>
431 <label id="setvaluetest_mylabel" for="setvaluetest">US State test 1 (200% Courier font):</label>
432 <script type="text/javascript">
433 function setValueTestOnChange(newValue){
434 if(this.lastlabelFuncMsg){
435 this.lastlabelFuncMsg = '';
436 }
437 dojo.byId('oc1').value = newValue;
438 var itemLabel;
439 if(this.item === null){
440 itemLabel = "null";
441 if(testWidget != "dijit.form.ComboBox" && this.isValid() && this.textbox.value != ''){
442 console.error(this.id + ' has a null item, onChange value = ' + newValue + ', widget value = ' + this.value + ', displayed Value = ' + this.textbox.value);
443 this.itemError = true;
444 }
445 }else if(typeof this.item === "undefined"){
446 itemLabel = "undefined";
447 console.error(this.id + ' has an undefined item, onChange value = ' + newValue + ', widget value = ' + this.value + ', displayed Value = ' + this.textbox.value);
448 this.itemError = true;
449 }else{
450 itemLabel = this.item[this.searchAttr].toString();
451 }
452 dojo.byId('i1').value = itemLabel;
453 }
454 function setValueTestLabelFunc(item, store){
455 var label = item[this.searchAttr];
456 var value = item.value;
457 if(!this.labelFuncCount){ this.labelFuncCount = 0; }
458 if(!this.labelFuncCounts){ this.labelFuncCounts = []; }
459 if(!this.labelFuncCounts[value]){ this.labelFuncCounts[value] = 0; }
460 this.labelFuncCount++;
461 this.labelFuncCounts[value]++;
462 this.lastlabelFuncMsg = 'my labelfunc ' + label + ' (' + value + '), count = ' + this.labelFuncCounts[value];
463 return label + ' (' + value + ')';
464 }
465 </script>
466 <select id="setvaluetest" data-dojo-type="$testWidget"
467 data-dojo-props='name:"state1",
468 style:{width:"50%", fontSize:"200%", fontFamily:"Courier"},
469 autoComplete:false,
470 selectOnClick:true,
471 onBlur:function(){ dojo.byId("b1").value=dijit.byId("setvaluetest").value },
472 onClick:function(){ console.log("onclick"); },
473 pageSize:30,
474 labelFunc:setValueTestLabelFunc,
475 onChange:setValueTestOnChange
476 '>
477 <option value="AL">Alabama</option>
478 <option value="AK">Alaska</option>
479 <option value="AS">American Samoa</option>
480 <option value="AZ">Arizona</option>
481 <option value="AR">Arkansas</option>
482 <option value="AE">Armed Forces Europe</option>
483 <option value="AP">Armed Forces Pacific</option>
484 <option value="AA">Armed Forces the Americas</option>
485 <option value="CA" selected>California</option>
486 <option value="CO">Colorado</option>
487 <option value="CT">Connecticut</option>
488 <option value="DE">Delaware</option>
489 <option value="DC">District of Columbia</option>
490 <option value="FM">Federated States of Micronesia</option>
491 <option value="FL">Florida</option>
492 <option value="GA">Georgia</option>
493 <option value="GU">Guam</option>
494 <option value="HI">Hawaii</option>
495 <option value="ID">Idaho</option>
496 <option value="IL">Illinois</option>
497 <option value="IN">Indiana</option>
498 <option value="IA">Iowa</option>
499 <option value="KS">Kansas</option>
500 <option value="KY">Kentucky</option>
501 <option value="LA">Louisiana</option>
502 <option value="ME">Maine</option>
503 <option value="MH">Marshall Islands</option>
504 <option value="MD">Maryland</option>
505 <option value="MA">Massachusetts</option>
506 <option value="MI">Michigan</option>
507 <option value="MN">Minnesota</option>
508 <option value="MS">Mississippi</option>
509 <option value="MO">Missouri</option>
510 <option value="MT">Montana</option>
511 <option value="NE">Nebraska</option>
512 <option value="NV">Nevada</option>
513 <option value="NH">New Hampshire</option>
514 <option value="NJ">New Jersey</option>
515 <option value="NM">New Mexico</option>
516 <option value="NY">New York</option>
517 <option value="NC">North Carolina</option>
518 <option value="ND">North Dakota</option>
519 <option value="MP">Northern Mariana Islands</option>
520 <option value="OH">Ohio</option>
521 <option value="OK">Oklahoma</option>
522 <option value="OR">Oregon</option>
523 <option value="PA">Pennsylvania</option>
524 <option value="PR">Puerto Rico</option>
525 <option value="RI">Rhode Island</option>
526 <option value="SC">South Carolina</option>
527 <option value="SD">South Dakota</option>
528 <option value="TN">Tennessee</option>
529 <option value="TX">Texas</option>
530 <option value="UT">Utah</option>
531 <option value="VT">Vermont</option>
532 <option value="VI">Virgin Islands, U.S.</option>
533 <option value="VA">Virginia</option>
534 <option value="WA">Washington</option>
535 <option value="WV">West Virginia</option>
536 <option value="WI">Wisconsin</option>
537 <option value="WY">Wyoming</option>
538 </select>
539 <br><label for="oc1">onChange:</label><input id="oc1" disabled value="not fired yet!" autocomplete="off"/>
540 <br><label for="v1">value:</label><input id="v1" disabled value="not fired yet!" autocomplete="off"/>
541 <br><label for="b1">blur:</label><input id="b1" disabled value="not fired yet!" autocomplete="off"/>
542 <br><label for="i1">this.item:</label><input id="i1" disabled value="no onChange yet!" autocomplete="off"/>
543 <input type="button" id="sv1_1" value="Set displayed value to Kentucky" onClick="dijit.byId('setvaluetest').set('displayedValue', 'Kentucky')"/>
544 <input type="button" id="sv1_2" value="Set displayed value to Canada" onClick="dijit.byId('setvaluetest').set('displayedValue', 'Canada')"/>
545 <input type="button" id="sv1_3" value="Set value to null" onClick="dijit.byId('setvaluetest').set('value', null)"/>
546 <input type="button" id="sv1_4" value="Get value" onClick="dojo.byId('v1').value=dijit.byId('setvaluetest').get('value')"/>
547
548 <hr>
549
550 <div data-dojo-id="stateStore" data-dojo-type="dojo/data/ItemFileReadStore" data-dojo-props='url:"../_data/states.json"'></div>
551 <div data-dojo-id="slowStateStore" data-dojo-type="dijit/tests/_data/SlowStore" data-dojo-props='url:"../_data/states.json"'></div>
552
553 <div data-dojo-id="dijitStore" data-dojo-type="dojo/data/ItemFileReadStore" data-dojo-props='url:"../_data/dijits.json"'></div>
554
555 <p>Data store, autoComplete=true:</p>
556 <label for="datatest">US State test 2 (8pt font):</label>
557 <input id="datatest" data-dojo-type="$testWidget"
558 data-dojo-props='value: (testWidget == "dijit.form.ComboBox") ? "California" : "CA",
559 store:stateStore,
560 searchAttr:"name",
561 style:{width:"200px", fontSize:"8pt"},
562 name:"state2",
563 onChange:setVal2
564 '/>
565 <br><label for="value2">onChange:</label><input id="value2" disabled value="not fired yet!" autocomplete="off"/>
566 <hr>
567 <p>Artificially slowed-down data store, autoComplete=true:</p>
568 <label for="slow">US State test slow:</label>
569 <input id="slow" data-dojo-type="$testWidget"
570 data-dojo-props='value: (testWidget == "dijit.form.ComboBox") ? "California" : "CA",
571 store:slowStateStore,
572 searchAttr:"name",
573 name:"stateSlow",
574 onChange:function(val){ dojo.byId("ocSlow").value = val; }
575 '/>
576 <br><label for="ocSlow">onChange:</label><input id="ocSlow" disabled value="not fired yet!" autocomplete="off"/>
577 <button id="slowDestroy" type="button" onclick="dijit.byId('slow').destroy();return false">Destroy widget to test in-flight query cancel</button>
578 <hr>
579
580 <label for="datatestDijit">Dijit List test #1 (150% font):</label>
581 <input id="datatestDijit" data-dojo-type="$testWidget"
582 data-dojo-props='value:"dijit.Editor",
583 store:dijitStore,
584 searchAttr:"className",
585 style:{width:"200px",fontSize:"150%"},
586 name:"dijitList1"
587 '/>
588 <span>Hey look, this one is kind of useful.</span>
589 <hr>
590
591 <p>Initially disabled, url, autoComplete=false:</p>
592 <label for="combo3">US State test 3:</label>
593 <input id="combo3" data-dojo-type="$testWidget"
594 data-dojo-props='value:(testWidget == "dijit.form.ComboBox") ? "California" : "CA",
595 store:stateStore,
596 searchAttr:"name",
597 style:{width:"300px"},
598 name:"state3",
599 autoComplete:false,
600 onChange:setVal3,
601 disabled:true
602 '/>
603 <br><label for="value3">onChange:</label><input id="value3" disabled value="not fired yet!" autocomplete="off"/>
604 <div>
605 <button id="combo3_disable" type="button" onclick='toggleDisabled("combo3_disable", "combo3"); return false;' tabIndex="-1">Enable</button>
606 </div>
607 <hr>
608 <p>Data store, autoComplete=false required=true and highlightMatch="none"</p>
609 <label for="combobox4">US State test 4:</label>
610 <input id="combobox4" data-dojo-type="$testWidget"
611 data-dojo-props='value:"",
612 store:stateStore,
613 searchAttr:"name",
614 style:{width:"300px"},
615 name:"state4",
616 onChange:setVal4,
617 autoComplete:false,
618 required:true,
619 highlightMatch:"none"
620 '/>
621 <br><label for="value4">onChange:</label><input id="value4" disabled value="not fired yet!" autocomplete="off"/>
622 <hr>
623 <p>test that title used as label is preserved on input</p>
624 <select id="preservetitletest" data-dojo-type="$testWidget"
625 data-dojo-props='name:"titletest",
626 style:{width:"50%", fontFamily:"Courier"},
627 autoComplete:false,
628 selectOnClick:true,
629 pageSize:5,
630 title:"New England States"
631 '>
632 <option value="ct">Connecticut</option>
633 <option value="me">Maine</option>
634 <option value="ma">Massachusetts</option>
635 <option value="nh">New Hampshire</option>
636 <option value="vt">Vermont</option>
637 </select>
638 <hr>
639 <p>No arrow, data store which searches and highlights matches anywhere in the string</p>
640 <label for="arrowless">Arrowless:</label>
641 <input id="arrowless" data-dojo-type="$testWidget"
642 data-dojo-props='value: (testWidget == "dijit.form.ComboBox") ? "California" : "CA",
643 store:stateStore,
644 searchAttr:"name",
645 queryExpr:"*${0}*",
646 name:"state5",
647 autoComplete:false,
648 hasDownArrow:false,
649 highlightMatch:"all"
650 '/>
651 <hr>
652 <p>Created programmatically</p>
653 <label for="progCombo">progCombo:</label>
654 <input id="progCombo"/>
655 <hr>
656 <p>Created programmatically with an initial query. (Limits list to items with type = country.)</p>
657 <label for="progCombo2">progCombo2</label>
658 <input id="progCombo2"/>
659 <hr>
660 <p>Created programmatically with an ItemFileReadStore and a descending sort. (Limits list to items with type = country.)</p>
661 <label for="progCombo3">progCombo3:</label>
662 <input id="progCombo3"/>
663 <hr>
664 <p>With option tags, autoComplete=true, pageSize=30, and a descending sort.</p>
665 <label for="descending">descending:</label>
666 <select id="descending" data-dojo-type="$testWidget"
667 data-dojo-props='name:"descending",
668 style:{width:"50%",fontSize:"200%",fontFamily:"Courier"},
669 autoComplete:true,
670 pageSize:30,
671 fetchProperties:{sort:[{attribute: "name", descending: true}]}
672 '>
673 <option value="AL">Alabama</option>
674 <option value="AK">Alaska</option>
675 <option value="AS">American Samoa</option>
676 <option value="AZ">Arizona</option>
677 <option value="AR">Arkansas</option>
678 <option value="AE">Armed Forces Europe</option>
679 <option value="AP">Armed Forces Pacific</option>
680 <option value="AA">Armed Forces the Americas</option>
681 <option value="CA" selected>California</option>
682 <option value="CO">Colorado</option>
683 <option value="CT">Connecticut</option>
684 <option value="DE">Delaware</option>
685 <option value="DC">District of Columbia</option>
686 <option value="FM">Federated States of Micronesia</option>
687 <option value="FL">Florida</option>
688 <option value="GA">Georgia</option>
689 <option value="GU">Guam</option>
690 <option value="HI">Hawaii</option>
691 <option value="ID">Idaho</option>
692 <option value="IL">Illinois</option>
693 <option value="IN">Indiana</option>
694 <option value="IA">Iowa</option>
695 <option value="KS">Kansas</option>
696 <option value="KY">Kentucky</option>
697 <option value="LA">Louisiana</option>
698 <option value="ME">Maine</option>
699 <option value="MH">Marshall Islands</option>
700 <option value="MD">Maryland</option>
701 <option value="MA">Massachusetts</option>
702 <option value="MI">Michigan</option>
703 <option value="MN">Minnesota</option>
704 <option value="MS">Mississippi</option>
705 <option value="MO">Missouri</option>
706 <option value="MT">Montana</option>
707 <option value="NE">Nebraska</option>
708 <option value="NV">Nevada</option>
709 <option value="NH">New Hampshire</option>
710 <option value="NJ">New Jersey</option>
711 <option value="NM">New Mexico</option>
712 <option value="NY">New York</option>
713 <option value="NC">North Carolina</option>
714 <option value="ND">North Dakota</option>
715 <option value="MP">Northern Mariana Islands</option>
716 <option value="OH">Ohio</option>
717 <option value="OK">Oklahoma</option>
718 <option value="OR">Oregon</option>
719 <option value="PA">Pennsylvania</option>
720 <option value="PR">Puerto Rico</option>
721 <option value="RI">Rhode Island</option>
722 <option value="SC">South Carolina</option>
723 <option value="SD">South Dakota</option>
724 <option value="TN">Tennessee</option>
725 <option value="TX">Texas</option>
726 <option value="UT">Utah</option>
727 <option value="VT">Vermont</option>
728 <option value="VI">Virgin Islands, U.S.</option>
729 <option value="VA">Virginia</option>
730 <option value="WA">Washington</option>
731 <option value="WV">West Virginia</option>
732 <option value="WI">Wisconsin</option>
733 <option value="WY">Wyoming</option>
734 </select>
735 <hr>
736 <p>Special characters</p>
737 <p>The drop down list should be:</p>
738 <ul>
739 <li>sticks &amp; stones</li>
740 <li>rags --&gt; riches to</li>
741 <li>more\less</li>
742 <li>3 * 5</li>
743 </ul>
744 <label for="specialchars">Special chars:</label>
745 <select id="specialchars" data-dojo-type="$testWidget"
746 data-dojo-props='name:"specialchars"
747 '>
748 <option value="sticks" selected>sticks &amp; stones</option>
749 <option value="rags">rags --&gt; riches to</option>
750 <option value="more">more\less</option>
751 <option value="times">3 * 5</option>
752 </select>
753 <hr>
754 <p>Japanese</p>
755 <p>Try typing &#x6771;&#x533A; (East), &#x897F;&#x533A; (West), &#x5317;&#x533A; (North), &#x5357;&#x533A; (South) and a few choices will pop up.<br>
756 Using the Microsoft IME for Japanese (Hiragana), &#x6771; can be inputed by typing higashi followed by SPACE.
757 </p>
758 <label for="japanese">Japanese list:</label>
759 <select id="japanese" data-dojo-type="$testWidget" data-dojo-props='name:"japanese", style:{width:"300px"}, autoComplete:true, required:true, value:""'>
760 <option value="nanboku">&#x5357;&#x5317; (Nanboku)</option>
761 <option value="touzai">&#x6771;&#x897F; (Touzai)</option>
762 <option value="toukyou">&#x6771;&#x4EAC; (Tokyo)</option>
763 <option value="higashiku">&#x6771;&#x533A; (East)</option>
764 <option value="nishiku">&#x897F;&#x533A; (West)</option>
765 <option value="minamiku">&#x5357;&#x533A; (South)</option>
766 <option value="kitaku">&#x5317;&#x533A; (North)</option>
767 </select>
768 <hr>
769 <p>Custom labelFunc (labels in lowercase), autoComplete=true, prompt message when field is blank:</p>
770 <label for="labelFunc">custom label function</label>
771 <input id="labelFunc" data-dojo-type="$testWidget"
772 data-dojo-props='value: (testWidget == "dijit.form.ComboBox") ? "Oregon" : "OR",
773 labelFunc:myLabelFunc,
774 store:stateStore,
775 name:"labelFunc",
776 autoComplete:true,
777 labelAttr:"label",
778 labelType:"html",
779 promptMessage:"Please enter a state",
780 invalidMessage:"Invalid state name."
781 '/>
782 <input type="button" onclick="dijit.byId('labelFunc').set('readOnly',false);" value="Remove readOnly"/>
783 <input type="button" onclick="dijit.byId('labelFunc').set('readOnly',true);" value="Set readOnly"/>
784 <input type="button" onclick="dijit.byId('labelFunc').set('disabled',false);" value="Remove disabled"/>
785 <input type="button" onclick="dijit.byId('labelFunc').set('disabled',true);" value="Set disabled"/>
786 <hr>
787
788 <p>Rich text label</p>
789 <label for="richtexttest">Rich text labels in drop down:</label>
790 <select id="richtexttest" data-dojo-type="$testWidget"
791 data-dojo-props='name:"richtexttest",
792 autoComplete:false,
793 selectOnClick:true,
794 value:"h1",
795 labelType:"html",
796 labelFunc:function(item){ var txt = item.value; return "<"+txt+">"+txt+"</"+txt+">"; }
797 '>
798 <option value="h1">h1</option>
799 <option value="h2">h2</option>
800 <option value="p">p</option>
801 <option value="pre">pre</option>
802 </select>
803 <hr>
804
805 <input type="button" value="Create one in a window" onclick="var win=window.open(window.location);"/>
806
807 </form>
808
809 <hr>
810 <p><label for="placeholdertest">test placeholder</label></p>
811 <select id="placeholdertest" data-dojo-type="$testWidget"
812 data-dojo-props='name:"placetest",
813 style:{width:"50%",fontFamily:"Courier"},
814 autoComplete:false,
815 selectOnClick:true,
816 pageSize:5,
817 placeHolder:"Select a New England State",
818 value:""
819 '>
820 <option value="ct">Connecticut</option>
821 <option value="me">Maine</option>
822 <option value="ma">Massachusetts</option>
823 <option value="nh">New Hampshire</option>
824 <option value="vt">Vermont</option>
825 </select>
826 <p id="nativeLabel">
827 This is some text below the boxes. It shouldn't get pushed out of the way when search results get returned.
828 A native select tag to test IE bleed through problem:
829 </p>
830
831 <select id="native" aria-labelledby="nativeLabel">
832 <option>test for</option>
833 <option>IE bleed through</option>
834 <option>problem</option>
835 </select>
836
837 <label for="combo_01">Destroy test:</label><div id="destroyDiv"
838 ><select id="combo_01" data-dojo-type="$testWidget"
839 data-dojo-props='name:"state",
840 disabled:true,
841 style:{width:"300px"},
842 autoComplete:false'>
843 <option value="AL">Alabama</option>
844 <option value="AK">Alaska</option>
845 <option value="AS">American Samoa</option>
846 <option value="AZ">Arizona</option>
847 <option value="AR">Arkansas</option>
848 <option value="AE">Armed Forces Europe</option>
849 <option value="AP">Armed Forces Pacific</option>
850 </select
851 ></div>
852
853 <br>
854 <fieldset style="position:relative;border:1px solid black;display:inline;">
855 <legend>Highlight test</legend>
856 <div style="border:0;margin:1.5em;">
857 <span style='white-space:nowrap;'>
858 <label for="ignoreCase">ignoreCase:</label><select id="ignoreCase" onchange="dijit.byId('highlight').set('ignoreCase', this.value=='true')">
859 <option value="true" selected>true</option>
860 <option value="false">false</option>
861 </select>
862 <label for="highlightMatch">highlightMatch:</label>
863 <select id="highlightMatch" onchange="dijit.byId('highlight').set('highlightMatch', this.value)">
864 <option value="first" selected>first</option>
865 <option value="all">all</option>
866 <option value="none">none</option>
867 </select>
868 <label for="queryExpr">queryExpr:</label>
869 <select id="queryExpr" onchange="dijit.byId('highlight').set('queryExpr', this.value)">
870 <option value="${0}*" selected>${0}*</option>
871 <option value="*${0}*">*${0}*</option>
872 <option value="*${0}">*${0}</option>
873 </select>
874 </span>
875 <br>
876 <span style='white-space:nowrap;'>
877 <label for="highlight">Highlight test:</label>
878 <select id="highlight" data-dojo-type="$testWidget"
879 data-dojo-props='ignoreCase:true,
880 highlightMatch:"first",
881 autoComplete:false,
882 required:false,
883 labelType:"text",
884 onBlur:function(){ this.set("value",null) },
885 value:""'>
886 <option value="AA">AA</option>
887 <option value="Aa">Aa</option>
888 <option value="aA">aA</option>
889 <option value="aa">aa</option>
890 </select>
891 </span>
892 </div>
893 </fieldset>
894
895 <div id="debugbox"></div>
896
897 <p><label for="subclass">User-defined subclass of ComboBox/FilteringSelect:</label></p>
898 <input id="subclass" data-dojo-type="StateSelect"/>
899
900 <div id="filteringSelect"></div>
901
902 <hr>
903 <p>autoComplete=true</p>
904 <select id="autocompleteon" data-dojo-type="$testWidget"
905 data-dojo-props='name:"autocompleteon",
906 style:{width:"50%", fontFamily:"Courier"},
907 autoComplete:true,
908 selectOnClick:true,
909 pageSize:5,
910 title:"New England States"
911 '>
912 <option value="ct">Connecticut</option>
913 <option value="me">Maine</option>
914 <option value="ma">Massachusetts</option>
915 <option value="nh">New Hampshire</option>
916 <option value="vt">Vermont</option>
917 </select>
918
919 <hr>
920 <p>autoComplete=false</p>
921 <select id="autocompleteoff" data-dojo-type="$testWidget"
922 data-dojo-props='name:"autocompleteon",
923 style:{width:"50%", fontFamily:"Courier"},
924 autoComplete:false,
925 selectOnClick:true,
926 pageSize:5,
927 title:"New England States"
928 '>
929 <option value="ct">Connecticut</option>
930 <option value="me">Maine</option>
931 <option value="ma">Massachusetts</option>
932 <option value="nh">New Hampshire</option>
933 <option value="vt">Vermont</option>
934 </select>
935
936 <hr>
937 <p>type=url</p>
938 <select id="url" data-dojo-type="$testWidget" type="url">
939 <option value="toolkit">http://dojotoolkit.org/</option>
940 <option value="foundation">http://dojofoundation.org/</option>
941 </select>
942
943 </body>
944 </html>