forked from ehynds/jquery-ui-multiselect-widget
-
Notifications
You must be signed in to change notification settings - Fork 1
/
examples.htm
256 lines (227 loc) · 8.8 KB
/
examples.htm
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery UI MultiSelect Widget by Eric Hynds</title>
<link type="text/css" rel="stylesheet" href="http://www.erichynds.com/examples/style.css" />
<link type="text/css" rel="stylesheet" href="jquery.multiselect.css" />
<link type="text/css" rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/redmond/jquery-ui.css" />
<style type="text/css">
h2 { font-size:14px; padding:0; margin:25px 0 5px 0 }
p { margin:5px 0; padding:0 }
#callback { color:green; font-weight:bold }
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.js" type="text/javascript"></script>
<script src="http://jqueryui.com/themeroller/themeswitchertool/" type="text/javascript"></script>
<script src="src/jquery.multiselect.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
// themeswitcher
$("#switcher").themeswitcher();
$("#example-basic, #example-presets, #example-optgroup").multiselect();
// effects
$("select[name=example-custom]").multiselect({
show: ['slide', 500],
hide:'slide',
checkAllText: 'All',
uncheckAllText: 'None',
selectedText: function(numChecked, numTotal, checkedItems){
return numChecked + ' of ' + numTotal + ' checked';
}
});
// callbacks
var $callback = $("#callback");
$("select[name=example-callbacks]").multiselect({
check: function(){
$callback.html(this.value + ' ' + (this.checked ? 'checked' : 'unchecked') );
},
open: function(){
$callback.html("Select opened!");
},
close: function(){
$callback.html("Select closed!");
},
checkAll: function(){
$callback.html("Check all clicked!");
},
uncheckAll: function(){
$callback.html("Uncheck all clicked!");
},
optgroupToggle: function(checkboxes){
var checked = $(checkboxes).is(":checked");
var values = [];
$.each(checkboxes, function(i,box){
values[i] = box.value;
});
$callback.html("Checkboxes " + (checked ? "checked" : "unchecked") + ": " + values.join(', ') );
}
});
// Options displayed in comma-separated list
$("#example-list").multiselect({
minWidth: 400,
selectedList: 5
});
// disabled
var $widget = $("#example-disabled").multiselect(), state = true;
$("#toggle-disabled").click(function(){
state = !state;
$widget.multiselect(state ? 'disable' : 'enable');
});
// radio
$("#example-radio").multiselect({
multiple: false,
noneSelectedText: "Select an option",
header: false,
selectedText: function(numChecked,numInputs,input){
return $(input).attr("title") + " selected";
}
});
$("form").submit(function(e){
var data = $(this).serialize();
alert( data.length ? data : 'Nothing to serialize; check a box or two' );
e.preventDefault();
});
});
</script>
</head>
<body>
<div id="bar">
<h1><a href="http://www.erichynds.com">eric<span>hynds</span></a></h1>
<!-- <div><a href="http://www.erichynds.com/jquery/visualizing-your-z-index-stacks-with-jquery">« Return to Blog Post</a></div> -->
</div>
<div id="content">
<h1>jQuery UI MultiSelect Widget - Examples</h1>
<div id="switcher"></div>
<form action="" method="post">
<h2>Basic</h2>
<p>
<select title="Basic example" id="example-basic" name="example-basic" multiple="multiple" size="5">
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
<option value="option3">Option 3</option>
<option value="option4">Option 4</option>
<option value="option5">Option 5</option>
<option value="option6">Option 6</option>
<option value="option7">Option 7</option>
<option value="option8">Option 8</option>
<option value="option9">Option 9</option>
<option value="option10">Option 10</option>
<option value="option11">Option 11</option>
<option value="option12">Option 12</option>
</select>
</p>
<h2>Custom</h2>
<p>
<select name="example-custom" multiple="multiple" size="5" style="width:300px">
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
<option value="option3">Option 3</option>
<option value="option4">Option 4</option>
<option value="option5">Option 5</option>
<option value="option5">Option 6</option>
<option value="option5">Option 7</option>
<option value="option5">Option 8</option>
<option value="option5">Option 9</option>
<option value="option5">Option 10</option>
<option value="option5">Option 11</option>
<option value="option5">Option 12</option>
</select>
</p>
<h2>Pre-selected & disabled options</h2>
<p>Options one, three, and four have the <code>selected="selected"</code> attribute and are checked by default. Options five and six have the <code>disabled="disabled"</code> attribute.</p>
<p>
<select id="example-presets" name="example-presets" multiple="multiple" size="5">
<option value="option1" selected="selected">Option 1</option>
<option value="option2">Option 2</option>
<option value="option3" selected="selected">Option 3</option>
<option value="option4" selected="selected">Option 4</option>
<option value="option5" disabled="disabled">Option 5</option>
<option value="option6" disabled="disabled">Option 6</option>
<option value="option7">Option 7</option>
<option value="option8">Option 8</option>
<option value="option9">Option 9</option>
</select>
</p>
<h2>Disable the entire widget</h2>
<p>
<select id="example-disabled" name="example-disabled" disabled="disabled" multiple="multiple" size="5">
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
<option value="option3">Option 3</option>
<option value="option4">Option 4</option>
<option value="option5">Option 5</option>
</select>
<div><button type="button" name="toggle" id="toggle-disabled">Toggle Disabled</button></div>
</p>
<h2>Optgroup support</h2>
<p>Click on an optgroup's heading to toggle the checked state of the entire group.</p>
<p>
<select id="example-optgroup" name="example-optgroup" multiple="multiple" size="5">
<optgroup label="Group One">
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
<option value="option3">Option 3</option>
</optgroup>
<optgroup label="Group Two">
<option value="option4">Option 4</option>
<option value="option5">Option 5</option>
<option value="option6">Option 6</option>
<option value="option7">Option 7</option>
</optgroup>
</select>
</p>
<h2>onOpen, onClose, onCheck, onCheckAll, onUncheckAll, and onOptgroupToggle callbacks</h2>
<p>
<p id="callback">Callback target</p>
<select name="example-callbacks" multiple="multiple" size="5">
<optgroup label="Group One">
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
<option value="option3">Option 3</option>
</optgroup>
<optgroup label="Group Two">
<option value="option4">Option 4</option>
<option value="option5">Option 5</option>
<option value="option6">Option 6</option>
<option value="option7">Option 7</option>
</optgroup>
</select>
</p>
<h2>Displaying options in a list</h2>
<p>A function is passed to the <code>selectedText</code> parameter which returns a list of the items selected,
as long as 5 or less checkboxes are checked. Once 5 or more checkboxes have been checked, <code>selectedText</code>
returns the number checked. <code>minWidth</code> is set to 400 (pixels).</p>
<p>
<select id="example-list" name="example-list" multiple="multiple" size="5">
<option value=""></option>
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
<option value="option3">Option 3</option>
<option value="option4">Option 4</option>
<option value="option5">Option 5</option>
<option value="option6">Option 6</option>
<option value="option7">Option 7</option>
</select>
</p>
<h2>Single select (radio buttons instead of checkboxes)</h2>
<p>Force users to select only one option by using radio buttons instead of checkboxes.</p>
<p>
<select id="example-radio" name="example-radio" multiple="multiple" size="5">
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
<option value="option3">Option 3</option>
<option value="option4">Option 4</option>
<option value="option5">Option 5</option>
<option value="option6">Option 6</option>
<option value="option7">Option 7</option>
</select>
</p>
<p> </p>
<select><option value="">Select to test IE6 bgiframe</option></select><br /><br />
<input type="submit" name="submit" value="Click to Serialize" />
<input type="reset" name="reset" value="Reset" />
</form>
</div>
</body>
</html>