View
 

Menubar

Page history last edited by Andrew Hao 3 months, 3 weeks ago Saved with comment


type:
 widget

release: ?

status: in development

documentation: n/a

demo: http://view.jqueryui.com/menubar/demos/index.html#menubar

 


TODOs:

  • Can the popup utility be used for  the menubar implementation? Probably needs methods for the menubar to use for handling left/right key navigation (or up/down, for vertical orientation) 
  • Add option orientation: vertical|horizontal  
  • Add refresh method 
  • Overhaul demo
  • Overhaul button-related options, figure out what options actually make sense 
  • Figure out API for setting top-level menu position and submenu position 
  • Write down the spec 
  • Write tests
  • Write documentation 
  • Add a demo ala Wordpress admin menubar: http://bassistance.de/i/40afad.png 

 


 

1 - Description:

 

A horizontal menu with nested vertical flyout menus for each menu item. Wraps the menu widget (which has a lot more links to existing plugins and other references).

 

A relevant reference is the whatwg html spec on menus.


 

2 - Visual Design:

 

See E2:

 

 

 


 

3 - Functional Specifications/Requirements:

 

Options:

  • option (Type, default: default ) 
    • description 

Methods:

  • method(arguments)
    • description

Events:

  • event
    • descriptions

 

 


 

 

4 - Markup & Style:

 

4.1 Initial markup examples 

     Any unordered list:

          <ul>

              <li><a href="/http://google.com">Google</a></li>

              <li><a href="/http://yahoo.com">Yahoo</a></li>

              <li><a href="/http://msn.com">MSN</a></li>

              <li><a href="/http://ask.com">Ask</a></li>

              <li><a href="/http://aol.com">AOL</a></li>

</ul>

 

     For nested menus, nested unordered lists:

          <ul>

              <li><a href="/http://google.com">Google</a></li>

              <li><a href="/http://yahoo.com">Yahoo</a></li>

              <li><a href="/http://msn.com">MSN</a>

                    <ul>

                         <li><a href="/htp://sub1.example.com">sub-level</a></li>

                        <li><a href="/http://sub2.example.com">sub-level</a></li>

                    </ul>

               </li>

              <li><a href="/http://ask.com">Ask</a></li>

              <li><a href="/http://aol.com">AOL</a></li>

</ul>

 

4.2 Recommended transformed HTML markup

TODO

 

4.3 Accessibility recommendations

 

ARIA markup:

Use the following roles:

  • role="menubar" for menubar <ul>
    • role="menu" for submenu <ul> elements
    • role="menuitem" for (sub)menu items *
      • role="menuitemradio" and role="menuitemcheckox" for checkable menu items
    • Role="presentation" for menuitem containers that are not needed in the exposed accessible menubar structure* 


Use the following states:

  • aria-expanded="true/false" for branch menu items
  • aria-hidden="true/false" for submenus
  • aria-activedescendant="<id of active menuitem>" to track focus
  • aria-labelledby="<id of parent menu item>"

 

* Support for ARIA menubars by screen readers such as JAWS is erratic at best, specifically in internet explorer. It seems support is more consistent when placing the role="menuitem" element adjacent to its submenu, as opposed to nesting the submenu inside the menuitem element (which is what regular nested html lists do). Because of this it's recommended to set role="presentation" on the <li> element and role="menuitem" on the <a> element inside of it.


To associate submenus with their parent menu(bar) items we need an aria-labelledby attribute on the submenu elements that point to the ID of the parent menu item. The downside is that you would have set ID values on those menu items, which would also conflict with the ID value bring added and removed by the menubar's  aria-activedescendant attribute. An easier solution would be to use the aria-label attribute, which just takes the submenu's accessible name as a string. The downside there is that IE does not support this attribute yet. The other option is to add the submenu's name as a title attribute, which works on all browsers and does not requires IDs. But of course the downside there is that you get unwanted tooltips as a side effect.


Keyboard navigation

