Autocomplete: Remove core event/alias and deprecated module dependencies

This commit is contained in:
Alexander Schmitz 2015-05-13 21:54:08 -04:00
parent b240eed81b
commit 8b4ce807cd
7 changed files with 19 additions and 19 deletions

View File

@ -92,11 +92,11 @@
}) })
.removeClass( "ui-corner-all" ) .removeClass( "ui-corner-all" )
.addClass( "custom-combobox-toggle ui-corner-right" ) .addClass( "custom-combobox-toggle ui-corner-right" )
.mousedown(function() { .on( "mousedown", function() {
wasOpen = input.autocomplete( "widget" ).is( ":visible" ); wasOpen = input.autocomplete( "widget" ).is( ":visible" );
}) })
.click(function() { .on( "click", function() {
input.focus(); input.trigger( "focus" );
// Close if already visible // Close if already visible
if ( wasOpen ) { if ( wasOpen ) {
@ -165,7 +165,7 @@
$(function() { $(function() {
$( "#combobox" ).combobox(); $( "#combobox" ).combobox();
$( "#toggle" ).click(function() { $( "#toggle" ).on( "click", function() {
$( "#combobox" ).toggle(); $( "#combobox" ).toggle();
}); });
}); });

View File

@ -27,7 +27,7 @@
$( "#birds" ) $( "#birds" )
// don't navigate away from the field on tab when selecting an item // don't navigate away from the field on tab when selecting an item
.bind( "keydown", function( event ) { .on( "keydown", function( event ) {
if ( event.keyCode === $.ui.keyCode.TAB && if ( event.keyCode === $.ui.keyCode.TAB &&
$( this ).autocomplete( "instance" ).menu.active ) { $( this ).autocomplete( "instance" ).menu.active ) {
event.preventDefault(); event.preventDefault();

View File

@ -46,7 +46,7 @@
$( "#tags" ) $( "#tags" )
// don't navigate away from the field on tab when selecting an item // don't navigate away from the field on tab when selecting an item
.bind( "keydown", function( event ) { .on( "keydown", function( event ) {
if ( event.keyCode === $.ui.keyCode.TAB && if ( event.keyCode === $.ui.keyCode.TAB &&
$( this ).autocomplete( "instance" ).menu.active ) { $( this ).autocomplete( "instance" ).menu.active ) {
event.preventDefault(); event.preventDefault();

View File

@ -167,7 +167,7 @@ test( "allow form submit on enter when menu is not active", function() {
delay: 0, delay: 0,
minLength: 0 minLength: 0
}); });
element.bind( "keypress", function( e ) { element.on( "keypress", function( e ) {
didMove = !e.isDefaultPrevented(); didMove = !e.isDefaultPrevented();
}); });
element.simulate( "keydown", { keyCode: ( isKeyUp ? $.ui.keyCode.UP : $.ui.keyCode.DOWN ) } ); element.simulate( "keydown", { keyCode: ( isKeyUp ? $.ui.keyCode.UP : $.ui.keyCode.DOWN ) } );

View File

@ -66,7 +66,7 @@ $.each([
}), }),
menu = element.autocomplete( "widget" ); menu = element.autocomplete( "widget" );
element.simulate( "focus" )[ settings.valueMethod ]( "j" ).keydown(); element.simulate( "focus" )[ settings.valueMethod ]( "j" ).trigger( "keydown" );
setTimeout(function() { setTimeout(function() {
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 } );
@ -112,10 +112,10 @@ asyncTest( "cancel search", function() {
} }
}), }),
menu = element.autocomplete( "widget" ); menu = element.autocomplete( "widget" );
element.val( "ja" ).keydown(); element.val( "ja" ).trigger( "keydown" );
setTimeout(function() { setTimeout(function() {
ok( menu.is( ":hidden" ), "menu is hidden after first search" ); ok( menu.is( ":hidden" ), "menu is hidden after first search" );
element.val( "java" ).keydown(); element.val( "java" ).trigger( "keydown" );
setTimeout(function() { setTimeout(function() {
ok( menu.is( ":visible" ), "menu is visible after second search" ); ok( menu.is( ":visible" ), "menu is visible after second search" );
equal( menu.find( ".ui-menu-item" ).length, 2, "# of menu items" ); equal( menu.find( ".ui-menu-item" ).length, 2, "# of menu items" );
@ -135,7 +135,7 @@ asyncTest( "cancel focus", function() {
return false; return false;
} }
}); });
element.val( "ja" ).keydown(); element.val( "ja" ).trigger( "keydown" );
setTimeout(function() { setTimeout(function() {
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( element.val(), customVal ); equal( element.val(), customVal );
@ -154,7 +154,7 @@ asyncTest( "cancel select", function() {
return false; return false;
} }
}); });
element.val( "ja" ).keydown(); element.val( "ja" ).trigger( "keydown" );
setTimeout(function() { setTimeout(function() {
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 } );
@ -179,7 +179,7 @@ asyncTest( "blur during remote search", function() {
ok( false, "opened after a blur" ); ok( false, "opened after a blur" );
} }
}); });
ac.val( "ro" ).keydown(); ac.val( "ro" ).trigger( "keydown" );
}); });
} ); } );

View File

@ -87,7 +87,7 @@ function autoFocusTest( afValue, focusedLength ) {
start(); start();
} }
}); });
element.val( "ja" ).keydown(); element.val( "ja" ).trigger( "keydown" );
stop(); stop();
} }
@ -108,7 +108,7 @@ asyncTest( "delay", function() {
delay: 25 delay: 25
}), }),
menu = element.autocomplete( "widget" ); menu = element.autocomplete( "widget" );
element.val( "ja" ).keydown(); element.val( "ja" ).trigger( "keydown" );
ok( menu.is( ":hidden" ), "menu is closed immediately after search" ); ok( menu.is( ":hidden" ), "menu is closed immediately after search" );
@ -125,7 +125,7 @@ asyncTest( "disabled", function( assert ) {
delay: 0 delay: 0
}), }),
menu = element.autocomplete( "disable" ).autocomplete( "widget" ); menu = element.autocomplete( "disable" ).autocomplete( "widget" );
element.val( "ja" ).keydown(); element.val( "ja" ).trigger( "keydown" );
ok( menu.is( ":hidden" ) ); ok( menu.is( ":hidden" ) );

View File

@ -233,7 +233,7 @@ $.widget( "ui.autocomplete", {
// we restore focus to ensure that the menu closes properly based on the user's // we restore focus to ensure that the menu closes properly based on the user's
// next actions. // next actions.
if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) { if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) {
this.element.focus(); this.element.trigger( "focus" );
} }
} ); } );
@ -262,7 +262,7 @@ $.widget( "ui.autocomplete", {
if ( this.isNewMenu ) { if ( this.isNewMenu ) {
this.isNewMenu = false; this.isNewMenu = false;
if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) { if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
this.menu.blur(); this.menu.trigger( "blur" );
this.document.one( "mousemove", function() { this.document.one( "mousemove", function() {
$( event.target ).trigger( event.originalEvent ); $( event.target ).trigger( event.originalEvent );
@ -293,7 +293,7 @@ $.widget( "ui.autocomplete", {
// 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.focus(); this.element.trigger( "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
// is asynchronous, so we need to reset the previous // is asynchronous, so we need to reset the previous