From 877b929a686019ccfa82e48ae7e11e6b457a4ced Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Tue, 10 Nov 2015 21:25:14 -0600 Subject: [PATCH] fix(menu): rename menu type config Closes #479 --- ionic/components/menu/menu.ts | 32 +++++++++++++++++--------------- ionic/config/modes.ts | 4 +++- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/ionic/components/menu/menu.ts b/ionic/components/menu/menu.ts index 60ff6da28a..dd2388553e 100644 --- a/ionic/components/menu/menu.ts +++ b/ionic/components/menu/menu.ts @@ -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 {IonicApp} from '../app/app'; import {Config} from '../../config/config'; -import {ConfigComponent} from '../../config/decorators'; import {Platform} from '../../platform/platform'; import {Keyboard} from '../../util/keyboard'; import * as gestures from './menu-gestures'; @@ -44,20 +43,24 @@ import * as gestures from './menu-gestures'; * * ``` */ -@ConfigComponent({ +@Component({ selector: 'ion-menu', inputs: [ 'content', 'dragThreshold', - 'id' + 'id', + 'side', + 'type' ], defaultInputs: { 'side': 'left', - 'type': 'reveal' + 'menuType': 'reveal' }, outputs: ['opening'], host: { - 'role': 'navigation' + 'role': 'navigation', + '[attr.side]': 'side', + '[attr.type]': 'type' }, template: '', 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\n\n'); } + if (this.side !== 'left' && this.side !== 'right') { + this.side = 'left'; + } + if (!this.id) { // Auto register this.id = 'menu'; @@ -130,16 +137,12 @@ export class Menu extends Ion { } _initType(type) { - type = type && type.trim().toLowerCase() || FALLBACK_MENU_TYPE; - - let menuTypeCls = menuTypes[type]; - - if (!menuTypeCls) { - type = FALLBACK_MENU_TYPE; - menuTypeCls = menuTypes[type]; + type = type && type.trim().toLowerCase(); + if (!type) { + type = this.config.get('menuType'); } - this._type = new menuTypeCls(this); + this._type = new menuTypes[type](this); this.type = type; if (this.config.get('animate') === false) { @@ -307,7 +310,6 @@ export class Menu extends Ion { } let menuTypes = {}; -const FALLBACK_MENU_TYPE = 'reveal'; /** diff --git a/ionic/config/modes.ts b/ionic/config/modes.ts index c0ba802ce0..68b198c90d 100644 --- a/ionic/config/modes.ts +++ b/ionic/config/modes.ts @@ -16,6 +16,8 @@ Config.setModeConfig('ios', { iconMode: 'ios', + menuType: 'reveal', + modalEnter: 'modal-slide-in', modalLeave: 'modal-slide-out', @@ -43,7 +45,7 @@ Config.setModeConfig('md', { iconMode: 'md', - type: 'overlay', + menuType: 'overlay', modalEnter: 'modal-md-slide-in', modalLeave: 'modal-md-slide-out',