*/
(function($) {
+var log = TestHelpers.menu.log,
+ click = TestHelpers.menu.click;
+
module("menu: events");
test("handle click on menu", function() {
expect(1);
var menu = $('#menu1').menu({
select: function(event, ui) {
- menu_log();
+ log();
}
});
- menu_log("click",true);
- menu_click($('#menu1'),"1");
- menu_log("afterclick");
- menu_click( menu,"2");
- menu_click($('#menu1'),"3");
- menu_click( menu,"1");
+ log("click",true);
+ click($('#menu1'),"1");
+ log("afterclick");
+ click( menu,"2");
+ click($('#menu1'),"3");
+ click( menu,"1");
equal( $("#log").html(), "1,3,2,afterclick,1,click,", "Click order not valid.");
});
expect(1);
var menu = $('#menu5').menu({
select: function(event, ui) {
- menu_log();
+ log();
},
menus: "div"
});
- menu_log("click",true);
- menu_click($('#menu5'),"1");
- menu_log("afterclick");
- menu_click( menu,"2");
- menu_click($('#menu5'),"3");
- menu_click( menu,"1");
+ log("click",true);
+ click($('#menu5'),"1");
+ log("afterclick");
+ click( menu,"2");
+ click($('#menu5'),"3");
+ click( menu,"1");
equal( $("#log").html(), "1,3,2,afterclick,1,click,", "Click order not valid.");
});
items: "div"
});
- menu_click($('#menu5'),"1");
+ click($('#menu5'),"1");
$( "<a>", { id: "remove"} ).appendTo("body").trigger( "click" );
$("#remove").remove();
expect(12);
var element = $('#menu1').menu({
select: function(event, ui) {
- menu_log($(ui.item[0]).text());
+ log($(ui.item[0]).text());
},
focus: function( event, ui ) {
- menu_log($(event.target).find(".ui-state-focus").parent().index());
+ log($(event.target).find(".ui-state-focus").parent().index());
}
});
- menu_log("keydown",true);
+ log("keydown",true);
element.focus();
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( $("#log").html(), "2,1,0,keydown,", "Keydown DOWN");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
equal( $("#log").html(), "1,keydown,", "Keydown UP");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
equal( $("#log").html(), "keydown,", "Keydown LEFT (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
equal( $("#log").html(), "keydown,", "Keydown RIGHT (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "4,keydown,", "Keydown PAGE_DOWN");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "keydown,", "Keydown PAGE_DOWN (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "0,keydown,", "Keydown PAGE_UP");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "keydown,", "Keydown PAGE_UP (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
equal( $("#log").html(), "4,keydown,", "Keydown END");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
equal( $("#log").html(), "0,keydown,", "Keydown HOME");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
equal( $("#log").html(), "keydown,", "Keydown ESCAPE (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
equal( $("#log").html(), "Aberdeen,keydown,", "Keydown ENTER");
});
expect(14);
var element = $('#menu2').menu({
select: function(event, ui) {
- menu_log($(ui.item[0]).text());
+ log($(ui.item[0]).text());
},
focus: function( event, ui ) {
- menu_log($(event.target).find(".ui-state-focus").parent().index());
+ log($(event.target).find(".ui-state-focus").parent().index());
}
});
- menu_log("keydown",true);
+ log("keydown",true);
element.one( "menufocus", function( event, ui ) {
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.focus();
function menukeyboard1() {
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
equal( $("#log").html(), "0,1,keydown,", "Keydown UP");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
equal( $("#log").html(), "keydown,", "Keydown LEFT (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
}
function menukeyboard2() {
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
equal( $("#log").html(), "4,keydown,", "Keydown LEFT (close submenu)");
}
function menukeyboard3() {
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "2,keydown,", "Keydown PAGE_DOWN");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "keydown,", "Keydown PAGE_DOWN (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "0,keydown,", "Keydown PAGE_UP");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "keydown,", "Keydown PAGE_UP (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
equal( $("#log").html(), "2,keydown,", "Keydown END");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
equal( $("#log").html(), "0,keydown,", "Keydown HOME");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
equal( $("#log").html(), "4,keydown,", "Keydown ESCAPE (close submenu)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
setTimeout( menukeyboard4, 50 );
}
function menukeyboard4() {
equal( $("#log").html(), "0,keydown,", "Keydown ENTER (open submenu)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
equal( $("#log").html(), "Ada,keydown,", "Keydown ENTER (select item)");
expect(14);
var element = $('#menu3').menu({
select: function(event, ui) {
- menu_log($(ui.item[0]).text());
+ log($(ui.item[0]).text());
},
focus: function( event, ui ) {
- menu_log($(event.target).find(".ui-state-focus").parent().index());
+ log($(event.target).find(".ui-state-focus").parent().index());
}
});
- menu_log("keydown",true);
+ log("keydown",true);
element.focus();
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( $("#log").html(), "2,1,0,keydown,", "Keydown DOWN");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
equal( $("#log").html(), "0,1,keydown,", "Keydown UP");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
equal( $("#log").html(), "keydown,", "Keydown LEFT (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
equal( $("#log").html(), "keydown,", "Keydown RIGHT (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "10,keydown,", "Keydown PAGE_DOWN");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "20,keydown,", "Keydown PAGE_DOWN");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "10,keydown,", "Keydown PAGE_UP");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "0,keydown,", "Keydown PAGE_UP");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "keydown,", "Keydown PAGE_UP (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
equal( $("#log").html(), "37,keydown,", "Keydown END");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "keydown,", "Keydown PAGE_DOWN (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
equal( $("#log").html(), "0,keydown,", "Keydown HOME");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
equal( $("#log").html(), "keydown,", "Keydown ESCAPE (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
equal( $("#log").html(), "Aberdeen,keydown,", "Keydown ENTER");
});
expect(14);
var element = $('#menu4').menu({
select: function(event, ui) {
- menu_log($(ui.item[0]).text());
+ log($(ui.item[0]).text());
},
focus: function( event, ui ) {
- menu_log($(event.target).find(".ui-state-focus").parent().index());
+ log($(event.target).find(".ui-state-focus").parent().index());
}
});
- menu_log("keydown",true);
+ log("keydown",true);
element.one( "menufocus", function( event, ui ) {
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
function menukeyboard1() {
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
equal( $("#log").html(), "0,1,keydown,", "Keydown UP");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
equal( $("#log").html(), "keydown,", "Keydown LEFT (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
}
function menukeyboard2() {
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
equal( $("#log").html(), "1,keydown,", "Keydown LEFT (close submenu)");
}
function menukeyboard3() {
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "10,keydown,", "Keydown PAGE_DOWN");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "20,keydown,", "Keydown PAGE_DOWN");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "10,keydown,", "Keydown PAGE_UP");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "0,keydown,", "Keydown PAGE_UP");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
equal( $("#log").html(), "27,keydown,", "Keydown END");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
equal( $("#log").html(), "0,keydown,", "Keydown HOME");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
equal( $("#log").html(), "1,keydown,", "Keydown ESCAPE (close submenu)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
setTimeout( menukeyboard4, 50 );
}
function menukeyboard4() {
equal( $("#log").html(), "0,keydown,", "Keydown ENTER (open submenu)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
equal( $("#log").html(), "Aberdeen,keydown,", "Keydown ENTER (select item)");
expect(6);
var element = $('#menu6').menu({
select: function(event, ui) {
- menu_log($(ui.item[0]).text());
+ log($(ui.item[0]).text());
},
focus: function( event, ui ) {
- menu_log($(event.target).find(".ui-state-focus").parent().index());
+ log($(event.target).find(".ui-state-focus").parent().index());
}
});
- menu_log("keydown",true);
+ log("keydown",true);
element.one( "menufocus", function( event, ui ) {
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
function menukeyboard1() {
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( $("#log").html(), "4,3,2,keydown,", "Keydown focus disabled item with submenu");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
equal( $("#log").html(), "keydown,", "Keydown LEFT (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
setTimeout( function() {
equal( $("#log").html(), "keydown,", "Keydown RIGHT (no effect on disabled sub-menu)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
setTimeout( function() {
equal( $("#log").html(), "keydown,", "Keydown ENTER (no effect on disabled sub-menu)");
- menu_log("click",true);
- menu_click( element, "1" );
+ log("click",true);
+ click( element, "1" );
equal( $("#log").html(), "click,", "Click disabled item (no effect)");
start();
}, 50);