summaryrefslogtreecommitdiff
path: root/resources/jquery.ui/jquery.ui.autocomplete.js
diff options
context:
space:
mode:
Diffstat (limited to 'resources/jquery.ui/jquery.ui.autocomplete.js')
-rw-r--r--resources/jquery.ui/jquery.ui.autocomplete.js61
1 files changed, 35 insertions, 26 deletions
diff --git a/resources/jquery.ui/jquery.ui.autocomplete.js b/resources/jquery.ui/jquery.ui.autocomplete.js
index 48ede20b..b634cce5 100644
--- a/resources/jquery.ui/jquery.ui.autocomplete.js
+++ b/resources/jquery.ui/jquery.ui.autocomplete.js
@@ -1,7 +1,7 @@
-/*
- * jQuery UI Autocomplete 1.8.17
+/*!
+ * jQuery UI Autocomplete 1.8.23
*
- * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
@@ -37,6 +37,7 @@ $.widget( "ui.autocomplete", {
var self = this,
doc = this.element[ 0 ].ownerDocument,
suppressKeyPress;
+ this.isMultiLine = this.element.is( "textarea" );
this.element
.addClass( "ui-autocomplete-input" )
@@ -62,14 +63,10 @@ $.widget( "ui.autocomplete", {
self._move( "nextPage", event );
break;
case keyCode.UP:
- self._move( "previous", event );
- // prevent moving cursor to beginning of text field in some browsers
- event.preventDefault();
+ self._keyEvent( "previous", event );
break;
case keyCode.DOWN:
- self._move( "next", event );
- // prevent moving cursor to end of text field in some browsers
- event.preventDefault();
+ self._keyEvent( "next", event );
break;
case keyCode.ENTER:
case keyCode.NUMPAD_ENTER:
@@ -131,9 +128,6 @@ $.widget( "ui.autocomplete", {
}, 150 );
});
this._initSource();
- this.response = function() {
- return self._response.apply( self, arguments );
- };
this.menu = $( "<ul></ul>" )
.addClass( "ui-autocomplete" )
.appendTo( $( this.options.appendTo || "body", doc )[0] )
@@ -268,16 +262,11 @@ $.widget( "ui.autocomplete", {
url: url,
data: request,
dataType: "json",
- autocompleteRequest: ++requestIndex,
success: function( data, status ) {
- if ( this.autocompleteRequest === requestIndex ) {
- response( data );
- }
+ response( data );
},
error: function() {
- if ( this.autocompleteRequest === requestIndex ) {
- response( [] );
- }
+ response( [] );
}
});
};
@@ -308,10 +297,26 @@ $.widget( "ui.autocomplete", {
this.pending++;
this.element.addClass( "ui-autocomplete-loading" );
- this.source( { term: value }, this.response );
+ this.source( { term: value }, this._response() );
+ },
+
+ _response: function() {
+ var that = this,
+ index = ++requestIndex;
+
+ return function( content ) {
+ if ( index === requestIndex ) {
+ that.__response( content );
+ }
+
+ that.pending--;
+ if ( !that.pending ) {
+ that.element.removeClass( "ui-autocomplete-loading" );
+ }
+ };
},
- _response: function( content ) {
+ __response: function( content ) {
if ( !this.options.disabled && content && content.length ) {
content = this._normalize( content );
this._suggest( content );
@@ -319,10 +324,6 @@ $.widget( "ui.autocomplete", {
} else {
this.close();
}
- this.pending--;
- if ( !this.pending ) {
- this.element.removeClass( "ui-autocomplete-loading" );
- }
},
close: function( event ) {
@@ -420,6 +421,14 @@ $.widget( "ui.autocomplete", {
widget: function() {
return this.menu.element;
+ },
+ _keyEvent: function( keyEvent, event ) {
+ if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
+ this._move( keyEvent, event );
+
+ // prevents moving cursor to beginning/end of the text field in some browsers
+ event.preventDefault();
+ }
}
});
@@ -592,7 +601,7 @@ $.widget("ui.menu", {
}
var base = this.active.offset().top,
- height = this.element.height();
+ height = this.element.height(),
result = this.element.children(".ui-menu-item").filter(function() {
var close = $(this).offset().top - base + height - $(this).height();
// TODO improve approximation