mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
55 lines
1.0 KiB
TypeScript
55 lines
1.0 KiB
TypeScript
import {Directive, ElementRef, Optional} from 'angular2/angular2';
|
|
|
|
import {Ion} from '../ion';
|
|
import {IonicApp} from '../app/app';
|
|
import {ViewController} from '../nav/view-controller';
|
|
import {Navbar} from '../nav-bar/nav-bar';
|
|
|
|
|
|
/**
|
|
* TODO
|
|
*/
|
|
@Directive({
|
|
selector: '[menu-toggle]',
|
|
properties: [
|
|
'menuToggle'
|
|
],
|
|
host: {
|
|
'(click)': 'toggle($event)',
|
|
'[hidden]': 'isHidden'
|
|
}
|
|
})
|
|
export class MenuToggle extends Ion {
|
|
|
|
constructor(
|
|
app: IonicApp,
|
|
elementRef: ElementRef,
|
|
@Optional() viewCtrl: ViewController,
|
|
@Optional() navbar: Navbar
|
|
) {
|
|
super(elementRef, null);
|
|
this.app = app;
|
|
this.viewCtrl = viewCtrl;
|
|
this.withinNavbar = !!navbar;
|
|
}
|
|
|
|
/**
|
|
* TODO
|
|
* @param {TODO} event TODO
|
|
*/
|
|
toggle(ev) {
|
|
let menu = this.app.getComponent(this.menuToggle || 'menu');
|
|
menu && menu.toggle();
|
|
ev.preventDefault();
|
|
ev.stopPropagation();
|
|
}
|
|
|
|
get isHidden() {
|
|
if (this.withinNavbar && this.viewCtrl) {
|
|
return !this.viewCtrl.isRoot();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
}
|