//>>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",
// Browser globals
factory( jQuery );
}
-}(function( $ ) {
+}( function( $ ) {
$.widget( "ui.autocomplete", {
version: "@VERSION",
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" );
// 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
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
// 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 ] &&
!$.contains( menuElement, event.target ) ) {
that.close();
}
- });
- });
+ } );
+ } );
}
},
menufocus: function( event, ui ) {
this.document.one( "mousemove", function() {
$( event.target ).trigger( event.originalEvent );
- });
+ } );
return;
}
// #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 } ) ) {
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" );
beforeunload: function() {
this.element.removeAttr( "autocomplete" );
}
- });
+ } );
},
_destroy: function() {
if ( that.xhr ) {
that.xhr.abort();
}
- that.xhr = $.ajax({
+ that.xhr = $.ajax( {
url: url,
data: request,
dataType: "json",
response( data );
},
error: function() {
- response([]);
+ response( [] );
}
- });
+ } );
};
} else {
this.source = this.options.source;
_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(),
_response: function() {
var index = ++this.requestIndex;
- return $.proxy(function( content ) {
+ return $.proxy( function( content ) {
if ( index === this.requestIndex ) {
this.__response( content );
}
return $.extend( {}, item, {
label: item.label || item.value,
value: item.value || item.label
- });
- });
+ } );
+ } );
},
_suggest: function( items ) {
// size and position menu
ul.show();
this._resizeMenu();
- ul.position( $.extend({
+ ul.position( $.extend( {
of: this.element
}, this.options.position ) );
var that = this;
$.each( items, function( index, item ) {
that._renderItemData( ul, item );
- });
+ } );
},
_renderItemData: function( ul, item ) {
event.preventDefault();
}
}
-});
+} );
$.extend( $.ui.autocomplete, {
escapeRegex: function( value ) {
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
this.liveRegion.children().hide();
$( "<div>" ).text( message ).appendTo( this.liveRegion );
}
-});
+} );
return $.ui.autocomplete;
-}));
+} ) );