fix popup manager

This commit is contained in:
cookfront 2017-03-10 17:22:47 +08:00
parent 24e1caca32
commit c5d5c90c06
2 changed files with 11 additions and 21 deletions

View File

@ -2,19 +2,20 @@ import Vue from 'vue';
import merge from 'src/utils/merge'; import merge from 'src/utils/merge';
import PopupManager from './popup-manager'; import PopupManager from './popup-manager';
let popupContext; let popupContext = {
idSeed: 1,
zIndex: 2000,
hasModal: false,
instances: {},
modalStack: []
};
if (Vue.prototype.$isServer) { if (Vue.prototype.$isServer) {
popupContext = global.popupContext || {};
global.popupContext = popupContext; global.popupContext = popupContext;
} else { } else {
popupContext = window.popupContext || {};
window.popupContext = popupContext; window.popupContext = popupContext;
} }
popupContext = merge(popupContext, {
idSeed: 1
});
const getDOM = function(dom) { const getDOM = function(dom) {
if (dom.nodeType === 3) { if (dom.nodeType === 3) {
dom = dom.nextElementSibling || dom.nextSibling; dom = dom.nextElementSibling || dom.nextSibling;
@ -98,9 +99,9 @@ export default {
const props = merge({}, this, options); const props = merge({}, this, options);
const zIndex = props.zIndex; const zIndex = props.zIndex;
// 如果属性中传入了`zIndex`,则覆盖`PopupManager`中对应的`zIndex` // 如果属性中传入了`zIndex`,则覆盖`popupContext`中对应的`zIndex`
if (zIndex) { if (zIndex) {
PopupManager.zIndex = zIndex; popupContext.zIndex = zIndex;
} }
// 如果显示遮罩层 // 如果显示遮罩层

View File

@ -1,22 +1,13 @@
import Vue from 'vue'; import Vue from 'vue';
import merge from 'src/utils/merge';
import { addClass } from 'src/utils/dom'; import { addClass } from 'src/utils/dom';
let popupContext; let popupContext;
if (Vue.prototype.$isServer) { if (Vue.prototype.$isServer) {
popupContext = global.popupContext || {}; popupContext = global.popupContext || {};
global.popupContext = popupContext;
} else { } else {
popupContext = window.popupContext || {}; popupContext = window.popupContext || {};
window.popupContext = popupContext;
} }
popupContext = merge(popupContext, {
hasModal: false,
instances: {},
modalStack: []
});
const getModal = function() { const getModal = function() {
let modalDom = PopupManager.modalDom; let modalDom = PopupManager.modalDom;
if (modalDom) { if (modalDom) {
@ -40,10 +31,8 @@ const getModal = function() {
}; };
const PopupManager = { const PopupManager = {
zIndex: 2000,
nextZIndex() { nextZIndex() {
return this.zIndex++; return popupContext.zIndex++;
}, },
getInstance(id) { getInstance(id) {