mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
@ -1,9 +1,8 @@
|
|||||||
import {forwardRef, Directive, Host, EventEmitter, ElementRef} from 'angular2/angular2';
|
import {Component, forwardRef, Directive, Host, EventEmitter, ElementRef} from 'angular2/angular2';
|
||||||
|
|
||||||
import {Ion} from '../ion';
|
import {Ion} from '../ion';
|
||||||
import {IonicApp} from '../app/app';
|
import {IonicApp} from '../app/app';
|
||||||
import {Config} from '../../config/config';
|
import {Config} from '../../config/config';
|
||||||
import {ConfigComponent} from '../../config/decorators';
|
|
||||||
import {Platform} from '../../platform/platform';
|
import {Platform} from '../../platform/platform';
|
||||||
import {Keyboard} from '../../util/keyboard';
|
import {Keyboard} from '../../util/keyboard';
|
||||||
import * as gestures from './menu-gestures';
|
import * as gestures from './menu-gestures';
|
||||||
@ -44,20 +43,24 @@ import * as gestures from './menu-gestures';
|
|||||||
* <ion-menu [content]="contentRef" type="overlay"></ion-menu>
|
* <ion-menu [content]="contentRef" type="overlay"></ion-menu>
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
@ConfigComponent({
|
@Component({
|
||||||
selector: 'ion-menu',
|
selector: 'ion-menu',
|
||||||
inputs: [
|
inputs: [
|
||||||
'content',
|
'content',
|
||||||
'dragThreshold',
|
'dragThreshold',
|
||||||
'id'
|
'id',
|
||||||
|
'side',
|
||||||
|
'type'
|
||||||
],
|
],
|
||||||
defaultInputs: {
|
defaultInputs: {
|
||||||
'side': 'left',
|
'side': 'left',
|
||||||
'type': 'reveal'
|
'menuType': 'reveal'
|
||||||
},
|
},
|
||||||
outputs: ['opening'],
|
outputs: ['opening'],
|
||||||
host: {
|
host: {
|
||||||
'role': 'navigation'
|
'role': 'navigation',
|
||||||
|
'[attr.side]': 'side',
|
||||||
|
'[attr.type]': 'type'
|
||||||
},
|
},
|
||||||
template: '<ng-content></ng-content><backdrop tappable disable-activated></backdrop>',
|
template: '<ng-content></ng-content><backdrop tappable disable-activated></backdrop>',
|
||||||
directives: [forwardRef(() => MenuBackdrop)]
|
directives: [forwardRef(() => MenuBackdrop)]
|
||||||
@ -94,6 +97,10 @@ export class Menu extends Ion {
|
|||||||
return console.error('Menu: must have a [content] element to listen for drag events on. Example:\n\n<ion-menu [content]="content"></ion-menu>\n\n<ion-nav #content></ion-nav>');
|
return console.error('Menu: must have a [content] element to listen for drag events on. Example:\n\n<ion-menu [content]="content"></ion-menu>\n\n<ion-nav #content></ion-nav>');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.side !== 'left' && this.side !== 'right') {
|
||||||
|
this.side = 'left';
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.id) {
|
if (!this.id) {
|
||||||
// Auto register
|
// Auto register
|
||||||
this.id = 'menu';
|
this.id = 'menu';
|
||||||
@ -130,16 +137,12 @@ export class Menu extends Ion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_initType(type) {
|
_initType(type) {
|
||||||
type = type && type.trim().toLowerCase() || FALLBACK_MENU_TYPE;
|
type = type && type.trim().toLowerCase();
|
||||||
|
if (!type) {
|
||||||
let menuTypeCls = menuTypes[type];
|
type = this.config.get('menuType');
|
||||||
|
|
||||||
if (!menuTypeCls) {
|
|
||||||
type = FALLBACK_MENU_TYPE;
|
|
||||||
menuTypeCls = menuTypes[type];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this._type = new menuTypeCls(this);
|
this._type = new menuTypes[type](this);
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
|
||||||
if (this.config.get('animate') === false) {
|
if (this.config.get('animate') === false) {
|
||||||
@ -307,7 +310,6 @@ export class Menu extends Ion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let menuTypes = {};
|
let menuTypes = {};
|
||||||
const FALLBACK_MENU_TYPE = 'reveal';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,6 +16,8 @@ Config.setModeConfig('ios', {
|
|||||||
|
|
||||||
iconMode: 'ios',
|
iconMode: 'ios',
|
||||||
|
|
||||||
|
menuType: 'reveal',
|
||||||
|
|
||||||
modalEnter: 'modal-slide-in',
|
modalEnter: 'modal-slide-in',
|
||||||
modalLeave: 'modal-slide-out',
|
modalLeave: 'modal-slide-out',
|
||||||
|
|
||||||
@ -43,7 +45,7 @@ Config.setModeConfig('md', {
|
|||||||
|
|
||||||
iconMode: 'md',
|
iconMode: 'md',
|
||||||
|
|
||||||
type: 'overlay',
|
menuType: 'overlay',
|
||||||
|
|
||||||
modalEnter: 'modal-md-slide-in',
|
modalEnter: 'modal-md-slide-in',
|
||||||
modalLeave: 'modal-md-slide-out',
|
modalLeave: 'modal-md-slide-out',
|
||||||
|
Reference in New Issue
Block a user