Autocomplete: Whitespace

This commit is contained in:
Jörn Zaefferer 2013-12-07 18:00:20 +01:00
parent 9de1eb0a23
commit 6a483fd143

View File

@ -53,7 +53,7 @@ $.widget( "ui.autocomplete", {
// events when we know the keydown event was used to modify the // events when we know the keydown event was used to modify the
// search term. #7799 // search term. #7799
var suppressKeyPress, suppressKeyPressRepeat, suppressInput, var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
nodeName = this.element[0].nodeName.toLowerCase(), nodeName = this.element[ 0 ].nodeName.toLowerCase(),
isTextarea = nodeName === "textarea", isTextarea = nodeName === "textarea",
isInput = nodeName === "input"; isInput = nodeName === "input";
@ -265,7 +265,7 @@ $.widget( "ui.autocomplete", {
previous = this.previous; previous = this.previous;
// only trigger when focus was lost (click on menu) // only trigger when focus was lost (click on menu)
if ( this.element[0] !== this.document[0].activeElement ) { if ( this.element[ 0 ] !== this.document[ 0 ].activeElement ) {
this.element.focus(); this.element.focus();
this.previous = previous; this.previous = previous;
// #6109 - IE triggers two focus events and the second // #6109 - IE triggers two focus events and the second
@ -342,7 +342,7 @@ $.widget( "ui.autocomplete", {
} }
if ( !element.length ) { if ( !element.length ) {
element = this.document[0].body; element = this.document[ 0 ].body;
} }
return element; return element;
@ -351,7 +351,7 @@ $.widget( "ui.autocomplete", {
_initSource: function() { _initSource: function() {
var array, url, var array, url,
that = this; that = this;
if ( $.isArray(this.options.source) ) { if ( $.isArray( this.options.source ) ) {
array = this.options.source; array = this.options.source;
this.source = function( request, response ) { this.source = function( request, response ) {
response( $.ui.autocomplete.filter( array, request.term ) ); response( $.ui.autocomplete.filter( array, request.term ) );
@ -370,7 +370,7 @@ $.widget( "ui.autocomplete", {
response( data ); response( data );
}, },
error: function() { error: function() {
response( [] ); response([]);
} }
}); });
}; };
@ -466,7 +466,7 @@ $.widget( "ui.autocomplete", {
_normalize: function( items ) { _normalize: function( items ) {
// assume all items have the right format when the first item is complete // assume all items have the right format when the first item is complete
if ( items.length && items[0].label && items[0].value ) { if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
return items; return items;
} }
return $.map( items, function( item ) { return $.map( items, function( item ) {
@ -494,7 +494,7 @@ $.widget( "ui.autocomplete", {
this._resizeMenu(); this._resizeMenu();
ul.position( $.extend({ ul.position( $.extend({
of: this.element of: this.element
}, this.options.position )); }, this.options.position ) );
if ( this.options.autoFocus ) { if ( this.options.autoFocus ) {
this.menu.next(); this.menu.next();
@ -560,11 +560,11 @@ $.widget( "ui.autocomplete", {
$.extend( $.ui.autocomplete, { $.extend( $.ui.autocomplete, {
escapeRegex: function( value ) { escapeRegex: function( value ) {
return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&"); return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
}, },
filter: function(array, term) { filter: function( array, term ) {
var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" ); var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
return $.grep( array, function(value) { return $.grep( array, function( value ) {
return matcher.test( value.label || value.value || value ); return matcher.test( value.label || value.value || value );
}); });
} }