mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
parent
a6499c0dee
commit
8029cc94e1
@ -22,7 +22,7 @@ common.testWidget( "autocomplete", {
|
|||||||
},
|
},
|
||||||
source: null,
|
source: null,
|
||||||
|
|
||||||
// callbacks
|
// Callbacks
|
||||||
change: null,
|
change: null,
|
||||||
close: null,
|
close: null,
|
||||||
create: null,
|
create: null,
|
||||||
|
@ -71,7 +71,8 @@ $.each([
|
|||||||
ok( menu.is( ":visible" ), "menu is visible after delay" );
|
ok( menu.is( ":visible" ), "menu is visible after delay" );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
||||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
||||||
// blur must be async for IE to handle it properly
|
|
||||||
|
// Blur must be async for IE to handle it properly
|
||||||
setTimeout( function() {
|
setTimeout( function() {
|
||||||
element.simulate( "blur" );
|
element.simulate( "blur" );
|
||||||
} );
|
} );
|
||||||
|
@ -189,19 +189,21 @@ test( "minLength, exceed then drop below then exceed", function() {
|
|||||||
} ),
|
} ),
|
||||||
menu = element.autocomplete( "widget" );
|
menu = element.autocomplete( "widget" );
|
||||||
|
|
||||||
// trigger a valid search
|
// Trigger a valid search
|
||||||
ok( menu.is( ":hidden" ), "menu is hidden before first search" );
|
ok( menu.is( ":hidden" ), "menu is hidden before first search" );
|
||||||
element.autocomplete( "search", "12" );
|
element.autocomplete( "search", "12" );
|
||||||
|
|
||||||
// trigger a search below the minLength, to turn on cancelSearch flag
|
// Trigger a search below the minLength, to turn on cancelSearch flag
|
||||||
ok( menu.is( ":hidden" ), "menu is hidden before second search" );
|
ok( menu.is( ":hidden" ), "menu is hidden before second search" );
|
||||||
element.autocomplete( "search", "1" );
|
element.autocomplete( "search", "1" );
|
||||||
|
|
||||||
// trigger a valid search
|
// Trigger a valid search
|
||||||
element.autocomplete( "search", "13" );
|
element.autocomplete( "search", "13" );
|
||||||
// react as if the first search was cancelled (default ajax behavior)
|
|
||||||
|
// React as if the first search was cancelled (default ajax behavior)
|
||||||
_res[ 0 ]( [] );
|
_res[ 0 ]( [] );
|
||||||
// react to second search
|
|
||||||
|
// React to second search
|
||||||
_res[ 1 ]( [ "13" ] );
|
_res[ 1 ]( [ "13" ] );
|
||||||
|
|
||||||
ok( menu.is( ":visible" ), "menu is visible after searches" );
|
ok( menu.is( ":visible" ), "menu is visible after searches" );
|
||||||
|
@ -51,7 +51,7 @@ $.widget( "ui.autocomplete", {
|
|||||||
},
|
},
|
||||||
source: null,
|
source: null,
|
||||||
|
|
||||||
// callbacks
|
// Callbacks
|
||||||
change: null,
|
change: null,
|
||||||
close: null,
|
close: null,
|
||||||
focus: null,
|
focus: null,
|
||||||
@ -165,7 +165,7 @@ $.widget( "ui.autocomplete", {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// replicate some key handlers to allow them to repeat in Firefox and Opera
|
// Replicate some key handlers to allow them to repeat in Firefox and Opera
|
||||||
var keyCode = $.ui.keyCode;
|
var keyCode = $.ui.keyCode;
|
||||||
switch ( event.keyCode ) {
|
switch ( event.keyCode ) {
|
||||||
case keyCode.PAGE_UP:
|
case keyCode.PAGE_UP:
|
||||||
@ -239,7 +239,7 @@ $.widget( "ui.autocomplete", {
|
|||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// clicking on the scrollbar causes focus to shift to the body
|
// Clicking on the scrollbar causes focus to shift to the body
|
||||||
// but we can't detect a mouseup or a click immediately afterward
|
// 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
|
// so we have to track the next mousedown and close the menu if
|
||||||
// the user clicks somewhere outside of the autocomplete
|
// the user clicks somewhere outside of the autocomplete
|
||||||
@ -293,7 +293,7 @@ $.widget( "ui.autocomplete", {
|
|||||||
var item = ui.item.data( "ui-autocomplete-item" ),
|
var item = ui.item.data( "ui-autocomplete-item" ),
|
||||||
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 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) {
|
if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) {
|
||||||
this.element.trigger( "focus" );
|
this.element.trigger( "focus" );
|
||||||
this.previous = previous;
|
this.previous = previous;
|
||||||
@ -327,7 +327,7 @@ $.widget( "ui.autocomplete", {
|
|||||||
|
|
||||||
this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
|
this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
|
||||||
|
|
||||||
// turning off autocomplete prevents the browser from remembering the
|
// Turning off autocomplete prevents the browser from remembering the
|
||||||
// value when navigating through history, so we re-enable autocomplete
|
// value when navigating through history, so we re-enable autocomplete
|
||||||
// if the page is unloaded before the widget is destroyed. #7790
|
// if the page is unloaded before the widget is destroyed. #7790
|
||||||
this._on( this.window, {
|
this._on( this.window, {
|
||||||
@ -427,7 +427,7 @@ $.widget( "ui.autocomplete", {
|
|||||||
search: function( value, event ) {
|
search: function( value, event ) {
|
||||||
value = value != null ? value : this._value();
|
value = value != null ? value : this._value();
|
||||||
|
|
||||||
// always save the actual value, not the one passed as an argument
|
// Always save the actual value, not the one passed as an argument
|
||||||
this.term = this._value();
|
this.term = this._value();
|
||||||
|
|
||||||
if ( value.length < this.options.minLength ) {
|
if ( value.length < this.options.minLength ) {
|
||||||
@ -523,7 +523,7 @@ $.widget( "ui.autocomplete", {
|
|||||||
this.isNewMenu = true;
|
this.isNewMenu = true;
|
||||||
this.menu.refresh();
|
this.menu.refresh();
|
||||||
|
|
||||||
// size and position menu
|
// Size and position menu
|
||||||
ul.show();
|
ul.show();
|
||||||
this._resizeMenu();
|
this._resizeMenu();
|
||||||
ul.position( $.extend( {
|
ul.position( $.extend( {
|
||||||
@ -592,7 +592,7 @@ $.widget( "ui.autocomplete", {
|
|||||||
if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
|
if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
|
||||||
this._move( keyEvent, event );
|
this._move( keyEvent, event );
|
||||||
|
|
||||||
// prevents moving cursor to beginning/end of the text field in some browsers
|
// Prevents moving cursor to beginning/end of the text field in some browsers
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -610,7 +610,7 @@ $.extend( $.ui.autocomplete, {
|
|||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// live region extension, adding a `messages` option
|
// Live region extension, adding a `messages` option
|
||||||
// NOTE: This is an experimental API. We are still investigating
|
// NOTE: This is an experimental API. We are still investigating
|
||||||
// a full solution for string manipulation and internationalization.
|
// a full solution for string manipulation and internationalization.
|
||||||
$.widget( "ui.autocomplete", $.ui.autocomplete, {
|
$.widget( "ui.autocomplete", $.ui.autocomplete, {
|
||||||
|
Loading…
Reference in New Issue
Block a user