Skip to content

Commit 8163d2a

Browse files
committed
Fix #49
1 parent ec1e596 commit 8163d2a

File tree

8 files changed

+35
-43
lines changed

8 files changed

+35
-43
lines changed

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

dist/jquery.selectric.js

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* /,'
1010
* /'
1111
*
12-
* Selectric Ϟ v1.8.3 (2014-09-22) - http://lcdsantos.github.io/jQuery-Selectric/
12+
* Selectric Ϟ v1.8.4 (2014-09-23) - http://lcdsantos.github.io/jQuery-Selectric/
1313
*
1414
* Copyright (c) 2014 Leonardo Santos; Dual licensed: MIT/GPL
1515
*
@@ -163,8 +163,6 @@
163163
if ( _this.options.inheritOriginalWidth && originalWidth > 0 )
164164
$outerWrapper.width(originalWidth);
165165

166-
isEnabled = true;
167-
168166
_populate();
169167
}
170168

@@ -204,18 +202,23 @@
204202
$label.html(_this.items[currValue].text);
205203
}
206204

207-
$wrapper.add($original, $outerWrapper, $input).off(bindSufix);
205+
$wrapper.add($original).add($outerWrapper).add($input).off(bindSufix);
208206

209207
$outerWrapper.prop('class', [_this.classes.wrapper, $original.prop('class').replace(/\S+/g, pluginName + '-$&'), _this.options.responsive ? _this.classes.responsive : ''].join(' '));
210208

211209
if ( !$original.prop('disabled') ){
210+
isEnabled = true;
211+
212212
// Not disabled, so... Removing disabled class and bind hover
213-
$outerWrapper.removeClass(_this.classes.disabled).on('mouseenter' + bindSufix + ' mouseleave' + bindSufix, function(){
213+
$outerWrapper.removeClass(_this.classes.disabled).on('mouseenter' + bindSufix + ' mouseleave' + bindSufix, function(e){
214214
$(this).toggleClass(_this.classes.hover);
215-
});
216215

217-
// Click on label and :focus on original select will open the options box
218-
_this.options.openOnHover && $wrapper.on('mouseenter' + bindSufix, _open);
216+
// Delay close effect when openOnHover is true
217+
if ( _this.options.openOnHover ){
218+
clearTimeout(_this.closeTimer);
219+
e.type == 'mouseleave' ? _this.closeTimer = setTimeout(_close, 500) : _open();
220+
}
221+
});
219222

220223
// Toggle open/close
221224
$wrapper.on('click' + bindSufix, function(e){
@@ -382,14 +385,6 @@
382385
});
383386
}
384387

385-
// Delay close effect when openOnHover is true
386-
if ( _this.options.openOnHover ){
387-
clearTimeout(_this.closeTimer);
388-
$outerWrapper.one('mouseleave' + bindSufix, function(){
389-
_this.closeTimer = setTimeout(_close, 500);
390-
});
391-
}
392-
393388
// Toggle options box visibility
394389
$outerWrapper.addClass(_this.classes.open);
395390
_detectItemVisibility(selected);

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.

gulpfile.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ var gulp = require('gulp'),
55
bump = require('gulp-bump'),
66
prefix = require('gulp-autoprefixer');
77

