so banner styles never leak into it (same place the old plugin rendered them).
document.querySelectorAll('dialog.jhs-popup').forEach(function(d){ if (d.parentNode !== document.body) document.body.appendChild(d); });
function unlock(){ if (!document.querySelector('dialog.jhs-popup[open]')) document.body.classList.remove('jhs-popup-open'); }
document.querySelectorAll('dialog.jhs-popup').forEach(function(d){ d.addEventListener('close', unlock); });
document.addEventListener('click', function(e){
var t = e.target; if (!t || !t.closest) return;
var trigger = t.closest('[data-jhs-popup]');
if (trigger) {
var d = document.getElementById(trigger.getAttribute('data-jhs-popup'));
if (d && typeof d.showModal === 'function') { e.preventDefault(); if (!d.open) { d.showModal(); document.body.classList.add('jhs-popup-open'); } }
return; // no dialog support: the link's normal href (the contact page) still works
}
if (t.closest('.jhs-popup-close')) { var c = t.closest('dialog'); if (c) c.close(); return; }
if (t.tagName === 'DIALOG' && t.classList.contains('jhs-popup')) t.close(); // click on the dark overlay
});
})();