@@ -38,7 +38,7 @@ $.widget("ui.selectmenu", {
38
38
var self = this , o = this . options ;
39
39
40
40
// set a default id value, generate a new random one if not set by developer
41
- var selectmenuId = this . element . attr ( 'id' ) || 'ui-selectmenu-' + Math . random ( ) . toString ( 16 ) . slice ( 2 , 10 ) ;
41
+ var selectmenuId = this . element . attr ( 'id' ) || 'ui-selectmenu-' + Math . random ( ) . toString ( 16 ) . slice ( 2 , 10 ) ;
42
42
43
43
// quick array of button and menu id's
44
44
this . ids = [ selectmenuId + '-button' , selectmenuId + '-menu' ] ;
@@ -49,20 +49,20 @@ $.widget("ui.selectmenu", {
49
49
// create menu button wrapper
50
50
this . newelement = $ ( '<a />' , {
51
51
'class' : this . widgetBaseClass + ' ui-widget ui-state-default ui-corner-all' ,
52
- 'id' : this . ids [ 0 ] ,
52
+ 'id' : this . ids [ 0 ] ,
53
53
'role' : 'button' ,
54
54
'href' : '#' ,
55
55
'tabindex' : '0' ,
56
56
'aria-haspopup' : true ,
57
- 'aria-owns' : this . ids [ 1 ]
57
+ 'aria-owns' : this . ids [ 1 ]
58
58
} ) ;
59
59
this . newelementWrap = $ ( o . wrapperElement )
60
60
. append ( this . newelement )
61
61
. insertAfter ( this . element ) ;
62
62
63
63
// transfer tabindex
64
64
var tabindex = this . element . attr ( 'tabindex' ) ;
65
- if ( tabindex ) {
65
+ if ( tabindex ) {
66
66
this . newelement . attr ( 'tabindex' , tabindex ) ;
67
67
}
68
68
@@ -390,7 +390,7 @@ $.widget("ui.selectmenu", {
390
390
}
391
391
392
392
// reset height to auto
393
- this . list . css ( " height" , " auto" ) ;
393
+ this . list . css ( ' height' , ' auto' ) ;
394
394
var listH = this . listWrap . height ( ) ;
395
395
// calculate default max height
396
396
if ( o . maxHeight && o . maxHeight < listH ) {
@@ -443,61 +443,62 @@ $.widget("ui.selectmenu", {
443
443
$ . Widget . prototype . destroy . apply ( this , arguments ) ;
444
444
} ,
445
445
446
- _typeAhead : function ( code , eventType ) {
446
+ _typeAhead : function ( code , eventType ) {
447
447
var self = this , focusFound = false , C = String . fromCharCode ( code ) . toUpperCase ( ) ;
448
448
c = C . toLowerCase ( ) ;
449
449
450
- if ( self . options . typeAhead == 'sequential' ) {
450
+ if ( self . options . typeAhead == 'sequential' ) {
451
451
// clear the timeout so we can use _prevChar
452
452
window . clearTimeout ( 'ui.selectmenu-' + self . selectmenuId ) ;
453
453
454
454
// define our find var
455
- var find = typeof ( self . _prevChar ) == 'undefined' ? '' : self . _prevChar . join ( '' ) ;
455
+ var find = typeof ( self . _prevChar ) == 'undefined' ? '' : self . _prevChar . join ( '' ) ;
456
456
457
- function focusOptSeq ( elem , ind , c ) {
457
+ function focusOptSeq ( elem , ind , c ) {
458
458
focusFound = true ;
459
- $ ( elem ) . trigger ( eventType ) ;
460
- typeof ( self . _prevChar ) == 'undefined' ? self . _prevChar = [ c ] : self . _prevChar [ self . _prevChar . length ] = c ;
459
+ $ ( elem ) . trigger ( eventType ) ;
460
+ typeof ( self . _prevChar ) == 'undefined' ? self . _prevChar = [ c ] : self . _prevChar [ self . _prevChar . length ] = c ;
461
461
}
462
- this . list . find ( 'li a' ) . each ( function ( i ) {
463
- if ( ! focusFound ) {
462
+ this . list . find ( 'li a' ) . each ( function ( i ) {
463
+ if ( ! focusFound ) {
464
464
// allow the typeahead attribute on the option tag for a more specific lookup
465
- var thisText = $ ( this ) . attr ( 'typeahead' ) || $ ( this ) . text ( ) ;
466
- if ( thisText . indexOf ( find + C ) == 0 ) {
467
- focusOptSeq ( this , i , C )
468
- } else if ( thisText . indexOf ( find + c ) == 0 ) {
469
- focusOptSeq ( this , i , c )
465
+ var thisText = $ ( this ) . attr ( 'typeahead' ) || $ ( this ) . text ( ) ;
466
+ if ( thisText . indexOf ( find + C ) === 0 ) {
467
+ focusOptSeq ( this , i , C ) ;
468
+ } else if ( thisText . indexOf ( find + c ) === 0 ) {
469
+ focusOptSeq ( this , i , c ) ;
470
470
}
471
471
}
472
472
} ) ;
473
473
// set a 1 second timeout for sequenctial typeahead
474
- // keep this set even if we have no matches so it doesnt typeahead somewhere else
475
- window . setTimeout ( function ( el ) {
474
+ // keep this set even if we have no matches so it doesnt typeahead somewhere else
475
+ window . setTimeout ( function ( el ) {
476
476
self . _prevChar = undefined ;
477
- } , 1000 , self ) ;
477
+ } , 1000 , self ) ;
478
478
479
479
} else {
480
- //define self._prevChar if needed
481
- if ( ! self . _prevChar ) { self . _prevChar = [ '' , 0 ] ; }
480
+ // define self._prevChar if needed
481
+ if ( ! self . _prevChar ) { self . _prevChar = [ '' , 0 ] ; }
482
482
483
- var focusFound = false ;
484
- function focusOpt ( elem , ind ) {
483
+ focusFound = false ;
484
+ function focusOpt ( elem , ind ) {
485
485
focusFound = true ;
486
- $ ( elem ) . trigger ( eventType ) ;
487
- self . _prevChar [ 1 ] = ind ;
486
+ $ ( elem ) . trigger ( eventType ) ;
487
+ self . _prevChar [ 1 ] = ind ;
488
488
}
489
- this . list . find ( 'li a' ) . each ( function ( i ) {
490
- if ( ! focusFound ) {
489
+ this . list . find ( 'li a' ) . each ( function ( i ) {
490
+ if ( ! focusFound ) {
491
491
var thisText = $ ( this ) . text ( ) ;
492
- if ( thisText . indexOf ( C ) == 0 || thisText . indexOf ( c ) == 0 ) {
493
- if ( self . _prevChar [ 0 ] == C ) {
494
- if ( self . _prevChar [ 1 ] < i ) { focusOpt ( this , i ) ; }
495
- }
496
- else { focusOpt ( this , i ) ; }
492
+ if ( thisText . indexOf ( C ) === 0 || thisText . indexOf ( c ) === 0 ) {
493
+ if ( self . _prevChar [ 0 ] == C ) {
494
+ if ( self . _prevChar [ 1 ] < i ) { focusOpt ( this , i ) ; }
495
+ } else {
496
+ focusOpt ( this , i ) ;
497
+ }
497
498
}
498
499
}
499
500
} ) ;
500
- this . _prevChar [ 0 ] = C ;
501
+ this . _prevChar [ 0 ] = C ;
501
502
}
502
503
} ,
503
504
@@ -518,7 +519,7 @@ $.widget("ui.selectmenu", {
518
519
self . newelement . addClass ( 'ui-state-active' ) ;
519
520
520
521
self . listWrap . appendTo ( o . appendTo ) ;
521
- self . list . attr ( 'aria-hidden' , false )
522
+ self . list . attr ( 'aria-hidden' , false ) ;
522
523
523
524
if ( o . style == "dropdown" ) {
524
525
self . newelement . removeClass ( 'ui-corner-all' ) . addClass ( 'ui-corner-top' ) ;
@@ -530,7 +531,7 @@ $.widget("ui.selectmenu", {
530
531
if ( $ . browser . msie && $ . browser . version . substr ( 0 , 1 ) == 7 ) {
531
532
self . _refreshPosition ( ) ;
532
533
}
533
- selected = self . list . attr ( 'aria-hidden' , false ) . find ( 'li:not(.' + self . widgetBaseClass + '-group):eq(' + self . _selectedIndex ( ) + ') a' ) ;
534
+ var selected = self . list . attr ( 'aria-hidden' , false ) . find ( 'li:not(.' + self . widgetBaseClass + '-group):eq(' + self . _selectedIndex ( ) + ') a' ) ;
534
535
if ( selected . length ) selected [ 0 ] . focus ( ) ;
535
536
// positioning needed for FF, Chrome, IE8, IE7, IE6 (tested 01.08.11 on MS VPC Image)
536
537
self . _refreshPosition ( ) ;
@@ -626,8 +627,7 @@ $.widget("ui.selectmenu", {
626
627
if ( ! isNaN ( amt ) ) {
627
628
var currIndex = parseInt ( this . _focusedOptionLi ( ) . data ( 'index' ) || 0 , 10 ) ;
628
629
var newIndex = currIndex + amt ;
629
- }
630
- else {
630
+ } else {
631
631
var newIndex = parseInt ( this . _optionLis . filter ( amt ) . data ( 'index' ) , 10 ) ;
632
632
}
633
633
@@ -803,13 +803,13 @@ $.widget("ui.selectmenu", {
803
803
var o = this . options ;
804
804
805
805
// if its a native pop-up we need to calculate the position of the selected li
806
- if ( o . style == "popup" && ! o . positionOptions . offset ) {
806
+ if ( o . style == "popup" && ! o . positionOptions . offset ) {
807
807
var selected = this . _selectedOptionLi ( ) ;
808
- var _offset = "0 -" + ( selected . outerHeight ( ) + selected . offset ( ) . top - this . list . offset ( ) . top ) ;
808
+ var _offset = "0 -" + ( selected . outerHeight ( ) + selected . offset ( ) . top - this . list . offset ( ) . top ) ;
809
809
}
810
810
// update zIndex if jQuery UI is able to process
811
811
var zIndexElement = this . element . zIndex ( ) ;
812
- if ( zIndexElement ) {
812
+ if ( zIndexElement ) {
813
813
this . list . css ( {
814
814
zIndex : zIndexElement
815
815
} ) ;
0 commit comments