update overlays

This commit is contained in:
Adam Bradley
2015-06-18 15:43:21 -05:00
parent e32f2f72e3
commit 079fb3c6c9
5 changed files with 43 additions and 32 deletions

View File

@@ -14,12 +14,12 @@ import {IonicRoot} from '../app/app';
import * as util from 'ionic/util';
import {Overlay} from '../overlay/overlay';
import {IonicComponentNew} from '../../config/component';
import {IonicComponentNEW} from '../../config/component';
import {Animation} from 'ionic/animations/animation';
import {ClickBlock} from '../../util/click-block';
@IonicComponentNew(ActionMenu)
@IonicComponentNEW(ActionMenu)
@View({
template: `
<div class="action-menu-backdrop" (click)="cancel()"></div>
@@ -41,16 +41,13 @@ export class ActionMenu extends Overlay {
constructor() {
super();
this.setOptions({
this.extendOptions({
destructiveButtonClicked: util.noop,
buttonClicked: util.noop,
cancel: util.noop,
enterAnimation: 'action-menu-slide-in',
leaveAnimation: 'action-menu-slide-out'
});
this.options = {
destructiveButtonClicked: util.noop,
buttonClicked: util.noop,
cancel: util.noop
};
}
cancel() {

View File

@@ -78,7 +78,7 @@ class IonicAppRoot {
let loader = rootComponent.loader;
let elementRef = rootComponent.anchorElementRef();
return new Promise(resolve => {
return new Promise((resolve, reject) => {
rootComponent.compiler.compileInHost(ComponentType).then(componentProtoViewRef => {
let containerRef = rootComponent.anchorViewContainerRef();
@@ -92,6 +92,9 @@ class IonicAppRoot {
};
resolve(hostViewRef);
}).catch(err => {
console.error('IonicAppRoot append:', err);
reject(err);
});
});
}

View File

@@ -6,7 +6,7 @@ export class Modal extends Overlay {
constructor() {
super();
this.setOptions({
this.extendOptions({
enterAnimation: 'modal-slide-in',
leaveAnimation: 'modal-slide-out'
});

View File

@@ -8,7 +8,7 @@ export class Overlay {
/* Instance Methods */
open(animation) {
animation = animation || this._opts.enterAnimation;
animation = animation || this.options.enterAnimation;
let enterAnimation = Animation.create(this.domElement, animation);
ClickBlock(true, enterAnimation.duration() + 200);
@@ -23,7 +23,7 @@ export class Overlay {
close(animation) {
return new Promise(resolve => {
animation = animation || this._opts.leaveAnimation;
animation = animation || this.options.leaveAnimation;
let leavingAnimation = Animation.create(this.domElement, animation);
leavingAnimation.play().then(() => {
@@ -34,9 +34,9 @@ export class Overlay {
});
}
setOptions(opts) {
if (!this._opts) this._opts = {};
util.extend(this._opts, opts);
extendOptions(opts) {
if (!this.options) this.options = {};
util.extend(this.options, opts);
}
_clean() {
@@ -46,14 +46,18 @@ export class Overlay {
/* Static Methods */
static create(ComponentType: Type, opts) {
return new Promise(resolve => {
return new Promise((resolve, reject) => {
IonicRoot.append(ComponentType).then((ref) => {
let overlay = ref.instance;
overlay._dispose = ref.dispose;
overlay.domElement = ref.elementRef.domElement;
overlay.setOptions(opts);
overlay.extendOptions(opts);
overlay.open();
resolve(overlay);
}).catch(err => {
console.error('Overlay create:', err);
reject(err);
});
});
}

View File

@@ -11,23 +11,11 @@ import {ViewController} from '../view/view-controller';
import {ViewItem} from '../view/view-item';
import {TabButton} from './tab-button';
import {Icon} from '../icon/icon';
import {IonicComponent} from '../../config/component';
import {ModeComponent} from '../../config/component';
import {IonicComponentNEW} from '../../config/component';
import {Config} from '../../config/component';
@ModeComponent({
selector: 'ion-tabs',
properties: [
'tabBarPlacement',
'tabBarIcons'
],
hostProperties: {
'tabBarPlacement': 'attr.tab-bar-placement',
'tabBarIcons': 'attr.tab-bar-icons'
},
classId: 'tabs'
})
@IonicComponentNEW(Tabs)
@View({
template: `
<nav class="navbar-container tab-bar-container">
@@ -136,4 +124,23 @@ export class Tabs extends ViewController {
return this.instances();
}
static get config() {
return {
selector: 'ion-tabs',
properties: [
'tabBarPlacement',
'tabBarIcons'
],
hostProperties: {
'tabBarPlacement': 'attr.tab-bar-placement',
'tabBarIcons': 'attr.tab-bar-icons'
},
classId: 'tabs',
propertyDefaults: {
'tabBarPlacement': 'top',
'tabBarIcons': 'bottom'
}
}
}
}