docs(MenuController): update MenuController docs

This commit is contained in:
Adam Bradley
2016-02-04 20:15:40 -06:00
parent ca50527437
commit 9f906ae8ae
2 changed files with 55 additions and 4 deletions

View File

@ -132,26 +132,74 @@ import {MenuType} from './menu-types';
export class MenuController {
private _menus: Array<Menu> = [];
/**
* Progamatically open the Menu.
* @return {Promise} returns a promise when the menu is fully opened
*/
open(menuId?: string) {
let menu = this.get(menuId);
menu && menu.open();
if (menu) {
return menu.open();
}
}
/**
* Progamatically close the Menu.
* @param {string} [menuId] Optionally get the menu by its id, or side.
* @return {Promise} returns a promise when the menu is fully closed
*/
close(menuId?: string) {
let menu = this.get(menuId);
menu && menu.close();
if (menu) {
return menu.close();
}
}
/**
* Toggle the menu. If it's closed, it will open, and if opened, it will
* close.
* @param {string} [menuId] Optionally get the menu by its id, or side.
* @return {Promise} returns a promise when the menu has been toggled
*/
toggle(menuId?: string) {
let menu = this.get(menuId);
if (menu) {
return menu.toggle();
}
}
/**
* Used to enable or disable a menu. For example, there could be multiple
* left menus, but only one of them should be able to be dragged open.
* @param {boolean} shouldEnable True if it should be enabled, false if not.
* @param {string} [menuId] Optionally get the menu by its id, or side.
* @return {Menu} Returns the instance of the menu, which is useful for chaining.
*/
enable(shouldEnable: boolean, menuId?: string) {
let menu = this.get(menuId);
menu && menu.enable(shouldEnable);
if (menu) {
return menu.enable(shouldEnable);
}
}
/**
* Used to enable or disable the ability to swipe open the menu.
* @param {boolean} shouldEnable True if it should be swipe-able, false if not.
* @param {string} [menuId] Optionally get the menu by its id, or side.
* @return {Menu} Returns the instance of the menu, which is useful for chaining.
*/
swipeEnable(shouldEnable: boolean, menuId?: string) {
let menu = this.get(menuId);
menu && menu.swipeEnable(shouldEnable);
if (menu) {
return menu.swipeEnable(shouldEnable);
}
}
/**
* Used to get a menu instance.
* @param {string} [menuId] Optionally get the menu by its id, or side.
* @return {Menu} Returns the instance of the menu if found, otherwise `null`.
*/
get(menuId?: string): Menu {
if (menuId) {
// first try by "id"

View File

@ -10,6 +10,9 @@ import {MenuController} from './menu-controller';
import {MenuType} from './menu-types';
/**
* @private
*/
@Component({
selector: 'ion-menu',
host: {