-
Notifications
You must be signed in to change notification settings - Fork 229
/
test_CheckedMultiSelectNonDropDown.html
205 lines (199 loc) · 5.81 KB
/
test_CheckedMultiSelectNonDropDown.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<!DOCTYPE html>
<html>
<head>
<title>dojox.form.CheckedMultiSelect</title>
<link rel="stylesheet" id="themeStyles" href="../../../dijit/themes/claro/claro.css">
<link rel="stylesheet" href="../resources/CheckedMultiSelect.css">
<style>
@import url(../../../dojo/resources/dojo.css);
@import url(../../../dijit/tests/css/dijitTests.css);
.ark {
text-decoration: underline;
}
td {
vertical-align: top;
}
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" data-dojo-config="isDebug: true, parseOnLoad: true">
</script>
<script src="../../../dijit/tests/_testCommon.js">
</script>
<script type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dojox.form.CheckedMultiSelect");
dojo.require("dijit.form.Button");
dojo.require("dijit.form.Form");
dojo.require("dojo.data.ItemFileWriteStore");
var data = {
identifier: "value",
label: "label",
items: [{
value: "AL",
label: "Alabama",
selected: true
}, {
value: "AK",
label: "Alaska"
}, {
value: "AZ",
label: "Arizona",
selected: true
}, {
value: "AR",
label: "Arkansas"
}, {
value: "CA",
label: "California"
}, {
value: "CO",
label: "Colorado"
}, {
value: "CT",
label: "Connecticut"
}]
};
var readStore = new dojo.data.ItemFileReadStore({
data: dojo.clone(data)
});
var writeStore = new dojo.data.ItemFileWriteStore({
data: dojo.clone(data)
});
var checkOptions = 0;
var radioOptions = 0;
var addNum = 10;
var testType;
// Uncomment below line to run perf tests - note SLOW to run
//testType = "perf";
</script>
</head>
<body class="claro">
<h1 class="testTitle">Test: dojox.form.CheckedMultiSelect</h1>
<h2>Non-dojo select (for comparison)</h2>
<select>
<option value ="volvo">Volvo</option>
<option value ="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
<form dojoType="dijit.form.Form" data-dojo-id="form">
<hr><h2>Multi-select</h2>
<table>
<tr>
<td>
<select data-dojo-id="ms1" multiple="true" name="ms1" dojoType="dojox.form.CheckedMultiSelect" dropdown="false">
<option value="TN">Tennessee</option>
<option value="VA" selected="selected">Virginia</option>
<option value="WA" selected="selected">Washington</option>
<option value="FL">Florida</option>
<option value="CA">California</option>
</select>
</td>
<td>
<button dojoType="dijit.form.Button">
<script type="dojo/method" data-dojo-event="onClick">
ms1.invertSelection(true);
return false;
</script>
Invert Selection
</button>
<button dojoType="dijit.form.Button">
<script type="dojo/method" data-dojo-event="onClick">
ms1.set("disabled", !ms1.disabled);
return false;
</script>
Toggle Disabled
</button>
<button dojoType="dijit.form.Button">
<script type="dojo/method" data-dojo-event="onClick">
console.log(ms1.get("displayedValue"));
return false;
</script>
Get Displayed Value
</button>
</td>
<tr>
<td>
<select data-dojo-id="ms2" multiple="true" name="ms2" dojoType="dojox.form.CheckedMultiSelect" dropdown="false">
<option value="UT">Utah</option>
<option value="TX" selected="selected">Texas</option>
<option value="GA" selected="selected">Georgia</option>
<option value="ID">Idaho</option>
<option value="WY">Wyoming</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
</select>
</td>
<td>
<button dojoType="dijit.form.Button">
<script type="dojo/method" data-dojo-event="onClick">
ms2.set("readOnly", !ms2.readOnly);
return false;
</script>
Toggle Read Only
</button>
</td>
</tr>
<tr>
<td>
<select data-dojo-id="ms3" multiple="true" maxHeight="125" name="ms3" dojoType="dojox.form.CheckedMultiSelect" dropdown="false">
</select>
</td>
<td>
<button dojoType="dijit.form.Button">
<script type="dojo/method" data-dojo-event="onClick">
checkOptions++;
ms3.addOption({value: checkOptions + "", label: "Option " + (checkOptions)});
return false;
</script>
Add Check Option
</button>
<button dojoType="dijit.form.Button">
<script type="dojo/method" data-dojo-event="onClick">
if(checkOptions > 0){
checkOptions--;
ms3.removeOption(checkOptions);
}
return false;
</script>
Remove Check Option
</button>
</td>
</tr>
<tr>
<td>
<select data-dojo-id="ms4" multiple="true" maxHeight="125" size="5" name="ms4" store="readStore" dojoType="dojox.form.CheckedMultiSelect" dropdown="false">
</select>
</td>
<td>
Read-Store-based
</td>
</tr>
</table>
<hr><h2>Validation</h2>
<select data-dojo-id="rq1" multiple="true" required="true" name="rq1" store="readStore" dojoType="dojox.form.CheckedMultiSelect" invalidMessage="You need to select at least one" dropdown="false">
</select>
<button dojoType="dijit.form.Button">
Validate
<script type='dojo/method' data-dojo-event='onClick'>
var isvalid = rq1.isValid();
console.warn("isvalid?", isvalid, form, form.validate);
try{
rq1.validate();
form.validate();
}catch(e){
console.log(e);
}
console.warn("validated");
</script>
</button>
<hr><h2>Output values in console</h2>
<button dojoType="dijit.form.Button">
<script type="dojo/method" data-dojo-event="onClick">
console.dir(form.get("value"));
return false;
</script>
Get Values
</button>
</form>
</body>
</html>