78f645764f3ab1e16066ac998644269c4ff80f75.svn-base 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2. "http://www.w3.org/TR/html4/strict.dtd">
  3. <html>
  4. <head>
  5. <title>Dojo FilteringSelect Widget Test</title>
  6. <style type="text/css">
  7. @import "../../../dojo/resources/dojo.css";
  8. @import "../css/dijitTests.css";
  9. </style>
  10. <script type="text/javascript" src="../../../dojo/dojo.js"
  11. djConfig="isDebug: true, parseOnLoad: true"></script>
  12. <script type="text/javascript" src="../_testCommon.js"></script>
  13. <script type="text/javascript">
  14. dojo.require("dijit.form.FilteringSelect");
  15. dojo.require("dojo.parser"); // scan page for widgets and instantiate them
  16. function setValue(id, val){
  17. dojo.byId(id).value=val;
  18. }
  19. function myLabelFunc(item, store){
  20. var label=store.getValue(item, 'name');
  21. // DEMO: uncomment to chop off a character
  22. //label=label.substr(0, label.length-1);
  23. // DEMO: uncomment to set to lower case
  24. label = label.toLowerCase();
  25. return label;
  26. }
  27. </script>
  28. </head>
  29. <body>
  30. <h1 class="testTitle">Dojo FilteringSelect Widget Test</h1>
  31. <div dojoType="dojo.data.ItemFileReadStore" jsId="myStore"
  32. url="../_data/states.json"></div>
  33. <div dojoType="dojo.data.ItemFileReadStore" jsId="myStore2"
  34. url="../_data/countries.json"></div>
  35. <p>The FilteringSelect widget is an enhanced version of HTML's &lt;select&gt; tag.</p>
  36. <p>Similar features:</p>
  37. <ul>
  38. <li>There is a drop down list of possible values.</li>
  39. <li>You can only enter a value from the drop down list. (You can't enter an arbitrary value.)</li>
  40. <li>The value submitted with the form is the hidden value (ex: CA),</li>
  41. <li>not the displayed value a.k.a. label (ex: California)</li>
  42. </ul>
  43. <p></p>
  44. <p>Enhancements over plain HTML version:</p>
  45. <ul>
  46. <li>If you type in some text then it will filter down the list of possible values in the drop down list.</li>
  47. <li>List can be specified either as a static list or via a javascript function (that can get the list from a server)</li>
  48. </ul>
  49. <p></p>
  50. <hr>
  51. <form action="#" method="GET">
  52. <p>FilteringSelect #1: inlined data, autoComplete=false:</p>
  53. <label for="setvaluetest2">state list 1:</label>
  54. <select dojoType="dijit.form.FilteringSelect"
  55. id="setvaluetest2"
  56. name="state1"
  57. autoComplete="false"
  58. invalidMessage="Invalid state name"
  59. onChange="dojo.byId('oc1').value=arguments[0]"
  60. >
  61. <option value="blank"></option>
  62. <option value="AL">Alabama</option>
  63. <option value="AK">Alaska</option>
  64. <option value="AS">American Samoa</option>
  65. <option value="AZ">Arizona</option>
  66. <option value="AR">Arkansas</option>
  67. <option value="AE">Armed Forces Europe</option>
  68. <option value="AP">Armed Forces Pacific</option>
  69. <option value="AA">Armed Forces the Americas</option>
  70. <option value="CA" selected>California</option>
  71. <option value="CO">Colorado</option>
  72. <option value="CT">Connecticut</option>
  73. <option value="DE">Delaware</option>
  74. <option value="DC">District of Columbia</option>
  75. <option value="FM">Federated States of Micronesia</option>
  76. <option value="FL">Florida</option>
  77. <option value="GA">Georgia</option>
  78. <option value="GU">Guam</option>
  79. <option value="HI">Hawaii</option>
  80. <option value="ID">Idaho</option>
  81. <option value="IL">Illinois</option>
  82. <option value="IN">Indiana</option>
  83. <option value="IA">Iowa</option>
  84. <option value="KS">Kansas</option>
  85. <option value="KY">Kentucky</option>
  86. <option value="LA">Louisiana</option>
  87. <option value="ME">Maine</option>
  88. <option value="MH">Marshall Islands</option>
  89. <option value="MD">Maryland</option>
  90. <option value="MA">Massachusetts</option>
  91. <option value="MI">Michigan</option>
  92. <option value="MN">Minnesota</option>
  93. <option value="MS">Mississippi</option>
  94. <option value="MO">Missouri</option>
  95. <option value="MT">Montana</option>
  96. <option value="NE">Nebraska</option>
  97. <option value="NV">Nevada</option>
  98. <option value="NH">New Hampshire</option>
  99. <option value="NJ">New Jersey</option>
  100. <option value="NM">New Mexico</option>
  101. <option value="NY">New York</option>
  102. <option value="NC">North Carolina</option>
  103. <option value="ND">North Dakota</option>
  104. <option value="MP">Northern Mariana Islands</option>
  105. <option value="OH">Ohio</option>
  106. <option value="OK">Oklahoma</option>
  107. <option value="OR">Oregon</option>
  108. <option value="PA">Pennsylvania</option>
  109. <option value="PR">Puerto Rico</option>
  110. <option value="RI">Rhode Island</option>
  111. <option value="SC">South Carolina</option>
  112. <option value="SD">South Dakota</option>
  113. <option value="TN">Tennessee</option>
  114. <option value="TX">Texas</option>
  115. <option value="UT">Utah</option>
  116. <option value="VT">Vermont</option>
  117. <option value="VI">Virgin Islands, U.S.</option>
  118. <option value="VA">Virginia</option>
  119. <option value="WA">Washington</option>
  120. <option value="WV">West Virginia</option>
  121. <option value="WI">Wisconsin</option>
  122. <option value="WY">Wyoming</option>
  123. </select>
  124. onChange:<input id="oc1" disabled value="not fired yet!" autocomplete="off">
  125. <input type="button" value="Set displayed value to Kentucky (valid)" onClick="dijit.byId('setvaluetest2').setDisplayedValue('Kentucky')">
  126. <input type="button" value="Set displayed value to Canada (invalid)" onClick="dijit.byId('setvaluetest2').setDisplayedValue('Canada')">
  127. <hr>
  128. <div dojoType="dojo.data.ItemFileReadStore" jsId="stateStore"
  129. url="../_data/states.json"></div>
  130. <p>FilteringSelect #2: url, autoComplete=true:</p>
  131. <label for="setvaluetest">state list 2:</label>
  132. <input searchAttr="name"
  133. id="setvaluetest"
  134. dojoType="dijit.form.FilteringSelect"
  135. store="stateStore"
  136. name="state2"
  137. autoComplete="true"
  138. onChange="setValue('value2', arguments[0]);"
  139. invalidMessage="Invalid state name"
  140. >
  141. <span>Value: <input id="value2" disabled></span>
  142. <p>FilteringSelect #3: url, autoComplete=false:</p>
  143. <label for="state3">state list 3:</label>
  144. <input searchAttr="name"
  145. id="state3"
  146. dojoType="dijit.form.FilteringSelect"
  147. value="VI"
  148. store="stateStore"
  149. name="state3"
  150. autoComplete="false"
  151. onChange="setValue('value3', arguments[0]);"
  152. invalidMessage="Invalid state name."
  153. >
  154. <span>Value: <input id="value3" disabled value="VI"></span>
  155. <hr>
  156. <p>FilteringSelect #5: custom labelFunc (value in textbox should be lower case when onChange is called), autoComplete=true:</p>
  157. <label for="state5">state list 5:</label>
  158. <input searchAttr="name"
  159. id="state5"
  160. dojoType="dijit.form.FilteringSelect"
  161. value="OR"
  162. labelFunc="myLabelFunc"
  163. store="stateStore"
  164. name="state5"
  165. autoComplete="true"
  166. labelAttr="label"
  167. labelType="html"
  168. dataProviderClass="dojo.data.ItemFileReadStore"
  169. promptMessage="Please enter a state"
  170. invalidMessage="Invalid state name."
  171. >
  172. <br>
  173. <hr>
  174. <p>FilteringSelect #7: Input method editor Chinese characters</p>
  175. <p>Using an input method editor (see <a href="http://www.microsoft.com/windows/ie/ie6/downloads/recommended/ime/default.mspx">IME</a> for Windows) try typing &#38463; (a) or &#25226; (ba).</p>
  176. <label for="state7">Chinese list:</label>
  177. <select dojoType="dijit.form.FilteringSelect"
  178. name="state7"
  179. id="state7"
  180. >
  181. <option value="a" selected>&#38463;</option>
  182. <option value="ba">&#25226;</option>
  183. </select>
  184. <br>
  185. <hr>
  186. <p>FilteringSelect #8: Japanese</p>
  187. <p>Try typing 東、西、北、南 (north, south, east west) and a few choices will pop up.</p>
  188. <label for="state8">Japanese list:</label>
  189. <select name="state8" id="state8" dojoType="dijit.form.FilteringSelect" style="width: 300px;" autoComplete="false"
  190. onChange="setValue('value8', arguments[0]);">
  191. <option value="nanboku">南北</option>
  192. <option value="touzai">東西</option>
  193. <option value="toukyou">東京</option>
  194. <option value="higashiguchi">東口</option>
  195. <option value="nishiguchi">西口</option>
  196. <option value="minamiguchi">南口</option>
  197. <option value="kitaguchi">北口</option>
  198. <option value="higashiku">東区</option>
  199. <option value="nishiku">西区</option>
  200. <option value="minamiku">南区</option>
  201. <option value="kitaku">北区</option>
  202. </select>
  203. <span>Value: <input id="value8" disabled value="nanboku"></span>
  204. <hr>
  205. <p>FilteringSelect #9: No data</p>
  206. <p>This FilteringSelect has no options to choose from. It should still load.</p>
  207. <label for="state9">empty list:</label>
  208. <select name="state9" id="state9" dojoType="dijit.form.FilteringSelect" style="width: 300px;" autoComplete="false">
  209. </select>
  210. <br>
  211. <hr>
  212. <p>FilteringSelect #10: hasDownArrow=false:</p>
  213. <label for="state10">no arrow list:</label>
  214. <input searchAttr="name"
  215. dojoType="dijit.form.FilteringSelect"
  216. value="AL"
  217. name="state10"
  218. id="state10"
  219. autoComplete="false"
  220. store="myStore"
  221. invalidMessage="Invalid state name."
  222. hasDownArrow="false"
  223. >
  224. <br>
  225. <hr>
  226. <div >
  227. <p>FilteringSelect #11: deep data, initial query of type=country:</p>
  228. <label for="state11">query list:</label>
  229. <input searchAttr="name"
  230. dojoType="dijit.form.FilteringSelect"
  231. query={type:'country'}
  232. value="United States of America"
  233. name="state11"
  234. id="state11"
  235. autoComplete="false"
  236. store="myStore2"
  237. invalidMessage="Choose a country from the list."
  238. hasDownArrow="false"
  239. >
  240. <br>
  241. <hr>
  242. <input type="submit">
  243. </form>
  244. <p>
  245. this is some text below the combo boxes. It shouldn't get pushed out of
  246. the way when search results get returned. also: adding a simple combo
  247. box to test IE bleed through problem:
  248. </p>
  249. <select>
  250. <option>test for</option>
  251. <option">IE bleed through</option>
  252. <option>problem</option>
  253. </select>
  254. <!-- maintain state of select if user presses back/forward button -->
  255. <form name="_dojo_form" style="display:none" disabled="true"><textarea name="stabile" cols="80" rows="10"></textarea></form>
  256. </body>
  257. </html>