Skip to content

Autocomplete: Fix style issues #1504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions ui/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
//>>css.structure: ../themes/base/autocomplete.css
//>>css.theme: ../themes/base/theme.css

(function( factory ) {
( function( factory ) {
if ( typeof define === "function" && define.amd ) {

// AMD. Register as an anonymous module.
define([
define( [
"jquery",
"./core",
"./widget",
Expand All @@ -32,7 +32,7 @@
// Browser globals
factory( jQuery );
}
}(function( $ ) {
}( function( $ ) {

$.widget( "ui.autocomplete", {
version: "@VERSION",
Expand Down Expand Up @@ -203,15 +203,15 @@ $.widget( "ui.autocomplete", {
this.close( event );
this._change( event );
}
});
} );

this._initSource();
this.menu = $( "<ul>" )
.appendTo( this._appendTo() )
.menu({
.menu( {
// disable ARIA support, the live region takes care of that
role: null
})
} )
.hide()
.menu( "instance" );

Expand All @@ -224,7 +224,7 @@ $.widget( "ui.autocomplete", {
// IE doesn't prevent moving focus even with event.preventDefault()
// so we set a flag to know when we should ignore the blur event
this.cancelBlur = true;
this._delay(function() {
this._delay( function() {
delete this.cancelBlur;

// Support: IE 8 only
Expand All @@ -236,24 +236,24 @@ $.widget( "ui.autocomplete", {
if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) {
this.element.focus();
}
});
} );

// clicking on the scrollbar causes focus to shift to the body
// but we can't detect a mouseup or a click immediately afterward
// so we have to track the next mousedown and close the menu if
// the user clicks somewhere outside of the autocomplete
var menuElement = this.menu.element[ 0 ];
if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
this._delay(function() {
this._delay( function() {
var that = this;
this.document.one( "mousedown", function( event ) {
if ( event.target !== that.element[ 0 ] &&
event.target !== menuElement &&
!$.contains( menuElement, event.target ) ) {
that.close();
}
});
});
} );
} );
}
},
menufocus: function( event, ui ) {
Expand All @@ -267,7 +267,7 @@ $.widget( "ui.autocomplete", {

this.document.one( "mousemove", function() {
$( event.target ).trigger( event.originalEvent );
});
} );

return;
}
Expand Down Expand Up @@ -299,10 +299,10 @@ $.widget( "ui.autocomplete", {
// #6109 - IE triggers two focus events and the second
// is asynchronous, so we need to reset the previous
// term synchronously and asynchronously :-(
this._delay(function() {
this._delay( function() {
this.previous = previous;
this.selectedItem = item;
});
} );
}

if ( false !== this._trigger( "select", event, { item: item } ) ) {
Expand All @@ -315,13 +315,13 @@ $.widget( "ui.autocomplete", {
this.close( event );
this.selectedItem = item;
}
});
} );

this.liveRegion = $( "<span>", {
role: "status",
"aria-live": "assertive",
"aria-relevant": "additions"
})
role: "status",
"aria-live": "assertive",
"aria-relevant": "additions"
} )
.appendTo( this.document[ 0 ].body );

this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
Expand All @@ -333,7 +333,7 @@ $.widget( "ui.autocomplete", {
beforeunload: function() {
this.element.removeAttr( "autocomplete" );
}
});
} );
},

_destroy: function() {
Expand Down Expand Up @@ -390,17 +390,17 @@ $.widget( "ui.autocomplete", {
if ( that.xhr ) {
that.xhr.abort();
}
that.xhr = $.ajax({
that.xhr = $.ajax( {
url: url,
data: request,
dataType: "json",
success: function( data ) {
response( data );
},
error: function() {
response([]);
response( [] );
}
});
} );
};
} else {
this.source = this.options.source;
Expand All @@ -409,7 +409,7 @@ $.widget( "ui.autocomplete", {

_searchTimeout: function( event ) {
clearTimeout( this.searching );
this.searching = this._delay(function() {
this.searching = this._delay( function() {

// Search if the value has changed, or if the user retypes the same value (see #7434)
var equalValues = this.term === this._value(),
Expand Down Expand Up @@ -451,7 +451,7 @@ $.widget( "ui.autocomplete", {
_response: function() {
var index = ++this.requestIndex;

return $.proxy(function( content ) {
return $.proxy( function( content ) {
if ( index === this.requestIndex ) {
this.__response( content );
}
Expand Down Expand Up @@ -512,8 +512,8 @@ $.widget( "ui.autocomplete", {
return $.extend( {}, item, {
label: item.label || item.value,
value: item.value || item.label
});
});
} );
} );
},

_suggest: function( items ) {
Expand All @@ -525,7 +525,7 @@ $.widget( "ui.autocomplete", {
// size and position menu
ul.show();
this._resizeMenu();
ul.position( $.extend({
ul.position( $.extend( {
of: this.element
}, this.options.position ) );

Expand All @@ -548,7 +548,7 @@ $.widget( "ui.autocomplete", {
var that = this;
$.each( items, function( index, item ) {
that._renderItemData( ul, item );
});
} );
},

_renderItemData: function( ul, item ) {
Expand Down Expand Up @@ -595,7 +595,7 @@ $.widget( "ui.autocomplete", {
event.preventDefault();
}
}
});
} );

$.extend( $.ui.autocomplete, {
escapeRegex: function( value ) {
Expand All @@ -605,9 +605,9 @@ $.extend( $.ui.autocomplete, {
var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
return $.grep( array, function( value ) {
return matcher.test( value.label || value.value || value );
});
} );
}
});
} );

// live region extension, adding a `messages` option
// NOTE: This is an experimental API. We are still investigating
Expand Down Expand Up @@ -637,8 +637,8 @@ $.widget( "ui.autocomplete", $.ui.autocomplete, {
this.liveRegion.children().hide();
$( "<div>" ).text( message ).appendTo( this.liveRegion );
}
});
} );

return $.ui.autocomplete;

}));
} ) );