1
1
/*
2
2
3
- jQuery selectBox (version 1.0.6 )
3
+ jQuery selectBox (version 1.0.7 )
4
4
5
5
A cosmetic, styleable replacement for SELECT elements.
6
6
93
93
SHIFT like in normal browser controls
94
94
- Fixed bug where inline controls would not receive focus unless tabbed into
95
95
v1.0.6 (2011-04-29) - Fixed bug where inline controls could be "dragged" when selecting an empty area
96
-
96
+ v1.0.7 (2011-05-18) - Expanded iOS check to include Android devices as well
97
+ - Added autoWidth option; set to false on init to use CSS widths for dropdown menus
97
98
98
99
Known Issues:
99
100
@@ -117,7 +118,7 @@ if(jQuery) (function($) {
117
118
var init = function ( select , data ) {
118
119
119
120
// Disable for iOS devices (their native controls are more suitable for a touch device)
120
- if ( navigator . userAgent . match ( / i P a d | i P h o n e / i) ) return false ;
121
+ if ( navigator . userAgent . match ( / i P a d | i P h o n e | A n d r o i d / i) ) return false ;
121
122
122
123
// Element must be a select control
123
124
if ( select . tagName . toLowerCase ( ) !== 'select' ) return false ;
@@ -129,6 +130,7 @@ if(jQuery) (function($) {
129
130
inline = select . attr ( 'multiple' ) || parseInt ( select . attr ( 'size' ) ) > 1 ;
130
131
131
132
var settings = data || { } ;
133
+ if ( settings . autoWidth === undefined ) settings . autoWidth = true ;
132
134
133
135
// Inherit class names, style, and title attributes
134
136
control
@@ -429,13 +431,16 @@ if(jQuery) (function($) {
429
431
430
432
hideMenus ( ) ;
431
433
432
- // Show menu
434
+ // Auto-width
435
+ if ( settings . autoWidth ) options . css ( 'width' , control . outerWidth ( ) - ( parseInt ( control . css ( 'borderLeftWidth' ) ) + parseInt ( control . css ( 'borderLeftWidth' ) ) ) ) ;
436
+
437
+ // Menu position
433
438
options . css ( {
434
- width : control . outerWidth ( ) - ( parseInt ( control . css ( 'borderLeftWidth' ) ) + parseInt ( control . css ( 'borderLeftWidth' ) ) ) ,
435
439
top : control . offset ( ) . top + control . outerHeight ( ) - ( parseInt ( control . css ( 'borderBottomWidth' ) ) ) ,
436
440
left : control . offset ( ) . left
437
441
} ) ;
438
442
443
+ // Show menu
439
444
switch ( settings . menuTransition ) {
440
445
441
446
case 'fade' :
0 commit comments