-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Menu Button Examples: Add activedescendant example and fix multiple b…
…ugs (pull #375) Made the following changes to the menu button examples: 1. Added an example that uses aria-activedescendant to manage focus in the menu; there are now three example pages instead of two. 2. For issue #363, changed how aria-expanded is implemented. 3. fixed a formatting bug. 4. Fixed link execution bugs; enter, ctrl+enter, and shift+enter all work as expected in the navigation menu example. 5. Fixed alt, ctrl, and meta key modifier bugs; Key events that include these key events are no longer captured and ignored by the JavaScript. 6. Put all three example HTML files in the same directory. 7. Made numerous editorial corrections and revisions to improve accuracy and clarity.
- Loading branch information
Showing
13 changed files
with
1,106 additions
and
382 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* This content is licensed according to the W3C Software License at | ||
* https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document | ||
* | ||
* File: MenuItem.js | ||
* | ||
* Desc: Popup Menu Menuitem widget that implements ARIA Authoring Practices | ||
* | ||
* Author: Jon Gunderson, Ku Ja Eun, Nicholas Hoyt and Brian Loh | ||
*/ | ||
|
||
/* | ||
* @constructor MenuItem | ||
* | ||
* @desc | ||
* Wrapper object for a simple menu item in a popup menu | ||
* | ||
* @param domNode | ||
* The DOM element node that serves as the menu item container. | ||
* The menuObj PopupMenu is responsible for checking that it has | ||
* requisite metadata, e.g. role="menuitem". | ||
* | ||
* @param menuObj | ||
* The object that is a wrapper for the PopupMenu DOM element that | ||
* contains the menu item DOM element. See PopupMenuAction.js | ||
*/ | ||
var MenuItem = function (domNode, menuObj) { | ||
this.domNode = domNode; | ||
this.menu = menuObj; | ||
}; | ||
|
||
MenuItem.prototype.init = function () { | ||
this.domNode.tabIndex = -1; | ||
|
||
if (!this.domNode.getAttribute('role')) { | ||
this.domNode.setAttribute('role', 'menuitem'); | ||
} | ||
|
||
this.domNode.addEventListener('click', this.handleClick.bind(this)); | ||
this.domNode.addEventListener('mouseover', this.handleMouseover.bind(this)); | ||
this.domNode.addEventListener('mouseout', this.handleMouseout.bind(this)); | ||
}; | ||
|
||
/* EVENT HANDLERS */ | ||
|
||
MenuItem.prototype.handleClick = function (event) { | ||
this.menu.setFocusToController(); | ||
this.menu.close(true); | ||
}; | ||
|
||
MenuItem.prototype.handleMouseover = function (event) { | ||
this.menu.hasHover = true; | ||
this.menu.open(); | ||
}; | ||
|
||
MenuItem.prototype.handleMouseout = function (event) { | ||
this.menu.hasHover = false; | ||
setTimeout(this.menu.close.bind(this.menu, false), 300); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.