mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
get highest modal instance
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -15,7 +15,6 @@ $alert-content-margin: 24px !default;
|
||||
}
|
||||
|
||||
.alert-container {
|
||||
z-index: $z-index-alert;
|
||||
display: block;
|
||||
|
||||
width: $alert-width;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user