8-
var pkg = require('./package.json');
9-
10-
gulp.task('js', function(){
8+
gulp.task('js', ['bump'], function(){
9+
var pkg = require('./package.json');
1110
var banner = [
1211
'/*!',
1312
' * ,/',
@@ -32,7 +31,8 @@ gulp.task('js', function(){
3231
.pipe(gulp.dest('./dist'));
3332
});
3433

35-
gulp.task('js-min', function(){
34+
gulp.task('js-min', ['bump'], function(){
35+
var pkg = require('./package.json');
3636
gulp.src('src/jquery.selectric.js')
3737
.pipe(uglify())
3838
.pipe(header('/*! Selectric ϟ v<%= pkg.version %> (<%= new Date().toJSON().slice(0,10) %>) - git.io/tjl9sQ - Copyright (c) <%= new Date().getFullYear() %> Leonardo Santos - Dual licensed: MIT/GPL */\n', { pkg: pkg }))
@@ -109,11 +109,13 @@ gulp.task('bump', function(){
109109
var gutil = require('gulp-util'),
110110
newVersion = gutil.env.bump || pkg.version;
111111

112-
gulp.src(['./package.json', './bower.json', './selectric.jquery.json'])
112+
var stream = gulp.src(['./package.json', './bower.json', './selectric.jquery.json'])
113113
.pipe(bump({
114114
version: newVersion
115115
}))
116116
.pipe(gulp.dest('./'));
117+
118+
return stream;
117119
});
118120

119121
gulp.task('default', ['bump', 'js', 'js-min', 'css']);

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,11 +708,11 @@ <h2>Demo</h2>
708708
$(function(){
709709
$('select, .select').selectric();
710710

711-
/*$('.customOptions').selectric({
711+
$('.customOptions').selectric({
712712
optionsItemBuilder: function(itemData, element, index){
713713
return element.val().length ? '<span class="ico ico-' + element.val() + '"></span>' + itemData.text : itemData.text;
714714
}
715-
});*/
715+
});
716716
});
717717
</script>
718718
</body>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jquery-selectric",
3-
"version": "1.8.3",
3+
"version": "1.8.4",
44
"repository": {
55
"type": "git",
66
"url": "https://github.com/lcdsantos/jQuery-Selectric.git"

selectric.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "selectric",
3-
"version": "1.8.3",
3+
"version": "1.8.4",
44
"title": "jQuery Selectric",
55
"author": {
66
"name": "Leonardo Santos",

src/jquery.selectric.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,6 @@
146146
if ( _this.options.inheritOriginalWidth && originalWidth > 0 )
147147
$outerWrapper.width(originalWidth);
148148

149-
isEnabled = true;
150-
151149
_populate();
152150
}
153151

@@ -187,18 +185,23 @@
187185
$label.html(_this.items[currValue].text);
188186
}
189187

190-
$wrapper.add($original, $outerWrapper, $input).off(bindSufix);
188+
$wrapper.add($original).add($outerWrapper).add($input).off(bindSufix);
191189

192190
$outerWrapper.prop('class', [_this.classes.wrapper, $original.prop('class').replace(/\S+/g, pluginName + '-$&'), _this.options.responsive ? _this.classes.responsive : ''].join(' '));
193191

194192
if ( !$original.prop('disabled') ){
193+
isEnabled = true;
194+
195195
// Not disabled, so... Removing disabled class and bind hover
196-
$outerWrapper.removeClass(_this.classes.disabled).on('mouseenter' + bindSufix + ' mouseleave' + bindSufix, function(){
196+
$outerWrapper.removeClass(_this.classes.disabled).on('mouseenter' + bindSufix + ' mouseleave' + bindSufix, function(e){
197197
$(this).toggleClass(_this.classes.hover);
198-
});
199198

200-
// Click on label and :focus on original select will open the options box
201-
_this.options.openOnHover && $wrapper.on('mouseenter' + bindSufix, _open);
199+
// Delay close effect when openOnHover is true
200+
if ( _this.options.openOnHover ){
201+
clearTimeout(_this.closeTimer);
202+
e.type == 'mouseleave' ? _this.closeTimer = setTimeout(_close, 500) : _open();
203+
}
204+
});
202205

203206
// Toggle open/close
204207
$wrapper.on('click' + bindSufix, function(e){
@@ -365,14 +368,6 @@
365368
});
366369
}
367370

368-
// Delay close effect when openOnHover is true
369-
if ( _this.options.openOnHover ){
370-
clearTimeout(_this.closeTimer);
371-
$outerWrapper.one('mouseleave' + bindSufix, function(){
372-
_this.closeTimer = setTimeout(_close, 500);
373-
});
374-
}
375-
376371
// Toggle options box visibility
377372
$outerWrapper.addClass(_this.classes.open);
378373
_detectItemVisibility(selected);

0 commit comments

Comments
 (0)