1
1
/*
2
- * jQuery UI selectmenu dev version
2
+ * jQuery UI selectmenu dev version * jQuery UI selectmenu 1.2.1 version
3
3
*
4
4
* Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
5
5
* Dual licensed under the MIT (MIT-LICENSE.txt)
@@ -40,7 +40,7 @@ $.widget("ui.selectmenu", {
40
40
41
41
// set a default id value, generate a new random one if not set by developer
42
42
var selectmenuId = ( this . element . attr ( 'id' ) || 'ui-selectmenu-' + Math . random ( ) . toString ( 16 ) . slice ( 2 , 10 ) ) . replace ( ':' , '\\:' ) ;
43
-
43
+
44
44
// quick array of button and menu id's
45
45
this . ids = [ selectmenuId , selectmenuId + '-button' , selectmenuId + '-menu' ] ;
46
46
@@ -61,7 +61,7 @@ $.widget("ui.selectmenu", {
61
61
this . newelementWrap = $ ( "<span />" )
62
62
. append ( this . newelement )
63
63
. insertAfter ( this . element ) ;
64
-
64
+
65
65
// transfer tabindex
66
66
var tabindex = this . element . attr ( 'tabindex' ) ;
67
67
if ( tabindex ) {
@@ -85,7 +85,7 @@ $.widget("ui.selectmenu", {
85
85
event . preventDefault ( ) ;
86
86
}
87
87
} ) ;
88
-
88
+
89
89
// click toggle for menu visibility
90
90
this . newelement
91
91
. bind ( 'mousedown.selectmenu' , function ( event ) {
@@ -194,7 +194,7 @@ $.widget("ui.selectmenu", {
194
194
// hide original selectmenu element
195
195
this . element . hide ( ) ;
196
196
197
- // create menu portion, append to body
197
+ // create menu portion, append to body
198
198
this . list = $ ( '<ul />' , {
199
199
'class' : 'ui-widget ui-widget-content' ,
200
200
'aria-hidden' : true ,
@@ -205,7 +205,7 @@ $.widget("ui.selectmenu", {
205
205
this . listWrap = $ ( "<div />" , {
206
206
'class' : self . widgetBaseClass + '-menu'
207
207
} ) . append ( this . list ) . appendTo ( o . appendTo ) ;
208
-
208
+
209
209
// transfer menu click to menu button
210
210
this . list
211
211
. bind ( "keydown.selectmenu" , function ( event ) {
@@ -305,7 +305,7 @@ $.widget("ui.selectmenu", {
305
305
var thisLiAttr = { role : 'presentation' } ;
306
306
if ( selectOptionData [ i ] . disabled ) {
307
307
thisLiAttr [ 'class' ] = this . namespace + '-state-disabled' ;
308
- }
308
+ }
309
309
var thisAAttr = {
310
310
html : selectOptionData [ i ] . text || ' ' ,
311
311
href : '#nogo' ,
@@ -318,10 +318,10 @@ $.widget("ui.selectmenu", {
318
318
}
319
319
if ( selectOptionData [ i ] . typeahead ) {
320
320
thisAAttr [ 'typeahead' ] = selectOptionData [ i ] . typeahead ;
321
- }
321
+ }
322
322
var thisA = $ ( '<a/>' , thisAAttr ) ;
323
- var thisLi = $ ( '<li/>' , thisLiAttr )
324
- . append ( thisA )
323
+ var thisLi = $ ( '<li/>' , thisLiAttr )
324
+ . append ( thisA )
325
325
. data ( 'index' , i )
326
326
. addClass ( selectOptionData [ i ] . classes )
327
327
. data ( 'optionClasses' , selectOptionData [ i ] . classes || '' )
@@ -425,10 +425,10 @@ $.widget("ui.selectmenu", {
425
425
this . list . css ( 'height' , 'auto' ) ;
426
426
var listH = this . listWrap . height ( ) ;
427
427
var winH = $ ( window ) . height ( ) ;
428
- // calculate default max height
428
+ // calculate default max height
429
429
var maxH = o . maxHeight ? Math . min ( o . maxHeight , winH ) : winH / 3 ;
430
- if ( listH > maxH ) this . list . height ( maxH ) ;
431
-
430
+ if ( listH > maxH ) this . list . height ( maxH ) ;
431
+
432
432
// save reference to actionable li's (not group label li's)
433
433
this . _optionLis = this . list . find ( 'li:not(.' + self . widgetBaseClass + '-group)' ) ;
434
434
@@ -438,10 +438,10 @@ $.widget("ui.selectmenu", {
438
438
} else {
439
439
this . enable ( ) ;
440
440
}
441
-
441
+
442
442
// update value
443
443
this . index ( this . _selectedIndex ( ) ) ;
444
-
444
+
445
445
// set selected item so movefocus has intial state
446
446
this . _selectedOptionLi ( ) . addClass ( this . widgetBaseClass + '-item-focus' ) ;
447
447
@@ -460,10 +460,10 @@ $.widget("ui.selectmenu", {
460
460
461
461
$ ( window ) . unbind ( ".selectmenu-" + this . ids [ 0 ] ) ;
462
462
$ ( document ) . unbind ( ".selectmenu-" + this . ids [ 0 ] ) ;
463
-
463
+
464
464
this . newelementWrap . remove ( ) ;
465
465
this . listWrap . remove ( ) ;
466
-
466
+
467
467
// unbind click event and show original select
468
468
this . element
469
469
. unbind ( ".selectmenu" )
@@ -561,26 +561,25 @@ $.widget("ui.selectmenu", {
561
561
if ( self . newelement . attr ( "aria-disabled" ) != 'true' ) {
562
562
self . _closeOthers ( event ) ;
563
563
self . newelement . addClass ( 'ui-state-active' ) ;
564
-
565
- self . list . attr ( 'aria-hidden' , false ) ;
564
+ self . list . attr ( 'aria-hidden' , false ) ;
566
565
self . listWrap . addClass ( self . widgetBaseClass + '-open' ) ;
567
-
566
+
568
567
var selected = this . _selectedOptionLi ( ) ;
569
568
if ( o . style == "dropdown" ) {
570
569
self . newelement . removeClass ( 'ui-corner-all' ) . addClass ( 'ui-corner-top' ) ;
571
- } else {
570
+ } else {
572
571
// center overflow and avoid flickering
573
572
this . list
574
573
. css ( "left" , - 5000 )
575
574
. scrollTop ( this . list . scrollTop ( ) + selected . position ( ) . top - this . list . outerHeight ( ) / 2 + selected . outerHeight ( ) / 2 )
576
575
. css ( "left" , "auto" ) ;
577
576
}
578
-
579
- self . _refreshPosition ( ) ;
580
-
577
+
578
+ self . _refreshPosition ( ) ;
579
+
581
580
var link = selected . find ( "a" ) ;
582
- if ( link . length ) link [ 0 ] . focus ( ) ;
583
-
581
+ if ( link . length ) link [ 0 ] . focus ( ) ;
582
+
584
583
self . isOpen = true ;
585
584
self . _trigger ( "open" , event , self . _uiHash ( ) ) ;
586
585
}
@@ -612,7 +611,7 @@ $.widget("ui.selectmenu", {
612
611
if ( this . _disabled ( event . currentTarget ) ) { return false ; }
613
612
this . _trigger ( "select" , event , this . _uiHash ( ) ) ;
614
613
} ,
615
-
614
+
616
615
widget : function ( ) {
617
616
return this . listWrap . add ( this . newelementWrap ) ;
618
617
} ,
@@ -631,7 +630,7 @@ $.widget("ui.selectmenu", {
631
630
this . open ( event ) ;
632
631
}
633
632
} ,
634
-
633
+
635
634
_formatText : function ( text ) {
636
635
if ( this . options . format ) {
637
636
text = this . options . format ( text ) ;
0 commit comments