Skip to content

Commit 32e0b25

Browse files
committed
Added some callbacks, added a new div inside options box for better control, updated CSS
1 parent 2968b4b commit 32e0b25

File tree

10 files changed

+445
-228
lines changed

10 files changed

+445
-228
lines changed

README.md

Lines changed: 109 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ Include **jQuery Selectric:**
2828
Put styles in your CSS and change it to your taste :D
2929

3030
```css
31+
/*======================================================================
32+
Selectric
33+
======================================================================*/
3134
.selectricWrapper {
3235
position: relative;
3336
margin: 0 0 10px;
@@ -45,7 +48,6 @@ Put styles in your CSS and change it to your taste :D
4548
position: relative;
4649
border-radius: 2px;
4750
}
48-
4951
.selectric .label {
5052
display: block;
5153
white-space: nowrap;
@@ -57,7 +59,6 @@ Put styles in your CSS and change it to your taste :D
5759
color: #444;
5860
min-height: 18px;
5961
}
60-
6162
.selectric .button {
6263
display: block;
6364
position: absolute;
@@ -68,9 +69,9 @@ Put styles in your CSS and change it to your taste :D
6869
color: #BBB;
6970
text-align: center;
7071
font: 0/0 a;
71-
*font: 20px/30px Lucida Sans Unicode,Arial Unicode MS,Arial;
72+
/* IE Fix */
73+
*font: 20px/30px Lucida Sans Unicode, Arial Unicode MS, Arial;
7274
}
73-
7475
.selectric .button:after {
7576
content: " ";
7677
position: absolute;
@@ -89,25 +90,20 @@ Put styles in your CSS and change it to your taste :D
8990
.selectricHover .selectric {
9091
border-color: #CCC;
9192
}
92-
9393
.selectricHover .selectric .button {
9494
color: #888;
9595
}
96-
9796
.selectricHover .selectric .button:after {
9897
border-top-color: #888;
9998
}
10099

101100
.selectricOpen {
102101
z-index: 9999;
103102
}
104-
105103
.selectricOpen .selectric {
106104
border-color: #CCC;
107105
background: #F0F0F0;
108-
z-index: 9999;
109106
}
110-
111107
.selectricOpen .selectricItems {
112108
display: block;
113109
}
@@ -117,7 +113,10 @@ Put styles in your CSS and change it to your taste :D
117113
opacity: 0.5;
118114
cursor: default;
119115
-webkit-touch-callout: none;
120-
user-select: none;
116+
-webkit-user-select: none;
117+
-moz-user-select: none;
118+
-ms-user-select: none;
119+
user-select: none;
121120
}
122121

123122
.selectricHideSelect {
@@ -126,7 +125,6 @@ Put styles in your CSS and change it to your taste :D
126125
width: 0;
127126
height: 0;
128127
}
129-
130128
.selectricHideSelect select {
131129
position: absolute;
132130
left: -100%;
@@ -155,32 +153,33 @@ Put styles in your CSS and change it to your taste :D
155153
display: block !important;
156154
}
157155

156+
/* Items box */
158157
.selectricItems {
159158
display: none;
160159
position: absolute;
161-
overflow: auto;
162160
top: 100%;
163161
left: 0;
164162
background: #F9F9F9;
165163
border: 1px solid #CCC;
166-
z-index: 9998;
164+
z-index: -1;
167165
box-shadow: 0 0 10px -6px;
168166
}
169-
167+
.selectricItems .selectricScroll {
168+
height: 100%;
169+
overflow: auto;
170+
}
170171
.selectricAbove .selectricItems {
171172
top: auto;
172173
bottom: 100%;
173174
}
174-
175-
.selectricItems ul,.selectricItems li {
175+
.selectricItems ul, .selectricItems li {
176176
list-style: none;
177177
padding: 0;
178178
margin: 0;
179179
font-size: 12px;
180180
line-height: 20px;
181181
min-height: 20px;
182182
}
183-
184183
.selectricItems li {
185184
display: block;
186185
padding: 5px;
@@ -189,18 +188,15 @@ Put styles in your CSS and change it to your taste :D
189188
color: #666;
190189
cursor: pointer;
191190
}
192-
193191
.selectricItems li.selected {
194192
background: #EFEFEF;
195193
color: #444;
196194
border-top-color: #E0E0E0;
197195
}
198-
199196
.selectricItems li:hover {
200197
background: #F0F0F0;
201198
color: #444;
202199
}
203-
204200
.selectricItems li.disabled {
205201
background: #F5F5F5;
206202
color: #BBB;
@@ -228,27 +224,53 @@ $(function(){
228224
<td><strong>Type</strong></td>
229225
<td><strong>Description</strong></td>
230226
</tr>
227+
<tr>
228+
<td>onBeforeInit</td>
229+
<td><pre><code>function(element) {}</code></pre></td>
230+
<td>Function</td>
231+
<td>Function called before plugin initialize</td>
232+
</tr>
233+
<tr>
234+
<td>onInit</td>
235+
<td><pre><code>function(element) {}</code></pre></td>
236+
<td>Function</td>
237+
<td>Function called plugin has been fully initialized</td>
238+
</tr>
239+
<tr>
240+
<td>onBeforeOpen</td>
241+
<td><pre><code>function(element) {}</code></pre></td>
242+
<td>Function</td>
243+
<td>Function called before select options opens</td>
244+
</tr>
231245
<tr>
232246
<td>onOpen</td>
233-
<td>function() {}</td>
247+
<td><pre><code>function(element) {}</code></pre></td>
234248
<td>Function</td>
235-
<td>Function called when select options open</td>
249+
<td>Function called after select options opens</td>
236250
</tr>
237251
<tr>
238-
<td>onChange</td>
239-
<td>function() {}</td>
252+
<td>onBeforeClose</td>
253+
<td><pre><code>function(element) {}</code></pre></td>
240254
<td>Function</td>
241-
<td>Function called when select options change</td>
255+
<td>Function called before select options closes</td>
242256
</tr>
243257
<tr>
244258
<td>onClose</td>
245-
<td>function() {}</td>
259+
<td><pre><code>function(element) {}</code></pre></td>
246260
<td>Function</td>
247-
<td>Function called when select options close</td>
261+
<td>Function called after select options closes</td>
262+
</tr>
263+
<tr>
264+
<td>onChange</td>
265+
<td><pre><code>function(element) {
266+
&nbsp;&nbsp;$(element).change();
267+
}</code></pre></td>
268+
<td>Function</td>
269+
<td>Function called when select options change</td>
248270
</tr>
249271
<tr>
250272
<td>onRefresh</td>
251-
<td>function() {}</td>
273+
<td><pre><code>function(element) {}</code></pre></td>
252274
<td>Function</td>
253275
<td>Function called when the Selectric is refreshed</td>
254276
</tr>
@@ -329,6 +351,65 @@ $(function(){
329351
</tr>
330352
</table>
331353

354+
##Events
355+
356+
All events are called on original element, first argument is the original element too. And can be bound like this:
357+
358+
```js
359+
$('select').on('selectric-eventname', function(element){
360+
// your code
361+
});
362+
```
363+
364+
`eventname` can be one of the following:
365+
366+
<table>
367+
<tr>
368+
<td><strong>Event name</strong></td>
369+
<td><strong>Description</strong></td>
370+
</tr>
371+
372+
<tr>
373+
<td><code>selectric-before-init</code></td>
374+
<td>Fired before plugin initialize</td>
375+
</tr>
376+
377+
<tr>
378+
<td><code>selectric-init</code></td>
379+
<td>Fired plugin has been fully initialized</td>
380+
</tr>
381+
382+
<tr>
383+
<td><code>selectric-before-open</code></td>
384+
<td>Fired before select options opens</td>
385+
</tr>
386+
387+
<tr>
388+
<td><code>selectric-open</code></td>
389+
<td>Fired after select options opens</td>
390+
</tr>
391+
392+
<tr>
393+
<td><code>selectric-before-close</code></td>
394+
<td>Fired before select options closes</td>
395+
</tr>
396+
397+
<tr>
398+
<td><code>selectric-close</code></td>
399+
<td>Fired after select options closes</td>
400+
</tr>
401+
402+
<tr>
403+
<td><code>selectric-change</code></td>
404+
<td>Fired when select options change</td>
405+
</tr>
406+
407+
<tr>
408+
<td><code>selectric-refresh</code></td>
409+
<td>Fired when the Selectric is refreshed</td>
410+
</tr>
411+
</table>
412+
332413
##Public methods:
333414

334415
```js

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jquery-selectric",
33
"description": "Fast, simple and light jQuery plugin to customize HTML selects",
4-
"version": "1.7.3",
4+
"version": "1.8.0",
55
"keywords": [
66
"select",
77
"selectbox",

0 commit comments

Comments
 (0)