|
@@ -1,3 +1,4 @@
|
|
|
+window.stagPopupsQueue = [];
|
|
|
function showStagPopup(_key, _noAutoFocus) {
|
|
|
/*$('html, body').addClass('no-scroll');
|
|
|
$(window.top.document.body).find('#stag_mcp_lhs').addClass('no-scroll');*/
|
|
@@ -10,6 +11,7 @@ function showStagPopup(_key, _noAutoFocus) {
|
|
|
stagPopup.find('input[type="text"]:not([readonly]):visible,select:visible').first().focus();
|
|
|
}, 150);
|
|
|
}
|
|
|
+ stagPopupsQueue.push(stagPopup);
|
|
|
return false;
|
|
|
}
|
|
|
function submitStagPopup(_form) {
|
|
@@ -19,31 +21,40 @@ function submitStagPopup(_form) {
|
|
|
}
|
|
|
showMask();
|
|
|
$.post(_form.attr('action'), _form.serialize(), function(_data) {
|
|
|
+ stagPopupsQueue = [];
|
|
|
fastReload();
|
|
|
});
|
|
|
return false;
|
|
|
}
|
|
|
function closeStagPopup() {
|
|
|
- $('.stag-popup').removeClass('show');
|
|
|
- $('html, body').removeClass('no-scroll');
|
|
|
- $(window.top.document.body).find('#stag_mcp_lhs').removeClass('no-scroll');
|
|
|
- $(document).trigger('stag-popup-closed');
|
|
|
+ if(!stagPopupsQueue.length) return false;
|
|
|
+ let popup = stagPopupsQueue[stagPopupsQueue.length - 1];
|
|
|
+ popup.removeClass('show');
|
|
|
+ stagPopupsQueue.splice(stagPopupsQueue.length - 1, 1);
|
|
|
+ // if all closed
|
|
|
+ if(!stagPopupsQueue.length) {
|
|
|
+ $('html, body').removeClass('no-scroll');
|
|
|
+ $(window.top.document.body).find('#stag_mcp_lhs').removeClass('no-scroll');
|
|
|
+ $(document).trigger('stag-popup-closed');
|
|
|
+ }
|
|
|
return false;
|
|
|
}
|
|
|
(function() {
|
|
|
window.initStagPopupEvents = function () {
|
|
|
- $(document).on('click', '.stag-popup', function(_e) {
|
|
|
- if($(_e.target).is('.stag-popup')) {
|
|
|
- closeStagPopup();
|
|
|
- }
|
|
|
- });
|
|
|
+ $(document)
|
|
|
+ .off('click.stag-popup-discard', '.stag-popup')
|
|
|
+ .on('click.stag-popup-discard', '.stag-popup', function(_e) {
|
|
|
+ if($(_e.target).is('.stag-popup')) {
|
|
|
+ closeStagPopup();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
// catch ESC and discard any visible popups
|
|
|
$(document)
|
|
|
.off('keydown.stag-popup-escape')
|
|
|
.on('keydown.stag-popup-escape', function (e) {
|
|
|
if(e.which === 27) {
|
|
|
- let visiblePopups = $('.stag-popup.show');
|
|
|
- if (visiblePopups.length) {
|
|
|
+ if(stagPopupsQueue.length) {
|
|
|
closeStagPopup();
|
|
|
return false;
|
|
|
}
|