forked from marcj/jquery-selectBox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·352 lines (308 loc) · 11.4 KB
/
index.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
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery selectBox (select replacement plugin)</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="jquery.selectBox.js"></script>
<link type="text/css" rel="stylesheet" href="jquery.selectBox.css" />
<script type="text/javascript">
$(document).ready( function() {
//
// Enable selectBox control and bind events
//
$("#create").click( function() {
$("SELECT").selectBox();
});
$("#destroy").click( function() {
$("SELECT").selectBox('destroy');
});
$("#enable").click( function() {
$("SELECT").selectBox('enable');
});
$("#disable").click( function() {
$("SELECT").selectBox('disable');
});
$("#serialize").click( function() {
$("#console").append('<br />-- Serialized data --<br />' + $("FORM").serialize().replace(/&/g, '<br />') + '<br /><br />');
$("#console")[0].scrollTop = $("#console")[0].scrollHeight;
});
$("#value-1").click( function() {
$("SELECT").selectBox('value', 1);
});
$("#value-2").click( function() {
$("SELECT").selectBox('value', 2);
});
$("#value-2-4").click( function() {
$("SELECT").selectBox('value', [2, 4]);
});
$("#options").click( function() {
$("SELECT").selectBox('options', {
'Opt Group 1': {
'1': 'Value 1',
'2': 'Value 2',
'3': 'Value 3',
'4': 'Value 4',
'5': 'Value 5'
},
'Opt Group 2': {
'6': 'Value 6',
'7': 'Value 7',
'8': 'Value 8',
'9': 'Value 9',
'10': 'Value 10'
},
'Opt Group 3': {
'11': 'Value 11',
'12': 'Value 12',
'13': 'Value 13',
'14': 'Value 14',
'15': 'Value 15'
}
});
});
$("#default").click( function() {
$("SELECT").selectBox('settings', {
'menuTransition': 'default',
'menuSpeed' : 0
});
});
$("#fade").click( function() {
$("SELECT").selectBox('settings', {
'menuTransition': 'fade',
'menuSpeed' : 'fast'
});
});
$("#slide").click( function() {
$("SELECT").selectBox('settings', {
'menuTransition': 'slide',
'menuSpeed' : 'fast'
});
});
$("SELECT")
.selectBox()
.focus( function() {
$("#console").append('Focus on ' + $(this).attr('name') + '<br />');
$("#console")[0].scrollTop = $("#console")[0].scrollHeight;
})
.blur( function() {
$("#console").append('Blur on ' + $(this).attr('name') + '<br />');
$("#console")[0].scrollTop = $("#console")[0].scrollHeight;
})
.change( function() {
$("#console").append('Change on ' + $(this).attr('name') + ': ' + $(this).val() + '<br />');
$("#console")[0].scrollTop = $("#console")[0].scrollHeight;
});
});
</script>
</head>
<body style="font-family: Arial, Helvetica, sans-serif; font-size: 14px;">
<form style="background: #FFF; padding: 20px; border: solid 2px #DDD;">
<div id="console" style="width: 50%; font-family: 'Courier New', monospace; border: solid 2px #000; background: #000; color: #FFF; height: 350px; overflow: auto; padding: 10px; float: right;"></div>
<div style="background: #FFFCCC; border: solid 2px #DDD999; padding: 1px 10px; width: 50%; float: right; clear: right; margin: 1em 0;">
<p><strong>Note</strong></p>
<p>
Special thanks to Andrew Becker for providing inspiration and contributions to this project.
</p>
<p>
Refer to <samp><a href="jquery.selectBox.js">jquery.selectBox.js</a></samp>
for usage, known issues, change log, and more info.
</p>
<p>
<a href="http://abeautifulsite.net/blog/2011/01/jquery-selectbox-plugin/">Go to the project homepage</a>
</p>
</div>
<h1>$("SELECT").selectBox();</h1>
<p>
<label for="standard-dropdown">Standard Dropdown</label><br />
<select id="standard-dropdown" name="standard-dropdown" class="custom-class1 custom-class2" style="width: 200px;">
<option value="1" class="test-class-1">Item 1</option>
<option value="2" class="test-class-2" selected="selected">Item 2</option>
<option value="3" class="test-class-3">Item 3 has a really long label that will not interfere with the control's width</option>
<option value="4" class="test-class-4">Item 4</option>
<option value="5" disabled="disabled">Item 5 (disabled)</option>
<option value="6">Item 6</option>
<option value="7">Item 7</option>
<option value="8">Item 8</option>
<option value="9">Item 9</option>
<option value="10">Item 10</option>
<option value="11">Item 11</option>
<option value="12">Item 12</option>
<option value="13">Item 13</option>
<option value="14">Item 14</option>
<option value="15">Item 15</option>
<option value="16">Item 16</option>
<option value="17">Item 17</option>
<option value="18">Item 18</option>
<option value="19">Item 19</option>
<option value="20">Item 20</option>
</select>
</p>
<p>
Empty Dropdown<br />
<select name="empty-dropdown"></select>
</p>
<p>
<label for="multi-select-control">Multi-select Control</label><br />
<select id="multi-select-control" name="multi-select-control" multiple="multiple">
<option value="1" selected="selected">Item 1</option>
<option value="2">Item 2</option>
<option value="3">Item 3</option>
<option value="4">Item 4</option>
<option value="5" disabled="disabled">Item 5 (disabled)</option>
</select>
</p>
<p>
Empty Multi-select<br />
<select name="empty-multi-select" size="5" multiple="multiple"></select>
</p>
<p>
Multi-select with few options<br />
<select name="multi-select-few-options" multiple="multiple" size="5">
<option value="1" selected="selected">Item 1</option>
<option value="2">Item 2</option>
<option value="3">Item 3</option>
</select>
</p>
<p>
No multi-select, size = 4<br />
<select name="no-multi-with-size-4" size="4">
<option value="1" selected="selected">Item 1</option>
<option value="2">Item 2</option>
<option value="3">Item 3 has <a> really long label but it won't affect the control's display at all</option>
<option value="4">Item 4</option>
<option value="5" disabled="disabled">Item 5 (disabled)</option>
</select>
</p>
<p>
Standard control with OPTGROUPS<br />
<select name="standard-with-optgroups">
<optgroup label="Section 1">
<option value="1">Item 1</option>
<option value="2">Item 2</option>
<option value="3">Item 3</option>
<option value="4">Item 4</option>
</optgroup>
<optgroup label="Section 2">
<option value="5">Item 5</option>
<option value="6">Item 6</option>
<option value="7">Item 7</option>
<option value="8">Item 8</option>
</optgroup>
<optgroup label="Section 3">
<option value="9">Item 9</option>
<option value="10">Item 10</option>
<option value="11">Item 11</option>
<option value="12">Item 12</option>
</optgroup>
<optgroup label="Section 4">
<option value="13">Item 13</option>
<option value="14">Item 14</option>
<option value="15">Item 15</option>
<option value="16">Item 16</option>
</optgroup>
<optgroup label="Section 5">
<option value="17">Item 17</option>
<option value="18">Item 18</option>
<option value="19">Item 19</option>
<option value="20">Item 20</option>
</optgroup>
<optgroup label="Section 6">
<option value="21">Item 21</option>
<option value="22">Item 22</option>
<option value="23">Item 23</option>
<option value="24">Item 24</option>
</optgroup>
</select>
</p>
<p>
Multi-select control with OPTGROUPS<br />
<select name="multi-with-optgroups" multiple="multiple">
<optgroup label="Section 1">
<option value="1">Item 1</option>
<option value="2">Item 2</option>
<option value="3">Item 3</option>
<option value="4">Item 4</option>
</optgroup>
<optgroup label="Section 2">
<option value="5">Item 5</option>
<option value="6">Item 6</option>
<option value="7">Item 7</option>
<option value="8">Item 8</option>
</optgroup>
<optgroup label="Section 3">
<option value="9">Item 9</option>
<option value="10">Item 10</option>
<option value="11">Item 11</option>
<option value="12">Item 12</option>
</optgroup>
<optgroup label="Section 4">
<option value="13">Item 13</option>
<option value="14">Item 14</option>
<option value="15">Item 15</option>
<option value="16">Item 16</option>
</optgroup>
<optgroup label="Section 5">
<option value="17">Item 17</option>
<option value="18">Item 18</option>
<option value="19">Item 19</option>
<option value="20">Item 20</option>
</optgroup>
<optgroup label="Section 6">
<option value="21">Item 21</option>
<option value="22">Item 22</option>
<option value="23">Item 23</option>
<option value="24">Item 24</option>
</optgroup>
</select>
</p>
<p>
<label for="obscured-dropdown">Dropdown positioned above control</label> <br />
<select id="obscured-dropdown" name="obscured-dropdown" style="width: 200px">
<option value="1" class="test-class-1">Item 1</option>
<option value="2" class="test-class-2" selected="selected">Item 2</option>
<option value="3" class="test-class-3">Item 3 has a really long label that will not interfere with the control's width</option>
<option value="4" class="test-class-4">Item 4</option>
<option value="5" disabled="disabled">Item 5 (disabled)</option>
<option value="6">Item 6</option>
<option value="7">Item 7</option>
<option value="8">Item 8</option>
<option value="9">Item 9</option>
<option value="10">Item 10</option>
<option value="11">Item 11</option>
<option value="12">Item 12</option>
<option value="13">Item 13</option>
<option value="14">Item 14</option>
<option value="15">Item 15</option>
<option value="16">Item 16</option>
<option value="17">Item 17</option>
<option value="18">Item 18</option>
<option value="19">Item 19</option>
<option value="20">Item 20</option>
</select>
</p>
<hr align="left" style="height: 1px; background-color: #DDD; width: 40%; margin-top: 1.5em; border: 0;" />
<p>
Methods:
<input type="button" id="destroy" value="Destroy" />
<input type="button" id="create" value="Create" />
<input type="button" id="enable" value="Enable" />
<input type="button" id="disable" value="Disable" />
<input type="button" id="serialize" value="Serialize Form" />
</p>
<p>
Values:
<input type="button" id="value-1" value="Value = 1" />
<input type="button" id="value-2" value="Value = 2" />
<input type="button" id="value-2-4" value="Value = [2, 4]" />
<input type="button" id="options" value="Set New Options" />
</p>
<p>
Transitions:
<input type="button" id="default" value="Default" />
<input type="button" id="fade" value="Fade" />
<input type="button" id="slide" value="Slide" />
</p>
<div style="clear: both;"></div>
</form>
</body>
</html>