mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 11:09:18 +02:00
64 lines
2.1 KiB
PHP
64 lines
2.1 KiB
PHP
<main class="search-main" id="main-content">
|
|
<h1 class="sr-only">Répertoire</h1>
|
|
<span id="rep-indicator" class="rep-indicator htmx-indicator" aria-hidden="true"></span>
|
|
<?php include APP_ROOT . '/templates/partials/repertoire-index.php'; ?>
|
|
</main>
|
|
<!-- Student popover -->
|
|
<div id="student-popover" class="student-popover" hidden aria-live="polite"></div>
|
|
|
|
<script src="/assets/js/htmx.min.js"></script>
|
|
<script>
|
|
(function () {
|
|
var popover = document.getElementById('student-popover');
|
|
var currentAnchor = null;
|
|
|
|
function positionPopover(anchor) {
|
|
var rect = anchor.getBoundingClientRect();
|
|
var scrollY = window.scrollY || 0;
|
|
var scrollX = window.scrollX || 0;
|
|
var left = rect.right + scrollX + 12;
|
|
var top = rect.top + scrollY;
|
|
if (left + 300 > window.innerWidth + scrollX) {
|
|
left = rect.left + scrollX - 312;
|
|
}
|
|
popover.style.left = left + 'px';
|
|
popover.style.top = top + 'px';
|
|
}
|
|
|
|
function showPreview(anchor) {
|
|
var tplId = anchor.dataset.preview;
|
|
if (!tplId) return;
|
|
var tpl = document.getElementById(tplId);
|
|
if (!tpl) return;
|
|
popover.innerHTML = '';
|
|
popover.appendChild(tpl.content.cloneNode(true));
|
|
positionPopover(anchor);
|
|
popover.hidden = false;
|
|
}
|
|
|
|
function hidePreview() {
|
|
popover.hidden = true;
|
|
currentAnchor = null;
|
|
}
|
|
|
|
document.body.addEventListener('mouseenter', function (e) {
|
|
var a = e.target.closest('[data-preview]');
|
|
if (!a) return;
|
|
currentAnchor = a;
|
|
showPreview(a);
|
|
}, true);
|
|
|
|
document.body.addEventListener('mouseleave', function (e) {
|
|
var a = e.target.closest('[data-preview]');
|
|
var p = e.target.closest('#student-popover');
|
|
if (!a && !p) return;
|
|
setTimeout(function () {
|
|
if (!document.querySelector('[data-preview]:hover') &&
|
|
!document.querySelector('#student-popover:hover')) {
|
|
hidePreview();
|
|
}
|
|
}, 120);
|
|
}, true);
|
|
}());
|
|
</script>
|