Skip to content

Commit e9100c4

Browse files
committed
Added tabindex support, fix #41
1 parent 821d07f commit e9100c4

File tree

8 files changed

+47
-14
lines changed

8 files changed

+47
-14
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.0",
4+
"version": "1.8.1",
55
"keywords": [
66
"select",
77
"selectbox",

dist/jquery.selectric.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* /,'
1010
* /'
1111
*
12-
* Selectric Ϟ v1.8.0 (2014-08-28) - http://lcdsantos.github.io/jQuery-Selectric/
12+
* Selectric Ϟ v1.8.0 (2014-09-01) - http://lcdsantos.github.io/jQuery-Selectric/
1313
*
1414
* Copyright (c) 2014 Leonardo Santos; Dual licensed: MIT/GPL
1515
*
@@ -96,7 +96,8 @@
9696
finalWidth,
9797
optionsLength,
9898
eventTriggers,
99-
isMobile = /android|ip(hone|od|ad)/i.test(navigator.userAgent);
99+
isMobile = /android|ip(hone|od|ad)/i.test(navigator.userAgent),
100+
tabindex = $original.prop('tabindex');
100101

101102
function _init(opts) {
102103
_this.options = $.extend(true, {}, defaults, _this.options, opts);
@@ -204,7 +205,10 @@
204205
isOpen ? _close() : _open(e);
205206
});
206207

207-
$input.prop('disabled', false).off().on({
208+
$input.prop({
209+
tabindex: tabindex,
210+
disabled: false
211+
}).off().on({
208212
keypress: _handleSystemKeys,
209213
keydown: function(e){
210214
_handleSystemKeys(e);
@@ -246,6 +250,8 @@
246250
}
247251
});
248252

253+
$original.prop('tabindex', false);
254+
249255
// Remove styles from items box
250256
// Fix incorrect height when refreshed is triggered with fewer options
251257
$li = $('li', $items.removeAttr('style')).click(function(){
@@ -332,7 +338,7 @@
332338
$('.' + _this.classes.open).removeClass(_this.classes.open);
333339

334340
isOpen = true;
335-
itemsHeight = $items.outerHeight(),
341+
itemsHeight = $items.outerHeight();
336342
itemsInnerHeight = $items.height();
337343

338344
// Give dummy input focus
@@ -440,7 +446,7 @@
440446
if ( isEnabled ){
441447
$items.add($wrapper).add($input).remove();
442448
!preserveData && $original.removeData(pluginName).removeData('value');
443-
$original.off(bindSufix).off(eventTriggers).unwrap().unwrap();
449+
$original.prop('tabindex', tabindex).off(bindSufix).off(eventTriggers).unwrap().unwrap();
444450
isEnabled = false;
445451
}
446452
}

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.

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.0",
3+
"version": "1.8.1",
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.0",
3+
"version": "1.8.1",
44
"title": "jQuery Selectric",
55
"author": {
66
"name": "Leonardo Santos",

src/.jscsrc

426 Bytes
Binary file not shown.

src/.jshintrc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"node": true,
3+
"browser": true,
4+
"esnext": true,
5+
"bitwise": true,
6+
"camelcase": true,
7+
"curly": true,
8+
"eqeqeq": true,
9+
"immed": true,
10+
"indent": 2,
11+
"newcap": true,
12+
"noarg": true,
13+
"quotmark": "single",
14+
"undef": true,
15+
"unused": "vars",
16+
"strict": true,
17+
"globals": {
18+
"$": false,
19+
"jQuery": false
20+
}
21+
}

src/jquery.selectric.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@
7979
finalWidth,
8080
optionsLength,
8181
eventTriggers,
82-
isMobile = /android|ip(hone|od|ad)/i.test(navigator.userAgent);
82+
isMobile = /android|ip(hone|od|ad)/i.test(navigator.userAgent),
83+
tabindex = $original.prop('tabindex');
8384

8485
function _init(opts) {
8586
_this.options = $.extend(true, {}, defaults, _this.options, opts);
@@ -187,7 +188,10 @@
187188
isOpen ? _close() : _open(e);
188189
});
189190

190-
$input.prop('disabled', false).off().on({
191+
$input.prop({
192+
tabindex: tabindex,
193+
disabled: false
194+
}).off().on({
191195
keypress: _handleSystemKeys,
192196
keydown: function(e){
193197
_handleSystemKeys(e);
@@ -229,6 +233,8 @@
229233
}
230234
});
231235

236+
$original.prop('tabindex', false);
237+
232238
// Remove styles from items box
233239
// Fix incorrect height when refreshed is triggered with fewer options
234240
$li = $('li', $items.removeAttr('style')).click(function(){
@@ -315,7 +321,7 @@
315321
$('.' + _this.classes.open).removeClass(_this.classes.open);
316322

317323
isOpen = true;
318-
itemsHeight = $items.outerHeight(),
324+
itemsHeight = $items.outerHeight();
319325
itemsInnerHeight = $items.height();
320326

321327
// Give dummy input focus
@@ -423,7 +429,7 @@
423429
if ( isEnabled ){
424430
$items.add($wrapper).add($input).remove();
425431
!preserveData && $original.removeData(pluginName).removeData('value');
426-
$original.off(bindSufix).off(eventTriggers).unwrap().unwrap();
432+
$original.prop('tabindex', tabindex).off(bindSufix).off(eventTriggers).unwrap().unwrap();
427433
isEnabled = false;
428434
}
429435
}

0 commit comments

Comments
 (0)