From 17f8079bc2ce4393d49e7dba238feaff1fddb134 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Wed, 21 Apr 2010 21:01:08 +0200 Subject: Menu: Extracted menu code from autocomplete, updated all dependencies --- demos/autocomplete/categories.html | 1 + demos/autocomplete/combobox.html | 1 + demos/autocomplete/custom-data.html | 1 + demos/autocomplete/default.html | 1 + demos/autocomplete/folding.html | 1 + demos/autocomplete/multiple-remote.html | 1 + demos/autocomplete/multiple.html | 1 + demos/autocomplete/remote-jsonp.html | 1 + demos/autocomplete/remote-with-cache.html | 1 + demos/autocomplete/remote.html | 1 + demos/autocomplete/xml.html | 1 + tests/unit/index.html | 1 + tests/visual/all.html | 1 + tests/visual/autocomplete/autocomplete.html | 1 + tests/visual/compound/widgets_in_dialog.html | 2 +- tests/visual/menu/contextmenu.html | 2 +- tests/visual/menu/drilldown.html | 2 +- tests/visual/menu/menu.html | 2 +- tests/visual/menu/nested.html | 2 +- tests/visual/position/position.html | 2 +- ui/jquery.ui.autocomplete.js | 1 + ui/jquery.ui.menu.js | 177 +++++++++++++++++++++++++++ 22 files changed, 198 insertions(+), 6 deletions(-) create mode 100644 ui/jquery.ui.menu.js diff --git a/demos/autocomplete/categories.html b/demos/autocomplete/categories.html index bb59bf31e..2a2ac2f48 100644 --- a/demos/autocomplete/categories.html +++ b/demos/autocomplete/categories.html @@ -8,6 +8,7 @@ + + + + + + +
+ Log: +
+
+ + + -- cgit v1.2.3 From c821aa680c617412cc9e9c74a4030722f6302379 Mon Sep 17 00:00:00 2001 From: dominiquevincent Date: Thu, 6 May 2010 17:10:52 +0200 Subject: Menu:the first set of unit test files. Signed-off-by: dominiquevincent --- tests/unit/menu/menu.html | 74 ++++++++++++++++++++++++++++++++++++++++ tests/unit/menu/menu_core.js | 32 +++++++++++++++++ tests/unit/menu/menu_defaults.js | 11 ++++++ tests/unit/menu/menu_events.js | 24 +++++++++++++ tests/unit/menu/menu_methods.js | 19 +++++++++++ tests/unit/menu/menu_options.js | 10 ++++++ tests/unit/menu/menu_tickets.js | 8 +++++ 7 files changed, 178 insertions(+) create mode 100644 tests/unit/menu/menu.html create mode 100644 tests/unit/menu/menu_core.js create mode 100644 tests/unit/menu/menu_defaults.js create mode 100644 tests/unit/menu/menu_events.js create mode 100644 tests/unit/menu/menu_methods.js create mode 100644 tests/unit/menu/menu_options.js create mode 100644 tests/unit/menu/menu_tickets.js diff --git a/tests/unit/menu/menu.html b/tests/unit/menu/menu.html new file mode 100644 index 000000000..14a5d06db --- /dev/null +++ b/tests/unit/menu/menu.html @@ -0,0 +1,74 @@ + + + + + jQuery UI Menu Test Suite + + + + + + + + + + + + + + + + + + + + + + + + + + +

jQuery UI Menu Test Suite

+

+

+
    +
