2012-06-18 17:26:46 +00:00
|
|
|
|
(function( $ ) {
|
2010-05-06 15:10:52 +00:00
|
|
|
|
|
2012-04-19 16:19:52 +00:00
|
|
|
|
var log = TestHelpers.menu.log,
|
2012-06-18 17:26:46 +00:00
|
|
|
|
logOutput = TestHelpers.menu.logOutput,
|
2012-04-19 16:19:52 +00:00
|
|
|
|
click = TestHelpers.menu.click;
|
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
module( "menu: events", {
|
|
|
|
|
setup: function() {
|
|
|
|
|
TestHelpers.menu.clearLog();
|
|
|
|
|
}
|
|
|
|
|
});
|
2010-05-06 15:10:52 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
test( "handle click on menu", function() {
|
|
|
|
|
expect( 1 );
|
2012-06-27 13:49:56 +00:00
|
|
|
|
var element = $( "#menu1" ).menu({
|
2012-06-18 17:26:46 +00:00
|
|
|
|
select: function( event, ui ) {
|
2012-04-19 16:19:52 +00:00
|
|
|
|
log();
|
2010-05-06 15:10:52 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "click", true );
|
|
|
|
|
click( $( "#menu1" ), "1" );
|
|
|
|
|
log( "afterclick" );
|
2012-06-27 13:49:56 +00:00
|
|
|
|
click( element, "2" );
|
2012-06-18 17:26:46 +00:00
|
|
|
|
click( $( "#menu1" ), "3" );
|
2012-06-27 13:49:56 +00:00
|
|
|
|
click( element, "1" );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "click,1,afterclick,2,3,1", "Click order not valid." );
|
2010-05-06 15:10:52 +00:00
|
|
|
|
});
|
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
test( "handle click on custom item menu", function() {
|
|
|
|
|
expect( 1 );
|
2012-06-27 13:49:56 +00:00
|
|
|
|
var element = $( "#menu5" ).menu({
|
2012-06-18 17:26:46 +00:00
|
|
|
|
select: function( event, ui ) {
|
2012-04-19 16:19:52 +00:00
|
|
|
|
log();
|
2011-09-14 15:29:36 +00:00
|
|
|
|
},
|
2011-12-15 18:43:28 +00:00
|
|
|
|
menus: "div"
|
2011-09-14 15:29:36 +00:00
|
|
|
|
});
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "click", true );
|
|
|
|
|
click( $( "#menu5" ), "1" );
|
|
|
|
|
log( "afterclick" );
|
2012-06-27 13:49:56 +00:00
|
|
|
|
click( element, "2" );
|
2012-06-18 17:26:46 +00:00
|
|
|
|
click( $( "#menu5" ), "3" );
|
2012-06-27 13:49:56 +00:00
|
|
|
|
click( element, "1" );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "click,1,afterclick,2,3,1", "Click order not valid." );
|
2011-09-14 15:29:36 +00:00
|
|
|
|
});
|
|
|
|
|
|
2012-05-23 04:52:59 +00:00
|
|
|
|
asyncTest( "handle blur", function() {
|
|
|
|
|
expect( 1 );
|
|
|
|
|
var blurHandled = false,
|
2012-06-27 13:49:56 +00:00
|
|
|
|
element = $( "#menu1" ).menu({
|
2012-05-23 04:52:59 +00:00
|
|
|
|
blur: function( event, ui ) {
|
|
|
|
|
// Ignore duplicate blur event fired by IE
|
|
|
|
|
if ( !blurHandled ) {
|
|
|
|
|
blurHandled = true;
|
|
|
|
|
equal( event.type, "menublur", "blur event.type is 'menublur'" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2012-06-27 13:49:56 +00:00
|
|
|
|
click( element, "1" );
|
2012-05-23 04:52:59 +00:00
|
|
|
|
setTimeout( function() {
|
2012-06-27 13:49:56 +00:00
|
|
|
|
element.blur();
|
2012-05-23 04:52:59 +00:00
|
|
|
|
start();
|
2012-06-18 17:26:46 +00:00
|
|
|
|
}, 350 );
|
2012-05-23 04:52:59 +00:00
|
|
|
|
});
|
2011-07-19 21:15:59 +00:00
|
|
|
|
|
2012-05-23 04:52:59 +00:00
|
|
|
|
asyncTest( "handle blur on click", function() {
|
|
|
|
|
expect( 1 );
|
|
|
|
|
var blurHandled = false,
|
2012-06-27 13:49:56 +00:00
|
|
|
|
element = $( "#menu1" ).menu({
|
2012-05-23 04:52:59 +00:00
|
|
|
|
blur: function( event, ui ) {
|
|
|
|
|
// Ignore duplicate blur event fired by IE
|
|
|
|
|
if ( !blurHandled ) {
|
|
|
|
|
blurHandled = true;
|
|
|
|
|
equal( event.type, "menublur", "blur event.type is 'menublur'" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2012-06-27 13:49:56 +00:00
|
|
|
|
click( element, "1" );
|
2012-05-23 04:52:59 +00:00
|
|
|
|
setTimeout( function() {
|
2012-06-18 17:26:46 +00:00
|
|
|
|
$( "<a>", { id: "remove"} ).appendTo( "body" ).trigger( "click" );
|
2012-05-23 04:52:59 +00:00
|
|
|
|
start();
|
2012-06-18 17:26:46 +00:00
|
|
|
|
}, 350 );
|
2011-07-19 21:15:59 +00:00
|
|
|
|
});
|
|
|
|
|
|
2012-05-23 04:52:59 +00:00
|
|
|
|
test( "handle focus of menu with active item", function() {
|
|
|
|
|
expect( 1 );
|
|
|
|
|
var element = $( "#menu1" ).menu({
|
2011-09-14 15:29:36 +00:00
|
|
|
|
focus: function( event, ui ) {
|
2012-05-23 04:52:59 +00:00
|
|
|
|
log( $( event.target ).find( ".ui-state-focus" ).parent().index() );
|
|
|
|
|
}
|
2011-09-14 15:29:36 +00:00
|
|
|
|
});
|
|
|
|
|
|
2012-05-23 04:52:59 +00:00
|
|
|
|
log( "focus", true );
|
|
|
|
|
element.focus();
|
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
|
|
|
|
element.focus();
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "focus,0,1,2,2", "current active item remains active" );
|
2011-09-14 15:29:36 +00:00
|
|
|
|
});
|
|
|
|
|
|
2011-09-12 13:43:49 +00:00
|
|
|
|
asyncTest( "handle submenu auto collapse: mouseleave", function() {
|
|
|
|
|
expect( 4 );
|
2012-06-27 13:49:56 +00:00
|
|
|
|
var element = $( "#menu2" ).menu(),
|
2012-04-20 04:50:52 +00:00
|
|
|
|
event = $.Event( "mouseenter" );
|
2011-09-12 13:43:49 +00:00
|
|
|
|
|
2012-02-17 22:05:12 +00:00
|
|
|
|
function menumouseleave1() {
|
2012-06-27 13:49:56 +00:00
|
|
|
|
equal( element.find( "ul[aria-expanded='true']" ).length, 1, "first submenu expanded" );
|
|
|
|
|
element.menu( "focus", event, element.find( "li:nth-child(7) li:first" ) );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
setTimeout( menumouseleave2, 350 );
|
|
|
|
|
}
|
|
|
|
|
function menumouseleave2() {
|
2012-06-27 13:49:56 +00:00
|
|
|
|
equal( element.find( "ul[aria-expanded='true']" ).length, 2, "second submenu expanded" );
|
|
|
|
|
element.find( "ul[aria-expanded='true']:first" ).trigger( "mouseleave" );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
setTimeout( menumouseleave3, 350 );
|
|
|
|
|
}
|
|
|
|
|
function menumouseleave3() {
|
2012-06-27 13:49:56 +00:00
|
|
|
|
equal( element.find( "ul[aria-expanded='true']" ).length, 1, "second submenu collapsed" );
|
|
|
|
|
element.trigger( "mouseleave" );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
setTimeout( menumouseleave4, 350 );
|
|
|
|
|
}
|
|
|
|
|
function menumouseleave4() {
|
2012-06-27 13:49:56 +00:00
|
|
|
|
equal( element.find( "ul[aria-expanded='true']" ).length, 0, "first submenu collapsed" );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
start();
|
|
|
|
|
}
|
2012-04-19 13:39:21 +00:00
|
|
|
|
|
2012-06-27 13:49:56 +00:00
|
|
|
|
element.find( "li:nth-child(7)" ).trigger( "mouseenter" );
|
2012-04-19 13:39:21 +00:00
|
|
|
|
setTimeout( menumouseleave1, 350 );
|
2011-09-12 13:43:49 +00:00
|
|
|
|
});
|
|
|
|
|
|
2012-02-17 22:05:12 +00:00
|
|
|
|
asyncTest( "handle submenu auto collapse: mouseleave", function() {
|
|
|
|
|
expect( 4 );
|
2012-06-27 13:49:56 +00:00
|
|
|
|
var element = $( "#menu5" ).menu({ menus: "div" }),
|
2012-04-20 04:50:52 +00:00
|
|
|
|
event = $.Event( "mouseenter" );
|
2011-09-14 15:29:36 +00:00
|
|
|
|
|
2012-02-17 22:05:12 +00:00
|
|
|
|
function menumouseleave1() {
|
2012-06-27 13:49:56 +00:00
|
|
|
|
equal( element.find( "div[aria-expanded='true']" ).length, 1, "first submenu expanded" );
|
|
|
|
|
element.menu( "focus", event, element.find( ":nth-child(7)" ).find( "div" ).eq( 0 ).children().eq( 0 ) );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
setTimeout( menumouseleave2, 350 );
|
|
|
|
|
}
|
|
|
|
|
function menumouseleave2() {
|
2012-06-27 13:49:56 +00:00
|
|
|
|
equal( element.find( "div[aria-expanded='true']" ).length, 2, "second submenu expanded" );
|
|
|
|
|
element.find( "div[aria-expanded='true']:first" ).trigger( "mouseleave" );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
setTimeout( menumouseleave3, 350 );
|
|
|
|
|
}
|
|
|
|
|
function menumouseleave3() {
|
2012-06-27 13:49:56 +00:00
|
|
|
|
equal( element.find( "div[aria-expanded='true']" ).length, 1, "second submenu collapsed" );
|
|
|
|
|
element.trigger( "mouseleave" );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
setTimeout( menumouseleave4, 350 );
|
|
|
|
|
}
|
|
|
|
|
function menumouseleave4() {
|
2012-06-27 13:49:56 +00:00
|
|
|
|
equal( element.find( "div[aria-expanded='true']" ).length, 0, "first submenu collapsed" );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
start();
|
|
|
|
|
}
|
2012-04-19 13:39:21 +00:00
|
|
|
|
|
2012-06-27 13:49:56 +00:00
|
|
|
|
element.find( ":nth-child(7)" ).trigger( "mouseenter" );
|
2012-04-19 13:39:21 +00:00
|
|
|
|
setTimeout( menumouseleave1, 350 );
|
2011-09-14 15:29:36 +00:00
|
|
|
|
});
|
|
|
|
|
|
2011-09-22 18:56:53 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
test( "handle keyboard navigation on menu without scroll and without submenus", function() {
|
|
|
|
|
expect( 12 );
|
|
|
|
|
var element = $( "#menu1" ).menu({
|
|
|
|
|
select: function( event, ui ) {
|
|
|
|
|
log( $( ui.item[0] ).text() );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
},
|
|
|
|
|
focus: function( event, ui ) {
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( $( event.target ).find( ".ui-state-focus" ).parent().index() );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-06 21:01:40 +00:00
|
|
|
|
element.focus();
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,0,1,2", "Keydown DOWN" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,1", "Keydown UP" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown", "Keydown LEFT (no effect)" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown", "Keydown RIGHT (no effect)" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,4", "Keydown PAGE_DOWN" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown", "Keydown PAGE_DOWN (no effect)" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,0", "Keydown PAGE_UP" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown", "Keydown PAGE_UP (no effect)" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,4", "Keydown END" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,0", "Keydown HOME" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown", "Keydown ESCAPE (no effect)" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,Aberdeen", "Keydown ENTER" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
});
|
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
asyncTest( "handle keyboard navigation on menu without scroll and with submenus", function() {
|
|
|
|
|
expect( 16 );
|
|
|
|
|
var element = $( "#menu2" ).menu({
|
|
|
|
|
select: function( event, ui ) {
|
|
|
|
|
log( $( ui.item[0] ).text() );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
},
|
|
|
|
|
focus: function( event, ui ) {
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( $( event.target ).find( ".ui-state-focus" ).parent().index() );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
element.one( "menufocus", function( event, ui ) {
|
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,1,2", "Keydown DOWN" );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
setTimeout( menukeyboard1, 50 );
|
|
|
|
|
});
|
2012-02-06 21:01:40 +00:00
|
|
|
|
element.focus();
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-02-17 22:05:12 +00:00
|
|
|
|
function menukeyboard1() {
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-09 21:19:50 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
|
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,1,0", "Keydown UP" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown", "Keydown LEFT (no effect)" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-09 21:19:50 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
|
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
setTimeout(function() {
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,1,2,3,4,0", "Keydown RIGHT (open submenu)" );
|
2012-06-18 17:26:46 +00:00
|
|
|
|
setTimeout( menukeyboard2, 50 );
|
|
|
|
|
}, 50 );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
}
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-02-17 22:05:12 +00:00
|
|
|
|
function menukeyboard2() {
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,4", "Keydown LEFT (close submenu)" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
// re-open submenu
|
2012-02-17 22:05:12 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
|
|
|
|
|
setTimeout( menukeyboard3, 50 );
|
|
|
|
|
}
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-02-17 22:05:12 +00:00
|
|
|
|
function menukeyboard3() {
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,2", "Keydown PAGE_DOWN" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown", "Keydown PAGE_DOWN (no effect)" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,0", "Keydown PAGE_UP" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown", "Keydown PAGE_UP (no effect)" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,2", "Keydown END" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,0", "Keydown HOME" );
|
2012-02-09 21:19:50 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,4", "Keydown ESCAPE (close submenu)" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-05-22 14:01:40 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.SPACE } );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
setTimeout( menukeyboard4, 50 );
|
|
|
|
|
}
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-02-17 22:05:12 +00:00
|
|
|
|
function menukeyboard4() {
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,0", "Keydown SPACE (open submenu)" );
|
2012-05-22 14:01:40 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-05-22 14:01:40 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,4", "Keydown ESCAPE (close submenu)" );
|
2012-05-22 14:01:40 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-05-25 04:44:51 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
|
|
|
|
|
setTimeout( function() {
|
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
|
|
|
|
|
setTimeout( function() {
|
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,5,6,0,1,0,2,4,0", "Keydown skip dividers and items without anchors" );
|
2012-05-25 04:44:51 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-05-25 04:44:51 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
|
|
|
|
setTimeout( menukeyboard6, 50 );
|
|
|
|
|
}, 50 );
|
|
|
|
|
}, 50 );
|
2012-05-22 14:01:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-05-25 04:44:51 +00:00
|
|
|
|
function menukeyboard6() {
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,Ada", "Keydown ENTER (open submenu)" );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
start();
|
|
|
|
|
}
|
2011-07-25 14:13:13 +00:00
|
|
|
|
});
|
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
test( "handle keyboard navigation on menu with scroll and without submenus", function() {
|
|
|
|
|
expect( 14 );
|
|
|
|
|
var element = $( "#menu3" ).menu({
|
|
|
|
|
select: function( event, ui ) {
|
|
|
|
|
log( $( ui.item[0] ).text() );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
},
|
|
|
|
|
focus: function( event, ui ) {
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( $( event.target ).find( ".ui-state-focus" ).parent().index());
|
2011-07-25 14:13:13 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-06 21:01:40 +00:00
|
|
|
|
element.focus();
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,0,1,2", "Keydown DOWN" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
|
2012-02-06 21:01:40 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,1,0", "Keydown UP" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown", "Keydown LEFT (no effect)" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown", "Keydown RIGHT (no effect)" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,10", "Keydown PAGE_DOWN" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,20", "Keydown PAGE_DOWN" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,10", "Keydown PAGE_UP" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,0", "Keydown PAGE_UP" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown", "Keydown PAGE_UP (no effect)" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,37", "Keydown END" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown", "Keydown PAGE_DOWN (no effect)" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,0", "Keydown HOME" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown", "Keydown ESCAPE (no effect)" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,Aberdeen", "Keydown ENTER" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
});
|
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
asyncTest( "handle keyboard navigation on menu with scroll and with submenus", function() {
|
|
|
|
|
expect( 14 );
|
|
|
|
|
var element = $( "#menu4" ).menu({
|
|
|
|
|
select: function( event, ui ) {
|
|
|
|
|
log( $( ui.item[0] ).text() );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
},
|
|
|
|
|
focus: function( event, ui ) {
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( $( event.target ).find( ".ui-state-focus" ).parent().index());
|
2011-07-25 14:13:13 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
element.one( "menufocus", function( event, ui ) {
|
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,1,2", "Keydown DOWN" );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
setTimeout( menukeyboard1, 50 );
|
|
|
|
|
});
|
2012-02-06 21:01:40 +00:00
|
|
|
|
element.focus();
|
2012-02-28 14:56:32 +00:00
|
|
|
|
|
2012-02-17 22:05:12 +00:00
|
|
|
|
function menukeyboard1() {
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-09 21:19:50 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
|
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,1,0", "Keydown UP" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown", "Keydown LEFT (no effect)" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-09 21:19:50 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
|
|
|
|
|
|
|
|
|
|
setTimeout( function() {
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,1,0", "Keydown RIGHT (open submenu)" );
|
2012-06-18 17:26:46 +00:00
|
|
|
|
}, 50 );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
setTimeout( menukeyboard2, 50 );
|
|
|
|
|
}
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-02-17 22:05:12 +00:00
|
|
|
|
function menukeyboard2() {
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,1", "Keydown LEFT (close submenu)" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
// re-open submenu
|
2012-02-17 22:05:12 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
|
|
|
|
|
setTimeout( menukeyboard3, 50 );
|
|
|
|
|
}
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-02-17 22:05:12 +00:00
|
|
|
|
function menukeyboard3() {
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,10", "Keydown PAGE_DOWN" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,20", "Keydown PAGE_DOWN" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,10", "Keydown PAGE_UP" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,0", "Keydown PAGE_UP" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,27", "Keydown END" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,0", "Keydown HOME" );
|
2012-02-09 21:19:50 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,1", "Keydown ESCAPE (close submenu)" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
|
|
|
|
setTimeout( menukeyboard4, 50 );
|
|
|
|
|
}
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-02-17 22:05:12 +00:00
|
|
|
|
function menukeyboard4() {
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,0", "Keydown ENTER (open submenu)" );
|
2012-02-09 21:19:50 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-02-17 22:05:12 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,Aberdeen", "Keydown ENTER (select item)" );
|
2011-07-25 14:13:13 +00:00
|
|
|
|
|
2012-02-17 22:05:12 +00:00
|
|
|
|
start();
|
|
|
|
|
}
|
2011-07-25 14:13:13 +00:00
|
|
|
|
});
|
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
asyncTest( "handle keyboard navigation and mouse click on menu with disabled items", function() {
|
|
|
|
|
expect( 6 );
|
|
|
|
|
var element = $( "#menu6" ).menu({
|
|
|
|
|
select: function( event, ui ) {
|
|
|
|
|
log( $( ui.item[0] ).text() );
|
2012-04-19 02:29:39 +00:00
|
|
|
|
},
|
|
|
|
|
focus: function( event, ui ) {
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( $( event.target ).find( ".ui-state-focus" ).parent().index());
|
2012-04-19 02:29:39 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-04-19 02:29:39 +00:00
|
|
|
|
element.one( "menufocus", function( event, ui ) {
|
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,1", "Keydown focus but not select disabled item" );
|
2012-04-19 02:29:39 +00:00
|
|
|
|
setTimeout( menukeyboard1, 50 );
|
|
|
|
|
});
|
|
|
|
|
element.focus();
|
|
|
|
|
|
|
|
|
|
function menukeyboard1() {
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-04-19 02:29:39 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,2,3,4", "Keydown focus disabled item with submenu" );
|
2012-04-19 02:29:39 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-04-19 02:29:39 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown", "Keydown LEFT (no effect)" );
|
2012-04-19 02:29:39 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-04-19 02:29:39 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
|
|
|
|
|
|
|
|
|
|
setTimeout( function() {
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown", "Keydown RIGHT (no effect on disabled sub-menu)" );
|
2012-04-19 02:29:39 +00:00
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "keydown", true );
|
2012-04-19 02:29:39 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
|
|
|
|
|
|
|
|
|
setTimeout( function() {
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown", "Keydown ENTER (no effect on disabled sub-menu)" );
|
2012-06-18 17:26:46 +00:00
|
|
|
|
log( "click", true );
|
2012-04-19 16:19:52 +00:00
|
|
|
|
click( element, "1" );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "click", "Click disabled item (no effect)" );
|
2012-04-19 02:29:39 +00:00
|
|
|
|
start();
|
2012-06-18 17:26:46 +00:00
|
|
|
|
}, 50 );
|
|
|
|
|
}, 50 );
|
2012-04-19 02:29:39 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
test( "handle keyboard navigation with spelling of menu items", function() {
|
2012-05-23 04:52:59 +00:00
|
|
|
|
expect( 2 );
|
|
|
|
|
var element = $( "#menu2" ).menu({
|
|
|
|
|
focus: function( event, ui ) {
|
|
|
|
|
log( $( event.target ).find( ".ui-state-focus" ).parent().index() );
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
log( "keydown", true );
|
|
|
|
|
element.one( "menufocus", function( event, ui ) {
|
|
|
|
|
element.simulate( "keydown", { keyCode: 65 } );
|
|
|
|
|
element.simulate( "keydown", { keyCode: 68 } );
|
|
|
|
|
element.simulate( "keydown", { keyCode: 68 } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,0,1,3", "Keydown focus Addyston by spelling the first 3 letters" );
|
2012-05-23 04:52:59 +00:00
|
|
|
|
element.simulate( "keydown", { keyCode: 68 } );
|
2012-06-18 17:38:16 +00:00
|
|
|
|
equal( logOutput(), "keydown,0,1,3,4", "Keydown focus Delphi by repeating the 'd' again" );
|
2012-05-23 04:52:59 +00:00
|
|
|
|
});
|
|
|
|
|
element.focus();
|
|
|
|
|
});
|
|
|
|
|
|
2012-06-18 17:26:46 +00:00
|
|
|
|
})( jQuery );
|