summaryrefslogtreecommitdiff
path: root/xstatic/pkg/jquery_ui/data/ui/jquery.ui.autocomplete.js
diff options
context:
space:
mode:
Diffstat (limited to 'xstatic/pkg/jquery_ui/data/ui/jquery.ui.autocomplete.js')
-rw-r--r--xstatic/pkg/jquery_ui/data/ui/jquery.ui.autocomplete.js112
1 files changed, 58 insertions, 54 deletions
diff --git a/xstatic/pkg/jquery_ui/data/ui/jquery.ui.autocomplete.js b/xstatic/pkg/jquery_ui/data/ui/jquery.ui.autocomplete.js
index 3baed1d..91759c5 100644
--- a/xstatic/pkg/jquery_ui/data/ui/jquery.ui.autocomplete.js
+++ b/xstatic/pkg/jquery_ui/data/ui/jquery.ui.autocomplete.js
@@ -1,8 +1,8 @@
/*!
- * jQuery UI Autocomplete 1.9.2
+ * jQuery UI Autocomplete 1.10.4
* http://jqueryui.com
*
- * Copyright 2012 jQuery Foundation and other contributors
+ * Copyright 2014 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*
@@ -16,14 +16,11 @@
*/
(function( $, undefined ) {
-// used to prevent race conditions with remote data sources
-var requestIndex = 0;
-
$.widget( "ui.autocomplete", {
- version: "1.9.2",
+ version: "1.10.4",
defaultElement: "<input>",
options: {
- appendTo: "body",
+ appendTo: null,
autoFocus: false,
delay: 300,
minLength: 1,
@@ -44,6 +41,7 @@ $.widget( "ui.autocomplete", {
select: null
},
+ requestIndex: 0,
pending: 0,
_create: function() {
@@ -54,10 +52,21 @@ $.widget( "ui.autocomplete", {
// so we use the suppressKeyPressRepeat flag to avoid handling keypress
// events when we know the keydown event was used to modify the
// search term. #7799
- var suppressKeyPress, suppressKeyPressRepeat, suppressInput;
-
- this.isMultiLine = this._isMultiLine();
- this.valueMethod = this.element[ this.element.is( "input,textarea" ) ? "val" : "text" ];
+ var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
+ nodeName = this.element[0].nodeName.toLowerCase(),
+ isTextarea = nodeName === "textarea",
+ isInput = nodeName === "input";
+
+ this.isMultiLine =
+ // Textareas are always multi-line
+ isTextarea ? true :
+ // Inputs are always single-line, even if inside a contentEditable element
+ // IE also treats inputs as contentEditable
+ isInput ? false :
+ // All other element types are determined by whether or not they're contentEditable
+ this.element.prop( "isContentEditable" );
+
+ this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
this.isNewMenu = true;
this.element
@@ -130,7 +139,9 @@ $.widget( "ui.autocomplete", {
keypress: function( event ) {
if ( suppressKeyPress ) {
suppressKeyPress = false;
- event.preventDefault();
+ if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
+ event.preventDefault();
+ }
return;
}
if ( suppressKeyPressRepeat ) {
@@ -180,17 +191,14 @@ $.widget( "ui.autocomplete", {
this._initSource();
this.menu = $( "<ul>" )
- .addClass( "ui-autocomplete" )
- .appendTo( this.document.find( this.options.appendTo || "body" )[ 0 ] )
+ .addClass( "ui-autocomplete ui-front" )
+ .appendTo( this._appendTo() )
.menu({
- // custom key handling for now
- input: $(),
// disable ARIA support, the live region takes care of that
role: null
})
- .zIndex( this.element.zIndex() + 1 )
.hide()
- .data( "menu" );
+ .data( "ui-menu" );
this._on( this.menu.element, {
mousedown: function( event ) {
@@ -223,7 +231,8 @@ $.widget( "ui.autocomplete", {
}
},
menufocus: function( event, ui ) {
- // #7024 - Prevent accidental activation of menu items in Firefox
+ // support: Firefox
+ // Prevent accidental activation of menu items in Firefox (#7024 #9118)
if ( this.isNewMenu ) {
this.isNewMenu = false;
if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
@@ -237,9 +246,7 @@ $.widget( "ui.autocomplete", {
}
}
- // back compat for _renderItem using item.autocomplete, via #7810
- // TODO remove the fallback, see #8156
- var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" );
+ var item = ui.item.data( "ui-autocomplete-item" );
if ( false !== this._trigger( "focus", event, { item: item } ) ) {
// use value to match what will end up in the input, if it was a key event
if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
@@ -255,9 +262,7 @@ $.widget( "ui.autocomplete", {
}
},
menuselect: function( event, ui ) {
- // back compat for _renderItem using item.autocomplete, via #7810
- // TODO remove the fallback, see #8156
- var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" ),
+ var item = ui.item.data( "ui-autocomplete-item" ),
previous = this.previous;
// only trigger when focus was lost (click on menu)
@@ -290,11 +295,7 @@ $.widget( "ui.autocomplete", {
"aria-live": "polite"
})
.addClass( "ui-helper-hidden-accessible" )
- .insertAfter( this.element );
-
- if ( $.fn.bgiframe ) {
- this.menu.element.bgiframe();
- }
+ .insertBefore( this.element );
// turning off autocomplete prevents the browser from remembering the
// value when navigating through history, so we re-enable autocomplete
@@ -321,25 +322,31 @@ $.widget( "ui.autocomplete", {
this._initSource();
}
if ( key === "appendTo" ) {
- this.menu.element.appendTo( this.document.find( value || "body" )[0] );
+ this.menu.element.appendTo( this._appendTo() );
}
if ( key === "disabled" && value && this.xhr ) {
this.xhr.abort();
}
},
- _isMultiLine: function() {
- // Textareas are always multi-line
- if ( this.element.is( "textarea" ) ) {
- return true;
+ _appendTo: function() {
+ var element = this.options.appendTo;
+
+ if ( element ) {
+ element = element.jquery || element.nodeType ?
+ $( element ) :
+ this.document.find( element ).eq( 0 );
+ }
+
+ if ( !element ) {
+ element = this.element.closest( ".ui-front" );
}
- // Inputs are always single-line, even if inside a contentEditable element
- // IE also treats inputs as contentEditable
- if ( this.element.is( "input" ) ) {
- return false;
+
+ if ( !element.length ) {
+ element = this.document[0].body;
}
- // All other element types are determined by whether or not they're contentEditable
- return this.element.prop( "isContentEditable" );
+
+ return element;
},
_initSource: function() {
@@ -410,19 +417,18 @@ $.widget( "ui.autocomplete", {
},
_response: function() {
- var that = this,
- index = ++requestIndex;
+ var index = ++this.requestIndex;
- return function( content ) {
- if ( index === requestIndex ) {
- that.__response( content );
+ return $.proxy(function( content ) {
+ if ( index === this.requestIndex ) {
+ this.__response( content );
}
- that.pending--;
- if ( !that.pending ) {
- that.element.removeClass( "ui-autocomplete-loading" );
+ this.pending--;
+ if ( !this.pending ) {
+ this.element.removeClass( "ui-autocomplete-loading" );
}
- };
+ }, this );
},
__response: function( content ) {
@@ -479,10 +485,9 @@ $.widget( "ui.autocomplete", {
},
_suggest: function( items ) {
- var ul = this.menu.element
- .empty()
- .zIndex( this.element.zIndex() + 1 );
+ var ul = this.menu.element.empty();
this._renderMenu( ul, items );
+ this.isNewMenu = true;
this.menu.refresh();
// size and position menu
@@ -598,5 +603,4 @@ $.widget( "ui.autocomplete", $.ui.autocomplete, {
}
});
-
}( jQuery ));