Top Link Disclosure Menu Toggle
A link or button that controls the visibility of a TopLinkDisclosureMenu.
Note
This is a subclass of BaseMenuToggle.
Constructor
Constructs a new TopLinkDisclosureMenuToggle
.
new TopLinkDisclosureMenuToggle({
menuToggleElement,
parentElement,
controlledMenu,
parentMenu,
initialize,
});
The constructor will call BaseMenuToggle's constructor with the provided options. It will also initialize the menu toggle if the initialize flag is set to true.
Parameters
Name | Type | Description | Default |
---|---|---|---|
options | object | The options for generating the menu toggle. | undefined |
options.menuToggleElement | HTMLElement | The toggle element in the DOM. | undefined |
options.parentElement | HTMLElement | The element containing the controlled menu. | undefined |
options.controlledMenu | TopLinkDisclosureMenu | The menu controlled by this toggle. | undefined |
options.parentMenu | TopLinkDisclosureMenu , null | The menu containing this toggle. | null |
options.initialize | boolean | A flag to initialize the menu toggle immediately upon creation. | true |
Initialize
The initialize method is inherited from the BaseMenuToggle class. There are no customizations for the TopLinkDisclosureMenuToggle class.
Properties
Properties are inherited from the BaseMenuToggle class. There are no custom properties for the TopLinkDisclosureMenuToggle class.
Getters and Setters
Getters and setters are inherited from the BaseMenuToggle class. There are no custom getters and setters for the TopLinkDisclosureMenuToggle class.
Methods
Methods are inherited from the BaseMenuToggle class. The following methods are unique to or overwritten in the TopLinkDisclosureMenuToggle class.
_setAriaAttributes protected
Sets the ARIA attributes on the toggle and controlled menu.
TopLinkDisclosureMenuToggle._setAriaAttributes();
Calls the BaseMenuToggle's _setAriaAttributes method.
Ensures the toggle element has a role
of "button" if it is not already a button.
Then using the toggle and menu's IDs, the toggle's aria-controls
is set to the menu's ID.
open public
Opens and controlled menu.
TopLinkDisclosureMenuToggle.open();
Calls the closeSiblings (inherited) method and then BaseMenuToggle's open method.
preview public
Opens the controlled menu without the current focus entering it.
TopLinkDisclosureMenuToggle.preview();
Calls the closeSiblings (inherited) method and then BaseMenuToggle's preview method.
close public
Closes the controlled menu.
TopLinkDisclosureMenuToggle.close();
Calls the closeChildren (inherited) method and then BaseMenuToggle's close method.