Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/utils/popup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ export default {
PopupManager.zIndex = zIndex;
}

PopupManager.openPopup(this._popupId);

if (modal) {
if (this._closing) {
PopupManager.closeModal(this._popupId);
Expand Down Expand Up @@ -199,6 +201,7 @@ export default {
},

doAfterClose() {
PopupManager.closePopup();
PopupManager.closeModal(this._popupId);
this._closing = false;
},
Expand Down
36 changes: 26 additions & 10 deletions src/utils/popup/popup-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ const PopupManager = {
},

modalStack: [],
popupStack: [],

doOnModalClick: function() {
const topItem = PopupManager.modalStack[PopupManager.modalStack.length - 1];
if (!topItem) return;
doOnModalClick: function () {
const instance = getTopPopup();
if (!instance) return;

const instance = PopupManager.getInstance(topItem.id);
if (instance && instance.closeOnClickModal) {
if (instance && instance.modal && instance.closeOnClickModal) {
instance.close();
}
},
Expand Down Expand Up @@ -109,6 +109,21 @@ const PopupManager = {
this.modalStack.push({ id: id, zIndex: zIndex, modalClass: modalClass });
},

openPopup: function (id) {
if (Vue.prototype.$isServer) return;
if (!id) return;
const popupStack = this.popupStack;
if (popupStack.includes(id)) return;
popupStack.push(id);
},

closePopup: function () {
const popupStack = this.popupStack;
if (popupStack.length > 0) {
popupStack.pop();
}
},

closeModal: function(id) {
const modalStack = this.modalStack;
const modalDom = getModal();
Expand Down Expand Up @@ -165,12 +180,13 @@ Object.defineProperty(PopupManager, 'zIndex', {
}
});

const getTopPopup = function() {
const getTopPopup = function () {
if (Vue.prototype.$isServer) return;
if (PopupManager.modalStack.length > 0) {
const topPopup = PopupManager.modalStack[PopupManager.modalStack.length - 1];
if (!topPopup) return;
const instance = PopupManager.getInstance(topPopup.id);
if (PopupManager.popupStack.length > 0) {
const topPopupId =
PopupManager.popupStack[PopupManager.popupStack.length - 1];
if (!topPopupId) return;
const instance = PopupManager.getInstance(topPopupId);

return instance;
}
Expand Down