added type='button' to both guard portal btns so firefox won't normalize to type='submit'; fixed several FTs for new click-guard functionality on Role card select & room gear menu DEL & BYE btns; several restorations to landscape breakpoint incl. logged-ion display_name, copyright info; provided title to room_scroll.html; a slurry of other minor fixes
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
@@ -57,8 +57,91 @@
|
||||
{% endif %}
|
||||
<dialog id="id_kit_bag_dialog"></dialog>
|
||||
|
||||
<div id="id_guard_portal">
|
||||
<span class="guard-message"></span>
|
||||
<div class="guard-actions">
|
||||
<button class="btn btn-confirm guard-yes" type="button">OK</button>
|
||||
<button class="btn btn-cancel guard-no" type="button">NVM</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% block scripts %}
|
||||
{% endblock scripts %}
|
||||
<script>
|
||||
(function () {
|
||||
var portal = null;
|
||||
var _cb = null;
|
||||
var _onDismiss = null;
|
||||
|
||||
function show(anchor, message, callback, onDismiss) {
|
||||
if (!portal) return;
|
||||
_cb = callback;
|
||||
_onDismiss = onDismiss || null;
|
||||
portal.querySelector('.guard-message').innerHTML = message;
|
||||
portal.classList.add('active');
|
||||
var rect = anchor.getBoundingClientRect();
|
||||
var pw = portal.offsetWidth;
|
||||
var rawLeft = rect.left + rect.width / 2;
|
||||
var cleft = Math.max(pw / 2 + 8, Math.min(rawLeft, window.innerWidth - pw / 2 - 8));
|
||||
portal.style.left = Math.round(cleft) + 'px';
|
||||
if (rect.top > 120) {
|
||||
portal.style.top = Math.round(rect.top) + 'px';
|
||||
portal.style.transform = 'translate(-50%, calc(-100% - 0.5rem))';
|
||||
} else {
|
||||
portal.style.top = Math.round(rect.bottom) + 'px';
|
||||
portal.style.transform = 'translate(-50%, 0.5rem)';
|
||||
}
|
||||
}
|
||||
|
||||
function dismiss() {
|
||||
if (!portal) return;
|
||||
var od = _onDismiss;
|
||||
portal.classList.remove('active');
|
||||
_cb = null;
|
||||
_onDismiss = null;
|
||||
if (od) od();
|
||||
}
|
||||
|
||||
function doConfirm() {
|
||||
var cb = _cb;
|
||||
portal.classList.remove('active');
|
||||
_cb = null;
|
||||
_onDismiss = null;
|
||||
if (cb) cb();
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
portal = document.getElementById('id_guard_portal');
|
||||
if (!portal) return;
|
||||
portal.querySelector('.guard-yes').addEventListener('click', doConfirm);
|
||||
portal.querySelector('.guard-no').addEventListener('click', dismiss);
|
||||
document.addEventListener('keydown', function (e) {
|
||||
if (e.key === 'Escape') dismiss();
|
||||
});
|
||||
// Outside-click to dismiss — capture phase + stopPropagation
|
||||
// prevents the click from cascading to backdrop listeners (e.g. closeFan)
|
||||
document.addEventListener('click', function (e) {
|
||||
if (!portal.classList.contains('active')) return;
|
||||
if (portal.contains(e.target)) return;
|
||||
e.stopPropagation();
|
||||
dismiss();
|
||||
}, true);
|
||||
// Intercept [data-confirm] buttons (capture phase, before form submits)
|
||||
document.addEventListener('click', function (e) {
|
||||
var btn = e.target.closest('[data-confirm]');
|
||||
if (!btn) return;
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
var form = btn.closest('form');
|
||||
show(btn, btn.dataset.confirm, function () {
|
||||
if (form) form.submit();
|
||||
});
|
||||
}, true);
|
||||
});
|
||||
|
||||
window.showGuard = show;
|
||||
}());
|
||||
</script>
|
||||
<script src="{% static "vendor/htmx.min.js" %}"></script>
|
||||
<script src="{% static "apps/applets/applets.js" %}"></script>
|
||||
<script src="{% static "apps/dashboard/game-kit.js" %}"></script>
|
||||
|
||||
Reference in New Issue
Block a user