forked from shawnchin/jquery-gentleSelect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
366 lines (339 loc) · 13.3 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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
<!DOCTYPE HTML>
<html>
<head>
<title>jquery-gentleSelect : a jQuery plugin</title>
<link type="text/css" href="gentleSelect/jquery-gentleSelect.css" rel="stylesheet" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" src="gentleSelect/jquery-gentleSelect-min.js"></script>
<style>
* { margin: 0; padding: 0; }
body { font-family: Helvetica,Arial,sans-serif; color: #222; background-color: #ddd;line-height: 24px; }
ul { margin-left: 20px; }
h1 { margin: 30px; font-size: 2.5em; font-weight: bold; color: #000; text-align: center; }
h2 { border-bottom: 1px solid #999; margin: 30px 0 10px 0; font-size: 1.3em; color: #555; }
h3 { border-left: 20px solid #999; padding-left: 10px; line-height: 1.2; font-size: 1.1em; color: #333; margin: 30px 0 10px 0; }
p { line-height: 1.3; margin-top: 20px; }
pre { line-height: 1.3; background-color: #369; color: #fff; padding: 10px; margin-top: 20px;}
a { color: #369; font-weight: bold; text-decoration: none; }
a:hover { text-decoration: underline; }
#content { margin: 0 auto; padding: 20px 20px 40px 20px; width: 760px; background-color: #fff; border: 1px solid #777; border-width: 0 1px 0px 1px; }
#footer { margin: 0 auto; padding: 20px; padding-top: 2px; width: 760px; font-size: 0.8em; text-align: center; color: #888; }
</style>
<script type="text/javascript">
$(document).ready(function() {
$('#example1').gentleSelect({
columns: 3,
itemWidth: 100,
title: "Select a fruit",
hideOnMouseOut: true
});
$('#example-multi').gentleSelect({
columns: 3,
itemWidth: 100,
title: "Select some fruit",
prompt: "Select some fruit",
hideOnMouseOut: true
});
$('#example-title').gentleSelect({
title: "Select a colour"
});
$('#example2').gentleSelect();
$('#example3').gentleSelect({
columns: 3,
itemWidth: 100
});
$('#example4').gentleSelect({
rows: 5,
itemWidth: 30
});
$('#example5').gentleSelect({
columns: 3,
itemWidth: 100,
openEffect: "fade",
openSpeed: "slow"
});
$('#example6').gentleSelect({
columns: 3,
itemWidth: 100,
hideOnMouseOut: false
});
});
</script>
</head>
<body>
<div id="content">
<h1>jQuery plugin: gentleSelect</h1>
<h2>Intro</h2>
<p>
gentleSelect is a <a href='http://jquery.com'>jQuery</a> plugin for transforming select boxes into a skinnable alternative.
The selection list can be rendered with multiple columns/rows to present larger datasets in a more manageable format. It
recognizes the <tt>multiple</tt> attribute on select boxes and does the right thing automatically.
</p>
<p>
Here's a gentleSelect box
<select id='example1'>
<option value="1">Apple</option>
<option value="2">Orange</option>
<option value="3">Banana</option>
<option value="4">Mango</option>
<option value="5">Pineapple</option>
<option value="6">Guava</option>
<option value="7">Passion Fruit</option>
<option value="8">Sugar Cane</option>
<option value="9">Durian</option>
<option value="10">Plum</option>
<option value="11">Apricot</option>
<option value="12">Cumquat</option>
</select>
compared to a standard select box
<select>
<option value="1">Apple</option>
<option value="2">Orange</option>
<option value="3">Banana</option>
<option value="4">Mango</option>
<option value="5">Pineapple</option>
<option value="6">Guava</option>
<option value="7">Passion Fruit</option>
<option value="8">Sugar Cane</option>
<option value="9">Durian</option>
<option value="10">Plum</option>
<option value="11">Apricot</option>
<option value="12">Cumquat</option>
</select>
</p>
<p>
And here's a version of that select box which supports multiple selections:
<select id='example-multi' multiple>
<option value="1">Apple</option>
<option value="2">Orange</option>
<option value="3">Banana</option>
<option value="4">Mango</option>
<option value="5">Pineapple</option>
<option value="6">Guava</option>
<option value="7">Passion Fruit</option>
<option value="8">Sugar Cane</option>
<option value="9">Durian</option>
<option value="10">Plum</option>
<option value="11">Apricot</option>
<option value="12">Cumquat</option>
</select>
</p>
<p>
There is much to be done on the flexibility and robustness front, and we welcome contributions
and bug fixes. Feel free to fork <a href='https://github.com/shawnchin/jquery-gentleSelect'>the project</a>
and send us pull requests!
</p>
<h2>Download</h2>
<ul>
<li>Latest Release : <a href='https://github.com/shawnchin/jquery-gentleSelect/zipball/v0.1.2'>gentleSelect v0.1.2</a></li>
<li>If you're feeling brave, download the <a href='https://github.com/shawnchin/jquery-gentleSelect/zipball/master'>Development Version</a></li>
</ul>
<h2>TODO</h2>
<ul>
<li>calculate default <tt>itemWidth</tt> automatically when <tt>columns</tt> or <tt>rows</tt> specified</li>
<li>implement option to fix width of select box (based on longest entry)</li>
<li>implement option to add CSS class (simplify customization)</li>
</ul>
<h2>Usage</h2>
<p>
To use this plugin, one simply needs to load jQuery and the JS/CSS scripts for gentleSelect,
then attach it to your select boxes on DOM ready:
</p>
<pre>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" src="gentleSelect/jquery-gentleSelect.js"></script>
<link type="text/css" href="gentleSelect/jquery-gentleSelect.css" rel="stylesheet" />
<script type="text/javascript">
$(document).ready(function() {
$('#selector').gentleSelect(); // apply gentleSelect with default options
});
</script>
</pre>
<p>
This produces a standard single-column select box as such <select id='example2'>
<option value="1">Apple</option>
<option value="2">Orange</option>
<option value="3">Banana</option>
<option value="4">Mango</option>
<option value="5">Pineapple</option>
<option value="6">Guava</option>
<option value="7">Passion Fruit</option>
<option value="8">Sugar Cane</option>
<option value="9">Durian</option>
<option value="10">Plum</option>
<option value="11">Apricot</option>
<option value="12">Cumquat</option>
</select>
</p>
<h2>Options</h2>
<h3 id='option-title'>title</h3>
<p>
You can specify a heading for the selection box using the <tt>title</tt> option.
</p>
<p>
For example, <select id='example-title'>
<option>Red</option>
<option>Green</option>
<option>Blue</option>
</select>
<pre>
$('#selector').gentleSelect({
title: "Select a colour"
});</pre>
</p>
<h3 id='option-columns'>columns & itemWidth</h3>
<p>
Specifies the number of columns used to display the selection. The number of rows is
calculated accordingly. When specifying <tt>columns</tt>, the <tt>itemWidth</tt> option must also be set. This value must be large enough
to fit the longest option.
</p>
<p>
For example, <select id='example3'>
<option value="1">Apple</option>
<option value="2">Orange</option>
<option value="3">Banana</option>
<option value="4">Mango</option>
<option value="5">Pineapple</option>
<option value="6">Guava</option>
<option value="7">Passion Fruit</option>
<option value="8">Sugar Cane</option>
<option value="9">Durian</option>
<option value="10">Plum</option>
<option value="11">Apricot</option>
<option value="12">Cumquat</option>
</select> can be implemented using:
</p>
<pre>
$('#selector').gentleSelect({
columns: 3,
itemWidth: 100,
});</pre>
<h3 id='option-rows'>rows & itemWidth</h3>
<p>
There may be situations where one might think it would be more suitable to fix the
number of rows instead, allowing the columns to spread out as required.
</p>
<p>
This can be achieved by specifying the <tt>rows</tt> and <tt>itemWidth</tt> options.
</p>
<p>
For example, <select id='example4'>
<option value="1">1st</option>
<option value="1">2nd</option>
<option value="1">3rd</option>
<option value="1">4th</option>
<option value="1">5th</option>
<option value="1">6th</option>
<option value="1">7th</option>
<option value="1">8th</option>
<option value="1">9th</option>
<option value="1">10th</option>
<option value="1">11th</option>
<option value="1">12th</option>
<option value="1">13th</option>
<option value="1">14th</option>
<option value="1">15th</option>
<option value="1">16th</option>
<option value="1">17th</option>
<option value="1">18th</option>
<option value="1">19th</option>
<option value="1">20th</option>
<option value="1">21st</option>
<option value="1">22nd</option>
<option value="1">23rd</option>
<option value="1">24th</option>
<option value="1">25th</option>
<option value="1">26th</option>
<option value="1">27th</option>
<option value="1">28th</option>
<option value="1">29th</option>
<option value="1">30th</option>
<option value="1">31st</option>
</select> can be implemented using:
</p>
<pre>
$('#selector').gentleSelect({
rows: 5,
itemWidth: 30,
});</pre>
<h3 id='option-effect'>openEffect & closeEffect</h3>
<p>
Effects to use for displaying and hiding the selection menu.
Possible options are <tt>'fade'</tt> and <tt>'slide'</tt> (default).
</p>
<h3 id='option-speed'>openSpeed & closeSpeed</h3>
<p>
Specifies the speed of the open/close animation.
This value is specified in milliseconds; higher values indicate slower animations, not faster ones.
The strings <tt>'slow'</tt> and <tt>'fast'</tt> can be supplied to indicate an animation duration of
<tt>600</tt> and <tt>200</tt> milliseconds.
</p>
<p>The default value is <tt>400</tt>.</p>
<p>
For example, <select id='example5'>
<option value="1">Apple</option>
<option value="2">Orange</option>
<option value="3">Banana</option>
<option value="4">Mango</option>
<option value="5">Pineapple</option>
<option value="6">Guava</option>
<option value="7">Passion Fruit</option>
<option value="8">Sugar Cane</option>
<option value="9">Durian</option>
<option value="10">Plum</option>
<option value="11">Apricot</option>
<option value="12">Cumquat</option>
</select> can be implemented using:
</p>
<pre>
$('#selector').gentleSelect({
columns: 3,
itemWidth: 100,
openEffect: "fade",
openSpeed: "slow"
});</pre>
<h3 id='option-mouseout'>hideOnMouseOut</h3>
<p>
Specifies whether the selection menu should be hidden when the mouse leaves the selection box.
This is <tt>true</tt> by default. Set to <tt>false</tt> to disable this behaviour.
</p>
<p>
For example, <select id='example6'>
<option value="1">Apple</option>
<option value="2">Orange</option>
<option value="3">Banana</option>
<option value="4">Mango</option>
<option value="5">Pineapple</option>
<option value="6">Guava</option>
<option value="7">Passion Fruit</option>
<option value="8">Sugar Cane</option>
<option value="9">Durian</option>
<option value="10">Plum</option>
<option value="11">Apricot</option>
<option value="12">Cumquat</option>
</select> (menu only disappears when something is selected)
</p>
<pre>
$('#selector').gentleSelect({
columns: 3,
itemWidth: 100,
hideOnMouseOut: false
});</pre>
<h2>Methods</h2>
<h3 id='method-update'>update</h3>
<p>
If you update the value of the select box using an external script,
you can update the display by calling the <tt>update</tt> function.
</p>
<pre>
// assssuming gentleSelect() previously initialised
$('#selector').val(3).gentleSelect("update");</pre>
</div>
<div id='footer'>
Copyright © 2010 <a href='http://github.com/shawnchin'>Shawn Chin</a>
(Licensed under the <a href='http://www.opensource.org/licenses/mit-license.php'>MIT License</a>)
</div>
<a href="http://github.com/shawnchin/jquery-gentleSelect"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub" /></a>
</body>
</html>