get highest modal instance

This commit is contained in:
Adam Bradley
2015-06-21 20:50:25 -05:00
parent 903ce56248
commit 04df5805f2
6 changed files with 33 additions and 14 deletions

View File

@@ -86,11 +86,17 @@ export class ActionMenu extends Overlay {
* @return Promise that resolves when the action menu is open.
*/
static open(opts) {
return this.create(ActionMenu, opts);
return this.create(overlayType, ActionMenu, opts);
}
static get() {
return Modal.getByType(overlayType);
}
}
const overlayType = 'actionmenu';
/**
* Animations for action sheet

View File

@@ -15,7 +15,6 @@ $alert-content-margin: 24px !default;
}
.alert-container {
z-index: $z-index-alert;
display: block;
width: $alert-width;

View File

@@ -8,6 +8,5 @@ $z-index-swipe-handle: 5 !default;
$z-index-toolbar-border: 20 !default;
$z-index-list-border: 50 !default;
$z-index-aside-overlay: 80 !default;
$z-index-overlay: 100 !default;
$z-index-alert: 110 !default;
$z-index-overlay: 1000 !default;
$z-index-click-block: 9999 !default;

View File

@@ -23,11 +23,17 @@ export class Modal extends Overlay {
/* Static Methods */
static open(ComponentType: Type, opts) {
return this.create(ComponentType, opts);
return this.create(overlayType, ComponentType, opts);
}
static get() {
return Modal.getByType(overlayType);
}
}
const overlayType = 'modal';
/**
* Animations for modals

View File

@@ -90,9 +90,8 @@ export class ModalFirstPage {
}
closeModal() {
// TODO(maxlynch): Figure out a much better way to get the parent ContactModal
var m = this.nav._nav.elementRef.parentView._view.context;
m.close();
let modal = Modal.get();
modal.close();
}
openActionMenu() {

View File

@@ -7,7 +7,7 @@ import * as util from 'ionic/util';
export class Overlay {
constructor() {
this.zIndex = rootIndex;
this.zIndex = Root_ZIndex;
for (let i = 0; i < overlayStack.length; i++) {
this.zIndex = overlayStack[i].zIndex + 1;
}
@@ -17,7 +17,7 @@ export class Overlay {
/* Instance Methods */
open(opts) {
let animationName = (opts && opts.animation) || this.options.enterAnimation;
let enterAnimation = Animation.create(this.domElement, animationName);
let enterAnimation = Animation.create(this._domElement, animationName);
enterAnimation.before.addClass('show-overlay');
ClickBlock(true, enterAnimation.duration() + 200);
@@ -33,7 +33,7 @@ export class Overlay {
close(opts) {
return new Promise(resolve => {
let animationName = (opts && opts.animation) || this.options.leaveAnimation;
let leavingAnimation = Animation.create(this.domElement, animationName);
let leavingAnimation = Animation.create(this._domElement, animationName);
leavingAnimation.after.removeClass('show-overlay');
ClickBlock(true, leavingAnimation.duration() + 200);
@@ -58,12 +58,13 @@ export class Overlay {
/* Static Methods */
static create(ComponentType: Type, opts) {
static create(overlayType, ComponentType: Type, opts) {
return new Promise((resolve, reject) => {
IonicRoot.append(ComponentType).then(ref => {
let overlay = ref.instance;
overlay._type = overlayType;
overlay._dispose = ref.dispose;
overlay.domElement = ref.elementRef.domElement;
overlay._domElement = ref.elementRef.domElement;
overlay.extendOptions(opts);
overlay.open(opts);
resolve(overlay);
@@ -75,7 +76,16 @@ export class Overlay {
});
}
static getByType(overlayType) {
for (let i = overlayStack.length - 1; i >= 0; i--) {
if (overlayType == overlayStack[i]._type) {
return overlayStack[i];
}
}
return null;
}
}
let overlayStack = [];
const rootIndex = 100;
const Root_ZIndex = 1000;