From 3bb09cee07d6e0cfe17d5a9ed3fcc5dd24800bf1 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Sat, 13 Feb 2016 00:54:01 -0600 Subject: [PATCH] feat(MenuController): create isOpen() and isEnabled() Closes #5390 --- ionic/components/menu/menu-controller.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/ionic/components/menu/menu-controller.ts b/ionic/components/menu/menu-controller.ts index 0172fc71fb..3e79392776 100644 --- a/ionic/components/menu/menu-controller.ts +++ b/ionic/components/menu/menu-controller.ts @@ -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`. */