1- import { DOCUMENT } from '@angular/common ' ;
2- import { Inject , Injectable } from '@angular /core' ;
1+ import { Injectable } from '@angular/core ' ;
2+ import { menuController } from '@ionic /core' ;
33
4- import { proxyMethod } from '../util/util' ;
5-
6- const CTRL = 'ion-menu-controller' ;
74@Injectable ( {
85 providedIn : 'root' ,
96} )
107export class MenuController {
118
12- constructor ( @Inject ( DOCUMENT ) private doc : any ) {
13- }
14-
159 /**
1610 * Programmatically open the Menu.
1711 * @param [menuId] Optionally get the menu by its id, or side.
1812 * @return returns a promise when the menu is fully opened
1913 */
20- open ( menuId ?: string ) : Promise < boolean > {
21- return proxyMethod ( CTRL , this . doc , ' open' , menuId ) ;
14+ open ( menuId ?: string ) {
15+ return menuController . open ( menuId ) ;
2216 }
2317
2418 /**
@@ -28,8 +22,8 @@ export class MenuController {
2822 * @param [menuId] Optionally get the menu by its id, or side.
2923 * @return returns a promise when the menu is fully closed
3024 */
31- close ( menuId ?: string ) : Promise < boolean > {
32- return proxyMethod ( CTRL , this . doc , ' close' , menuId ) ;
25+ close ( menuId ?: string ) {
26+ return menuController . close ( menuId ) ;
3327 }
3428
3529 /**
@@ -38,8 +32,8 @@ export class MenuController {
3832 * @param [menuId] Optionally get the menu by its id, or side.
3933 * @return returns a promise when the menu has been toggled
4034 */
41- toggle ( menuId ?: string ) : Promise < boolean > {
42- return proxyMethod ( CTRL , this . doc , ' toggle' , menuId ) ;
35+ toggle ( menuId ?: string ) {
36+ return menuController . toggle ( menuId ) ;
4337 }
4438
4539 /**
@@ -50,8 +44,8 @@ export class MenuController {
5044 * @param [menuId] Optionally get the menu by its id, or side.
5145 * @return Returns the instance of the menu, which is useful for chaining.
5246 */
53- enable ( shouldEnable : boolean , menuId ?: string ) : Promise < HTMLIonMenuElement > {
54- return proxyMethod ( CTRL , this . doc , ' enable' , shouldEnable , menuId ) ;
47+ enable ( shouldEnable : boolean , menuId ?: string ) {
48+ return menuController . enable ( shouldEnable , menuId ) ;
5549 }
5650
5751 /**
@@ -61,7 +55,7 @@ export class MenuController {
6155 * @return Returns the instance of the menu, which is useful for chaining.
6256 * @deprecated Use swipeGesture() instead
6357 */
64- swipeEnable ( shouldEnable : boolean , menuId ?: string ) : Promise < HTMLIonMenuElement > {
58+ swipeEnable ( shouldEnable : boolean , menuId ?: string ) {
6559 console . warn ( 'MenuController.swipeEnable is deprecated. Use MenuController.swipeGesture() instead' ) ;
6660 return this . swipeGesture ( shouldEnable , menuId ) ;
6761 }
@@ -72,25 +66,25 @@ export class MenuController {
7266 * @param [menuId] Optionally get the menu by its id, or side.
7367 * @return Returns the instance of the menu, which is useful for chaining.
7468 */
75- swipeGesture ( shouldEnable : boolean , menuId ?: string ) : Promise < HTMLIonMenuElement > {
76- return proxyMethod ( CTRL , this . doc , ' swipeGesture' , shouldEnable , menuId ) ;
69+ swipeGesture ( shouldEnable : boolean , menuId ?: string ) {
70+ return menuController . swipeGesture ( shouldEnable , menuId ) ;
7771 }
7872
7973 /**
8074 * @param [menuId] Optionally get the menu by its id, or side.
8175 * @return Returns true if the specified menu is currently open, otherwise false.
8276 * If the menuId is not specified, it returns true if ANY menu is currenly open.
8377 */
84- isOpen ( menuId ?: string ) : Promise < boolean > {
85- return proxyMethod ( CTRL , this . doc , ' isOpen' , menuId ) ;
78+ isOpen ( menuId ?: string ) {
79+ return menuController . isOpen ( menuId ) ;
8680 }
8781
8882 /**
8983 * @param [menuId] Optionally get the menu by its id, or side.
9084 * @return Returns true if the menu is currently enabled, otherwise false.
9185 */
92- isEnabled ( menuId ?: string ) : Promise < boolean > {
93- return proxyMethod ( CTRL , this . doc , ' isEnabled' , menuId ) ;
86+ isEnabled ( menuId ?: string ) {
87+ return menuController . isEnabled ( menuId ) ;
9488 }
9589
9690 /**
@@ -102,21 +96,21 @@ export class MenuController {
10296 * @param [menuId] Optionally get the menu by its id, or side.
10397 * @return Returns the instance of the menu if found, otherwise `null`.
10498 */
105- get ( menuId ?: string ) : Promise < HTMLIonMenuElement > {
106- return proxyMethod ( CTRL , this . doc , ' get' , menuId ) ;
99+ get ( menuId ?: string ) {
100+ return menuController . get ( menuId ) ;
107101 }
108102
109103 /**
110104 * @return Returns the instance of the menu already opened, otherwise `null`.
111105 */
112- getOpen ( ) : Promise < HTMLIonMenuElement > {
113- return proxyMethod ( CTRL , this . doc , ' getOpen' ) ;
106+ getOpen ( ) {
107+ return menuController . getOpen ( ) ;
114108 }
115109
116110 /**
117111 * @return Returns an array of all menu instances.
118112 */
119- getMenus ( ) : Promise < HTMLIonMenuElement [ ] > {
120- return proxyMethod ( CTRL , this . doc , ' getMenus' ) ;
113+ getMenus ( ) {
114+ return menuController . getMenus ( ) ;
121115 }
122116}
0 commit comments