import {Component, forwardRef, Directive, Host, EventEmitter, ElementRef, NgZone, Input} from 'angular2/core';
import {Ion} from '../ion';
import {IonicApp} from '../app/app';
import {Config} from '../../config/config';
import {Platform} from '../../platform/platform';
import {Keyboard} from '../../util/keyboard';
import * as gestures from './menu-gestures';
import {Gesture} from '../../gestures/gesture';
import {MenuType} from './menu-types';
/**
* @name Menu
* @description
* _For basic Menu usage, see the [Menu section](../../../../components/#menus)
* of the Component docs._
*
* Menu is a side-menu navigation that can be dragged out or toggled to show.
*
* @usage
* In order to use Menu, you must specify a [reference](https://angular.io/docs/ts/latest/guide/user-input.html#local-variables)
* to the content element that Menu should listen on for drag events, using the `content` property:
*
* ```html
*
*
*
* ...
*
*
*
*
*
* ```
*
* By default, Menus are on the left, but this can be overriden with the `side`
* property:
* ```html
*
* ```
*
* Menus can optionally be given an `id` attribute which allows the app to
* to get ahold of menu references. If no `id` is given then the menu
* automatically receives an `id` created from the side it is on, such as
* `leftMenu` or `rightMenu`. When using more than one menu it is always
* recommended to give each menu a unique `id`. Additionally menuToggle and
* menuClose directives should be given menu id values of their respective
* menu.
*
* Menu supports two display styles: overlay, and reveal. Overlay
* is the traditional Android drawer style, and Reveal is the traditional iOS
* style. By default, Menu will adjust to the correct style for the platform,
* but this can be overriden using the `type` property:
* ```html
*
* ```
*
* To programatically interact with the menu, you first get the menu component.
*
* ```ts
* @Page({
* `
* `
* )}
* export class MyClass{
* constructor(app: IonicApp){
* this.app = app;
* this.menu;
* }
*
* // Wait until the page is ready
* ngAfterViewInit(){
* this.menu = this.app.getComponent('leftMenu');
* }
*
* // Open the menu programatically
* openMenu(){
* this.menu.open();
* }
*
* }
* ```
*
* If you want to use any of the APIs down below, make sure to grabe the menu component by it's ID
*
* @demo /docs/v2/demos/menu/
*
* @see {@link /docs/v2/components#menus Menu Component Docs}
* @see {@link /docs/v2/components#navigation Navigation Component Docs}
* @see {@link ../../nav/Nav Nav API Docs}
*
*/
@Component({
selector: 'ion-menu',
defaultInputs: {
'side': 'left',
'menuType': 'reveal'
},
outputs: ['opening'],
host: {
'role': 'navigation',
'[attr.side]': 'side',
'[attr.type]': 'type'
},
template: '
',
directives: [forwardRef(() => MenuBackdrop)]
})
export class Menu extends Ion {
private _preventTime: number = 0;
private _cntEle: HTMLElement;
private _gesture: Gesture;
private _targetGesture: Gesture;
private _type: MenuType;
opening: EventEmitter