+ + +
+ + +
+ +
+ + + diff --git a/tests/unit/menu/menu_core.js b/tests/unit/menu/menu_core.js new file mode 100644 index 000000000..a1cf11b7f --- /dev/null +++ b/tests/unit/menu/menu_core.js @@ -0,0 +1,32 @@ +/* + * menu_core.js + */ + + +(function($) { + +module("menu: core"); + +test("accessibility", function () { + expect(3); + var ac = $('#menu1').menu(); + var item0 = $("li:eq(0) a"); + + ok( ac.hasClass("ui-menu ui-widget ui-widget-content ui-corner-all"), "menu class"); + equals( ac.attr("role"), "listbox", "main role"); + equals( ac.attr("aria-activedescendant"), "ui-active-menuitem", "aria attribute"); +}); + +test("items class and role", function () { + var ac = $('#menu1').menu(); + expect(1 + 4 * $("li",ac).length); + ok( ($("li",ac).length > 0 ), "number of menu items"); + $("li",ac).each(function(item) { + ok( $(this).hasClass("ui-menu-item"), "menu item ("+ item + ") class for item"); + equals( $(this).attr("role"), "menuitem", "menu item ("+ item + ") role"); + ok( $("a",this).hasClass("ui-corner-all"), "a element class for menu item ("+ item + ") "); + equals( $("a",this).attr("tabindex"), "-1", "a element tabindex for menu item ("+ item + ") "); + }); +}); + +})(jQuery); diff --git a/tests/unit/menu/menu_defaults.js b/tests/unit/menu/menu_defaults.js new file mode 100644 index 000000000..c3f741d2a --- /dev/null +++ b/tests/unit/menu/menu_defaults.js @@ -0,0 +1,11 @@ +/* + * menu_defaults.js + */ + +var menu_defaults = { + disabled: false, + navigationFilter: function() {} + +}; + +commonWidgetTests('menu', { defaults: menu_defaults }); diff --git a/tests/unit/menu/menu_events.js b/tests/unit/menu/menu_events.js new file mode 100644 index 000000000..a03bec3f6 --- /dev/null +++ b/tests/unit/menu/menu_events.js @@ -0,0 +1,24 @@ +/* + * menu_events.js + */ +(function($) { + +module("menu: events"); + +test("handle click on menu", function() { + expect(1); + var ac = $('#menu1').menu({ + select: function(event, ui) { + log(); + } + }); + log("click",true); + clickMenu($('#menu1'),"1"); + log("afterclick"); + clickMenu( ac,"2"); + clickMenu($('#menu1'),"3"); + clickMenu( ac,"1"); + equals( $("#log").html(), "1,3,2,afterclick,1,click,", "Click order not valid."); +}); + +})(jQuery); diff --git a/tests/unit/menu/menu_methods.js b/tests/unit/menu/menu_methods.js new file mode 100644 index 000000000..b6ebaf215 --- /dev/null +++ b/tests/unit/menu/menu_methods.js @@ -0,0 +1,19 @@ +/* + * menu_methods.js + */ +(function($) { + +module("menu: methods"); + +test("destroy", function() { + var beforeHtml = $("#menu1").find("div").css("font-style", "normal").end().parent().html(); + var afterHtml = $("#menu1").menu().menu("destroy").parent().html(); + // Opera 9 outputs role="" instead of removing the attribute like everyone else + if ($.browser.opera) { + afterHtml = afterHtml.replace(/ role=""/g, ""); + } + equal( afterHtml, beforeHtml ); +}); + + +})(jQuery); diff --git a/tests/unit/menu/menu_options.js b/tests/unit/menu/menu_options.js new file mode 100644 index 000000000..03822fd74 --- /dev/null +++ b/tests/unit/menu/menu_options.js @@ -0,0 +1,10 @@ +/* + * menu_options.js + */ +(function($) { + +module("menu: options"); + + + +})(jQuery); diff --git a/tests/unit/menu/menu_tickets.js b/tests/unit/menu/menu_tickets.js new file mode 100644 index 000000000..760afd368 --- /dev/null +++ b/tests/unit/menu/menu_tickets.js @@ -0,0 +1,8 @@ +/* + * menu_tickets.js + */ +(function($) { + +module("menu: tickets"); + +})(jQuery); -- cgit v1.2.3 From f1edd5b62e61e675af8130c78d256e23fee2d588 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Fri, 18 Jun 2010 10:23:41 +0200 Subject: Menu: default and contextmenu demos --- demos/menu/contextmenu.html | 76 +++++++++++++++++++++++++++++++++++++++++++++ demos/menu/default.html | 60 +++++++++++++++++++++++++++++++++++ demos/menu/index.html | 17 ++++++++++ 3 files changed, 153 insertions(+) create mode 100644 demos/menu/contextmenu.html create mode 100644 demos/menu/default.html create mode 100644 demos/menu/index.html diff --git a/demos/menu/contextmenu.html b/demos/menu/contextmenu.html new file mode 100644 index 000000000..1c4a6ddd4 --- /dev/null +++ b/demos/menu/contextmenu.html @@ -0,0 +1,76 @@ + + + + + jQuery UI Menu - Contextmenu demo + + + + + + + + + + + + +
+ + + + +
+ +
+ +
+ +

A simple contextmenu: Click the button, or tab to it and hit space to open the menu. Use the mouse or cursor keys to select an item, click it or hit enter to select it.

+ +

The keyboard handling is part of the menu. Using the input option to menu is configured to add the key event handlers to the button, as that button gets focused when clicked.

+ +
+ + + + + diff --git a/demos/menu/default.html b/demos/menu/default.html new file mode 100644 index 000000000..6a2cb5280 --- /dev/null +++ b/demos/menu/default.html @@ -0,0 +1,60 @@ + + + + + jQuery UI Menu - Default demo + + + + + + + + + + + + + +
+ +

A menu with the default configuration. A list is transformed, adding themeing, mouse and keyboard navigation support. Try to tab to the menu and use the cursor keys to navigate.

+ +
+ + + + + diff --git a/demos/menu/index.html b/demos/menu/index.html new file mode 100644 index 000000000..cfc12bc1d --- /dev/null +++ b/demos/menu/index.html @@ -0,0 +1,17 @@ + + + + + jQuery UI Menu Demos + + + +
+

Examples

+ +
+ + -- cgit v1.2.3 From b376fa8dda91aefb50c7a5a7d9ab8dace9eccd0d Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Fri, 18 Jun 2010 10:57:20 +0200 Subject: Menu: Implemented destroy method and disabled option, modified test to pass html-compare-destroy test and extended default visual test for testing destroy and disabled features --- tests/unit/menu/menu.html | 12 ++++++------ tests/visual/menu/menu.html | 26 +++++++++++++++++++++----- ui/jquery.ui.menu.js | 33 +++++++++++++++++++++++++++++---- 3 files changed, 56 insertions(+), 15 deletions(-) diff --git a/tests/unit/menu/menu.html b/tests/unit/menu/menu.html index 14a5d06db..b47728641 100644 --- a/tests/unit/menu/menu.html +++ b/tests/unit/menu/menu.html @@ -59,12 +59,12 @@
-