In general the menubar needs to behave like in a desktop environment. It should be possible to use the left and right arrow keys to open the adjacent sub menu in the bar. It should also be possible to navigate the menubar items sideways without automatically expanding their sub menus (unless the current menubar item was already expanded).

 

Optionally, there could be a shortcut to move focus to the menu from any point in the web application. Selecting an item in the menubar should ten attempt to move focus back to where it was when the menubar shortcut was triggered

 

High contrast support

The sub menu indicators as well as checkable indicators must be visible in high contrast mode.

 

4.4 CSS & Theme

TODO

 

 


 

5 - Latest version of plugin:

 

http://view.jqueryui.com/master/demos/menubar/default.html

 


 

6 - Open issues being discussed

 

  • Adjust keyboard handling based on orientation? How does the screenreader know what the orientation is? Does aria-orientation work here?
  • Should menubar allow top-level regular links, without submenus? Currently those aren't handled correctly 

 

 

Comments (9)

fnagel said

at 2:26 pm on Oct 10, 2011

Is there any option to define a delay for collapsing? Currently the using of multi level menus is pretty tricky. We could improve the usability a lot by adding some delay before collapsing.

Something like the amazing hover plugin: http://cherne.net/brian/resources/jquery.hoverIntent.html

JohnHadj said

at 9:08 am on Oct 11, 2011

In the second example, it seems that the submenu doesn't close when an item from the dropdown is selected. IE9. Is that by design?

Dalia said

at 7:14 pm on Nov 9, 2011

I know this plugin still in development however I can not wait I already used it, but can you please help me how to activate or make the click on the menu bar items (buttons) work, I mean the horizontal items not the sub menus. Also there is a bug, if the menubar item does not have sub menu and you hover, you get error "Uncaught TypeError: Cannot read property 'nodeType' of undefined". Also for the menuIcons I asked above, this should be easy to implement, IMHO when creating the sub menus, looping through the menubar elements and if the element/button has a children then add the icon otherwise no.

Dalia said

at 7:48 am on Nov 10, 2011

Not sure if this is correct or not, I tried this :

$('.ui-menubar-link').unbind("click");

and it solved the menubar items click issue. I still have the issue with the error "Uncaught TypeError: Cannot read property 'nodeType' of undefined" when you hover on
menubar items without submenus. Please help

Dalia said

at 12:48 am on Nov 11, 2011

One more issue, the menus links color are completely not shown or white on most ui themes, the menus of the menubar gets their colors from the ui-widget-header a of the menubar and therefore its colors not the same as the reset of menus, normally the header color is inverted so the header is dark and text is light. I think the sub menus should be wrapped with some container or should not inheret the bar header classes. Any suggestions.

Dalia said

at 1:43 am on Nov 11, 2011

Simple fix I did for the above error, I checked the menu length before opening after line about 98:
if (menu.length == 0){
return;
}
that._open( event, menu );

Eric H said

at 11:29 am on Dec 28, 2011

>Should menubar allow top-level regular links, without submenus?
Yes. They're needed to support icon bars as a variety of this widget.

Jovan Popovic said

at 10:55 am on Jan 27, 2012

Currently menu bar does not allow external links because event.preventDefault(); is called in the function that handles click event.
This can be avoided if in the event handler we check whether the input has href attribute other than "#" and in that case skip further processing - something like this:


input.bind("click.menubar focus.menubar mouseenter.menubar", function (event) {

...
//If user has clicked on the external link do not prevent default behaviour
if (event.type == "click" && $(this).attr("href") != "#")
return;

event.preventDefault();
...

Optionally can be checked whether the input.tagName is "A" or something else.
This works for me (I can put top navigation link with href="#" for internal, and other values for external links) but I'm not sure is there anything else that could be affected b this change.

hmua2012 said

at 5:54 am on Mar 20, 2012

Hello everybody:

I'm just using this menu for my applications, but I find two problems to work fine:
1. How can i delay the collapsing time? I think it is very quickly.
2. I have a long vertical menu, then i cant see whole menu because the navigator window is shorter (height) than the menu. How can i add a scroll vertical bar to let acces all menu?

Thank you very much.

You don't have permission to comment on this page.