Skip to content

Commit 0eedd04

Browse files
committed
Added onRefresh option, added inheritOriginalWidth option, changed from Grunt to gulp
1 parent 3a611e6 commit 0eedd04

12 files changed

+85
-144
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package.json
2-
Gruntfile.js
2+
gulpfile.js
33
node_modules
44
.npm-debug.log
5-
tmp
5+
tmp
6+
.sass-cache

Gruntfile.js

Lines changed: 0 additions & 102 deletions
This file was deleted.

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ Initialize **jQuery Selectric:**
214214
```html
215215
<script>
216216
$(function(){
217-
$('select').selectric();
217+
$('select').selectric();
218218
});
219219
</script>
220220
```
@@ -246,6 +246,12 @@ $(function(){
246246
<td>Function</td>
247247
<td>Function called when select options close</td>
248248
</tr>
249+
<tr>
250+
<td>onRefresh</td>
251+
<td>function() {}</td>
252+
<td>Function</td>
253+
<td>Function called when the Selectric is refreshed</td>
254+
</tr>
249255
<tr>
250256
<td>maxHeight</td>
251257
<td>300</td>
@@ -315,6 +321,12 @@ $(function(){
315321
<td>Boolean</td>
316322
<td>Prevent scroll on window when using mouse wheel inside options box to match common browsers behavior.</td>
317323
</tr>
324+
<tr>
325+
<td>inheritOriginalWidth</td>
326+
<td>false</td>
327+
<td>Boolean</td>
328+
<td>Inherit width from original element</td>
329+
</tr>
318330
</table>
319331

320332
##Public methods:

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.2",
4+
"version": "1.7.3",
55
"keywords": [
66
"select",
77
"selectbox",

dist/jquery.selectric.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* /,'
1010
* /'
1111
*
12-
* Selectric Ϟ v1.7.2 - http://lcdsantos.github.io/jQuery-Selectric/
12+
* Selectric Ϟ v1.7.3 (2014-08-25) - http://lcdsantos.github.io/jQuery-Selectric/
1313
*
1414
* Copyright (c) 2014 Leonardo Santos; Dual licensed: MIT/GPL
1515
*
@@ -24,6 +24,7 @@
2424
defaults = {
2525
onOpen: $.noop,
2626
onClose: $.noop,
27+
onRefresh: $.noop,
2728
onChange: function(elm) { $(elm).change(); },
2829
maxHeight: 300,
2930
keySearchTimeout: 500,
@@ -33,6 +34,7 @@
3334
expandToItemText: false,
3435
responsive: false,
3536
preventWindowScroll: true,
37+
inheritOriginalWidth: false,
3638
customClass: {
3739
prefix: pluginName,
3840
postfixes: classList,
@@ -102,7 +104,8 @@
102104

103105
// Generate classNames for elements
104106
var customClass = _this.options.customClass,
105-
postfixes = customClass.postfixes.split(' ');
107+
postfixes = customClass.postfixes.split(' '),
108+
originalWidth = $original.width();
106109

107110
$.each(classList.split(' '), function(i, elm){
108111
var c = customClass.prefix + postfixes[i];
@@ -119,13 +122,17 @@
119122
open : _open,
120123
close : _close,
121124
destroy : _destroy,
122-
refresh : _populate,
125+
refresh : _refresh,
123126
init : _init
124127
};
125128

126129
$original.on(eventTriggers).wrap('<div class="' + _this.classes.hideselect + '">');
127130
$.extend(_this, eventTriggers);
128131

132+
if ( _this.options.inheritOriginalWidth && originalWidth > 0 ) {
133+
$outerWrapper.width(originalWidth);
134+
}
135+
129136
isEnabled = true;
130137

131138
_populate();
@@ -241,6 +248,11 @@
241248
$input.prop('disabled', true);
242249
}
243250

251+
function _refresh() {
252+
_this.options.onRefresh(element);
253+
_populate();
254+
}
255+
244256
// Behavior when system keys is pressed
245257
function _handleSystemKeys(e) {
246258
var key = e.keyCode || e.which;

dist/jquery.selectric.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/selectric.css

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/*======================================================================
2+
Selectric
3+
======================================================================*/
14
.selectricWrapper {
25
position: relative;
36
margin: 0 0 10px;
@@ -15,7 +18,6 @@
1518
position: relative;
1619
border-radius: 2px;
1720
}
18-
1921
.selectric .label {
2022
display: block;
2123
white-space: nowrap;
@@ -27,7 +29,6 @@
2729
color: #444;
2830
min-height: 18px;
2931
}
30-
3132
.selectric .button {
3233
display: block;
3334
position: absolute;
@@ -38,9 +39,9 @@
3839
color: #BBB;
3940
text-align: center;
4041
font: 0/0 a;
41-
*font: 20px/30px Lucida Sans Unicode,Arial Unicode MS,Arial;
42+
/* IE Fix */
43+
*font: 20px/30px Lucida Sans Unicode, Arial Unicode MS, Arial;
4244
}
43-
4445
.selectric .button:after {
4546
content: " ";
4647
position: absolute;
@@ -59,25 +60,20 @@
5960
.selectricHover .selectric {
6061
border-color: #CCC;
6162
}
62-
6363
.selectricHover .selectric .button {
6464
color: #888;
6565
}
66-
6766
.selectricHover .selectric .button:after {
6867
border-top-color: #888;
6968
}
7069

7170
.selectricOpen {
7271
z-index: 9999;
7372
}
74-
7573
.selectricOpen .selectric {
7674
border-color: #CCC;
7775
background: #F0F0F0;
78-
z-index: 9999;
7976
}
80-
8177
.selectricOpen .selectricItems {
8278
display: block;
8379
}
@@ -87,7 +83,10 @@
8783
opacity: 0.5;
8884
cursor: default;
8985
-webkit-touch-callout: none;
90-
user-select: none;
86+
-webkit-user-select: none;
87+
-moz-user-select: none;
88+
-ms-user-select: none;
89+
user-select: none;
9190
}
9291

9392
.selectricHideSelect {
@@ -96,7 +95,6 @@
9695
width: 0;
9796
height: 0;
9897
}
99-
10098
.selectricHideSelect select {
10199
position: absolute;
102100
left: -100%;
@@ -125,6 +123,7 @@
125123
display: block !important;
126124
}
127125

126+
/* Items box */
128127
.selectricItems {
129128
display: none;
130129
position: absolute;
@@ -133,24 +132,21 @@
133132
left: 0;
134133
background: #F9F9F9;
135134
border: 1px solid #CCC;
136-
z-index: 9998;
135+
z-index: -1;
137136
box-shadow: 0 0 10px -6px;
138137
}
139-
140138
.selectricAbove .selectricItems {
141139
top: auto;
142140
bottom: 100%;
143141
}
144-
145-
.selectricItems ul,.selectricItems li {
142+
.selectricItems ul, .selectricItems li {
146143
list-style: none;
147144
padding: 0;
148145
margin: 0;
149146
font-size: 12px;
150147
line-height: 20px;
151148
min-height: 20px;
152149
}
153-
154150
.selectricItems li {
155151
display: block;
156152
padding: 5px;
@@ -159,21 +155,18 @@
159155
color: #666;
160156
cursor: pointer;
161157
}
162-
163158
.selectricItems li.selected {
164159
background: #EFEFEF;
165160
color: #444;
166161
border-top-color: #E0E0E0;
167162
}
168-
169163
.selectricItems li:hover {
170164
background: #F0F0F0;
171165
color: #444;
172166
}
173-
174167
.selectricItems li.disabled {
175168
background: #F5F5F5;
176169
color: #BBB;
177170
border-top-color: #FAFAFA;
178171
cursor: default;
179-
}
172+
}

0 commit comments

Comments
 (0)