@@ -65,6 +65,7 @@ $.widget( "ui.autocomplete", {
65
65
pending : 0 ,
66
66
67
67
_create : function ( ) {
68
+
68
69
// Some browsers only repeat keydown events, not keypress events,
69
70
// so we use the suppressKeyPress flag to determine if we've already
70
71
// handled the keydown event. #7269
@@ -120,8 +121,10 @@ $.widget( "ui.autocomplete", {
120
121
this . _keyEvent ( "next" , event ) ;
121
122
break ;
122
123
case keyCode . ENTER :
124
+
123
125
// when menu is open and has focus
124
126
if ( this . menu . active ) {
127
+
125
128
// #6055 - Opera still allows the keypress to occur
126
129
// which causes forms to submit
127
130
suppressKeyPress = true ;
@@ -140,6 +143,7 @@ $.widget( "ui.autocomplete", {
140
143
this . _value ( this . term ) ;
141
144
}
142
145
this . close ( event ) ;
146
+
143
147
// Different browsers have different default behavior for escape
144
148
// Single press can mean undo or clear
145
149
// Double press in IE means clear the whole form
@@ -148,6 +152,7 @@ $.widget( "ui.autocomplete", {
148
152
break ;
149
153
default :
150
154
suppressKeyPressRepeat = true ;
155
+
151
156
// search timeout should be triggered before the input value is changed
152
157
this . _searchTimeout ( event ) ;
153
158
break ;
@@ -210,6 +215,7 @@ $.widget( "ui.autocomplete", {
210
215
this . menu = $ ( "<ul>" )
211
216
. appendTo ( this . _appendTo ( ) )
212
217
. menu ( {
218
+
213
219
// disable ARIA support, the live region takes care of that
214
220
role : null
215
221
} )
@@ -219,6 +225,7 @@ $.widget( "ui.autocomplete", {
219
225
this . _addClass ( this . menu . element , "ui-autocomplete" , "ui-front" ) ;
220
226
this . _on ( this . menu . element , {
221
227
mousedown : function ( event ) {
228
+
222
229
// prevent moving focus out of the text field
223
230
event . preventDefault ( ) ;
224
231
@@ -259,6 +266,7 @@ $.widget( "ui.autocomplete", {
259
266
} ,
260
267
menufocus : function ( event , ui ) {
261
268
var label , item ;
269
+
262
270
// support: Firefox
263
271
// Prevent accidental activation of menu items in Firefox (#7024 #9118)
264
272
if ( this . isNewMenu ) {
@@ -276,6 +284,7 @@ $.widget( "ui.autocomplete", {
276
284
277
285
item = ui . item . data ( "ui-autocomplete-item" ) ;
278
286
if ( false !== this . _trigger ( "focus" , event , { item : item } ) ) {
287
+
279
288
// use value to match what will end up in the input, if it was a key event
280
289
if ( event . originalEvent && / ^ k e y / . test ( event . originalEvent . type ) ) {
281
290
this . _value ( item . value ) ;
@@ -297,6 +306,7 @@ $.widget( "ui.autocomplete", {
297
306
if ( this . element [ 0 ] !== $ . ui . safeActiveElement ( this . document [ 0 ] ) ) {
298
307
this . element . trigger ( "focus" ) ;
299
308
this . previous = previous ;
309
+
300
310
// #6109 - IE triggers two focus events and the second
301
311
// is asynchronous, so we need to reset the previous
302
312
// term synchronously and asynchronously :-(
@@ -309,6 +319,7 @@ $.widget( "ui.autocomplete", {
309
319
if ( false !== this . _trigger ( "select" , event , { item : item } ) ) {
310
320
this . _value ( item . value ) ;
311
321
}
322
+
312
323
// reset the term after the select event
313
324
// this allows custom select handling to work properly
314
325
this . term = this . _value ( ) ;
@@ -473,6 +484,7 @@ $.widget( "ui.autocomplete", {
473
484
this . _suggest ( content ) ;
474
485
this . _trigger ( "open" ) ;
475
486
} else {
487
+
476
488
// use ._close() instead of .close() so we don't cancel future searches
477
489
this . _close ( ) ;
478
490
}
@@ -499,6 +511,7 @@ $.widget( "ui.autocomplete", {
499
511
} ,
500
512
501
513
_normalize : function ( items ) {
514
+
502
515
// assume all items have the right format when the first item is complete
503
516
if ( items . length && items [ 0 ] . label && items [ 0 ] . value ) {
504
517
return items ;
@@ -538,6 +551,7 @@ $.widget( "ui.autocomplete", {
538
551
_resizeMenu : function ( ) {
539
552
var ul = this . menu . element ;
540
553
ul . outerWidth ( Math . max (
554
+
541
555
// Firefox wraps long text (possibly a rounding bug)
542
556
// so we add 1px to avoid the wrapping (#7513)
543
557
ul . width ( "" ) . outerWidth ( ) + 1 ,
0 commit comments