feat(MenuController): create isOpen() and isEnabled()

Closes #5390
This commit is contained in:
Adam Bradley
2016-02-13 00:54:01 -06:00
parent 6a7c97d77e
commit 3bb09cee07

View File

@@ -197,7 +197,26 @@ export class MenuController {
}
/**
* Used to get a menu instance.
* @return {boolean} Returns true if the menu is currently open, otherwise false.
*/
isOpen(menuId?: string): boolean {
let menu = this.get(menuId);
return menu && menu.isOpen || false;
}
/**
* @return {boolean} Returns true if the menu is currently enabled, otherwise false.
*/
isEnabled(menuId?: string): boolean {
let menu = this.get(menuId);
return menu && menu.isEnabled || false;
}
/**
* Used to get a menu instance. If a `menuId` is not provided then it'll return
* the first menu found. If a `menuId` is provided, then it'll first try to find
* the menu using the menu's `id` attribute. If a menu is not found using the `id`
* attribute, then it'll try to find the menu by its `side` name.
* @param {string} [menuId] Optionally get the menu by its id, or side.
* @return {Menu} Returns the instance of the menu if found, otherwise `null`.
*/