Skip to content

Commit cac6831

Browse files
committed
Autocomplete: Coding standards.
1 parent 3ccf86c commit cac6831

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

ui/jquery.ui.autocomplete.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ $.widget( "ui.autocomplete", {
110110
}
111111
break;
112112
case keyCode.ESCAPE:
113-
if ( this.menu.element.is(":visible") ) {
113+
if ( this.menu.element.is( ":visible" ) ) {
114114
this._value( this.term );
115115
this.close( event );
116116
// Different browsers have different default behavior for escape
@@ -178,9 +178,9 @@ $.widget( "ui.autocomplete", {
178178
});
179179

180180
this._initSource();
181-
this.menu = $( "<ul></ul>" )
181+
this.menu = $( "<ul>" )
182182
.addClass( "ui-autocomplete" )
183-
.appendTo( this.document.find( this.options.appendTo || "body" )[0] )
183+
.appendTo( this.document.find( this.options.appendTo || "body" )[ 0 ] )
184184
.menu({
185185
// custom key handling for now
186186
input: $(),
@@ -210,7 +210,7 @@ $.widget( "ui.autocomplete", {
210210
if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
211211
this._delay(function() {
212212
var that = this;
213-
this.document.one( 'mousedown', function( event ) {
213+
this.document.one( "mousedown", function( event ) {
214214
if ( event.target !== that.element[ 0 ] &&
215215
event.target !== menuElement &&
216216
!$.contains( menuElement, event.target ) ) {
@@ -224,7 +224,7 @@ $.widget( "ui.autocomplete", {
224224
// #7024 - Prevent accidental activation of menu items in Firefox
225225
if ( this.isNewMenu ) {
226226
this.isNewMenu = false;
227-
if ( event.originalEvent && /^mouse/.test(event.originalEvent.type) ) {
227+
if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
228228
this.menu.blur();
229229

230230
this.document.one( "mousemove", function() {
@@ -240,7 +240,7 @@ $.widget( "ui.autocomplete", {
240240
var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" );
241241
if ( false !== this._trigger( "focus", event, { item: item } ) ) {
242242
// use value to match what will end up in the input, if it was a key event
243-
if ( event.originalEvent && /^key/.test(event.originalEvent.type) ) {
243+
if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
244244
this._value( item.value );
245245
}
246246
} else {
@@ -330,13 +330,12 @@ $.widget( "ui.autocomplete", {
330330
},
331331

332332
_initSource: function() {
333-
var that = this,
334-
array,
335-
url;
333+
var array, url,
334+
that = this;
336335
if ( $.isArray(this.options.source) ) {
337336
array = this.options.source;
338337
this.source = function( request, response ) {
339-
response( $.ui.autocomplete.filter(array, request.term) );
338+
response( $.ui.autocomplete.filter( array, request.term ) );
340339
};
341340
} else if ( typeof this.options.source === "string" ) {
342341
url = this.options.source;
@@ -434,7 +433,7 @@ $.widget( "ui.autocomplete", {
434433

435434
_close: function( event ) {
436435
clearTimeout( this.closing );
437-
if ( this.menu.element.is(":visible") ) {
436+
if ( this.menu.element.is( ":visible" ) ) {
438437
this.menu.element.hide();
439438
this.menu.blur();
440439
this.isNewMenu = true;
@@ -453,7 +452,7 @@ $.widget( "ui.autocomplete", {
453452
if ( items.length && items[0].label && items[0].value ) {
454453
return items;
455454
}
456-
return $.map( items, function(item) {
455+
return $.map( items, function( item ) {
457456
if ( typeof item === "string" ) {
458457
return {
459458
label: item,
@@ -510,18 +509,18 @@ $.widget( "ui.autocomplete", {
510509
},
511510

512511
_renderItem: function( ul, item ) {
513-
return $( "<li></li>" )
514-
.append( $( "<a></a>" ).text( item.label ) )
512+
return $( "<li>" )
513+
.append( $( "<a>" ).text( item.label ) )
515514
.appendTo( ul );
516515
},
517516

518517
_move: function( direction, event ) {
519-
if ( !this.menu.element.is(":visible") ) {
518+
if ( !this.menu.element.is( ":visible" ) ) {
520519
this.search( null, event );
521520
return;
522521
}
523-
if ( this.menu.isFirstItem() && /^previous/.test(direction) ||
524-
this.menu.isLastItem() && /^next/.test(direction) ) {
522+
if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
523+
this.menu.isLastItem() && /^next/.test( direction ) ) {
525524
this._value( this.term );
526525
this.menu.blur();
527526
return;

0 commit comments

Comments
 (0)