This commit is contained in:
27
public/ts-build/ui/modal.js
Normal file
27
public/ts-build/ui/modal.js
Normal file
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.showModal = showModal;
|
||||
exports.hideModal = hideModal;
|
||||
let activeModal = null;
|
||||
let backdrop = null;
|
||||
function ensureBackdrop() {
|
||||
if (backdrop)
|
||||
return backdrop;
|
||||
backdrop = document.createElement('div');
|
||||
backdrop.className = 'modal-backdrop';
|
||||
backdrop.addEventListener('click', hideModal);
|
||||
document.body.appendChild(backdrop);
|
||||
return backdrop;
|
||||
}
|
||||
function showModal(content) {
|
||||
const bd = ensureBackdrop();
|
||||
if (!content.parentElement)
|
||||
bd.appendChild(content);
|
||||
activeModal = content;
|
||||
bd.classList.add('show');
|
||||
}
|
||||
function hideModal() {
|
||||
if (backdrop)
|
||||
backdrop.classList.remove('show');
|
||||
activeModal = null;
|
||||
}
|
||||
Reference in New Issue
Block a user