Files
xamxam/app/public/assets/js/app/repertoire-student-popover.js
T
Pontoporeia 3e93150c76 justfile: standardise test recipes to lint-php/lint-css/lint-js/test + add fix recipe
- Removed ambiguous aliases: phpstan, cs-check, syntax
- Split lint-biome into lint-css and lint-js with correct paths
- Added lint meta-recipe and fix recipe (biome --unsafe + php-cs-fixer)
- Fixed FormBootstrap dead null check, CSS shorthand override bug
- Updated phpstan baseline, suppressed noDescendingSpecificity/noInnerDeclarations
- Applied ~74 biome auto-fixes across CSS/JS
2026-07-05 11:07:41 +02:00

58 lines
1.3 KiB
JavaScript

/**
* repertoire-student-popover.js — Student name popover on repertoire page.
*
* Shows a popover with HTMX-fetched student details on hover over links
* with `data-student-name` attribute.
*/
(() => {
var popover = document.getElementById("student-popover");
var currentAnchor = null;
function position(anchor) {
var r = anchor.getBoundingClientRect();
var left = r.right + window.scrollX + 12;
var top = r.top + window.scrollY;
if (left + 300 > window.innerWidth + window.scrollX) {
left = r.left + window.scrollX - 312;
}
popover.style.left = `${left}px`;
popover.style.top = `${top}px`;
}
document.body.addEventListener(
"mouseenter",
(e) => {
var a = e.target.closest("[data-student-name]");
if (!a) return;
currentAnchor = a;
},
true,
);
document.body.addEventListener("htmx:afterSwap", (e) => {
if (e.detail.target !== popover) return;
if (currentAnchor) position(currentAnchor);
popover.hidden = false;
});
document.body.addEventListener(
"mouseleave",
(e) => {
if (
!e.target.closest("[data-student-name]") &&
!e.target.closest("#student-popover")
)
return;
setTimeout(() => {
if (
!document.querySelector("[data-student-name]:hover") &&
!document.querySelector("#student-popover:hover")
) {
popover.hidden = true;
}
}, 120);
},
true,
);
})();