1
1
/*
2
2
3
- jQuery selectBox (version 1.0.4 )
3
+ jQuery selectBox (version 1.0.5 )
4
4
5
5
A cosmetic, styleable replacement for SELECT elements.
6
6
88
88
- Added 'control' method for working directly with the selectBox control
89
89
v1.0.3 (2011-04-22) - Fixed bug in value method that errored if the control didn't exist
90
90
v1.0.4 (2011-04-22) - Fixed bug where controls without any options would render with incorrect heights
91
+ v1.0.5 (2011-04-22) - Removed 'tick' image in lieu of background colors to indicate selection
92
+ - Clicking no longer toggles selected/unselected in multi-selects; use CTRL/CMD and
93
+ SHIFT like in normal browser controls
94
+ - Fixed bug where inline controls would not receive focus unless tabbed into
91
95
92
96
93
97
Known Issues:
@@ -300,14 +304,11 @@ if(jQuery) (function($) {
300
304
} )
301
305
. bind ( 'mousedown.selectBox' , function ( event ) {
302
306
event . preventDefault ( ) ; // Prevent options from being "dragged"
307
+ if ( ! select . selectBox ( 'control' ) . hasClass ( 'selectBox-active' ) ) select . selectBox ( 'control' ) . focus ( ) ;
303
308
} )
304
309
. bind ( 'mouseup.selectBox' , function ( event ) {
305
310
hideMenus ( ) ;
306
- if ( event . shiftKey ) {
307
- selectOption ( select , $ ( this ) . parent ( ) , true ) ;
308
- } else {
309
- selectOption ( select , $ ( this ) . parent ( ) , false ) ;
310
- }
311
+ selectOption ( select , $ ( this ) . parent ( ) , event ) ;
311
312
} ) ;
312
313
313
314
disableSelection ( options ) ;
@@ -496,7 +497,7 @@ if(jQuery) (function($) {
496
497
} ;
497
498
498
499
499
- var selectOption = function ( select , li , selectRange ) {
500
+ var selectOption = function ( select , li , event ) {
500
501
501
502
select = $ ( select ) ;
502
503
li = $ ( li ) ;
@@ -508,8 +509,8 @@ if(jQuery) (function($) {
508
509
509
510
if ( select . attr ( 'multiple' ) ) {
510
511
511
- // If selectRange is true, this will select all options between li and the last li selected
512
- if ( selectRange && control . data ( 'selectBox-last-selected' ) ) {
512
+ // If event.shiftKey is true, this will select all options between li and the last li selected
513
+ if ( event . shiftKey && control . data ( 'selectBox-last-selected' ) ) {
513
514
514
515
li . toggleClass ( 'selectBox-selected' ) ;
515
516
@@ -528,8 +529,11 @@ if(jQuery) (function($) {
528
529
affectedOptions . removeClass ( 'selectBox-selected' ) ;
529
530
}
530
531
531
- } else {
532
+ } else if ( event . metaKey ) {
532
533
li . toggleClass ( 'selectBox-selected' ) ;
534
+ } else {
535
+ li . siblings ( ) . removeClass ( 'selectBox-selected' ) ;
536
+ li . addClass ( 'selectBox-selected' ) ;
533
537
}
534
538
535
539
} else {
@@ -639,7 +643,7 @@ if(jQuery) (function($) {
639
643
640
644
case 13 : // enter
641
645
if ( control . hasClass ( 'selectBox-menuShowing' ) ) {
642
- selectOption ( select , options . find ( 'LI.selectBox-hover:first' ) , event . shiftKey ) ;
646
+ selectOption ( select , options . find ( 'LI.selectBox-hover:first' ) , event ) ;
643
647
if ( control . hasClass ( 'selectBox-dropdown' ) ) hideMenus ( ) ;
644
648
} else {
645
649
showMenu ( select ) ;
0 commit comments