summaryrefslogtreecommitdiff
path: root/resources
diff options
context:
space:
mode:
authorGreg Roach <greg@subaqua.co.uk>2026-02-10 09:53:44 +0000
committerGreg Roach <greg@subaqua.co.uk>2026-02-10 10:53:20 +0000
commitb1403cd54adcdd7b9451aafc680c644c4b888ea8 (patch)
treec8b47ef2a04d57c49c7d2ffa65941f4953654d2e /resources
parentb9a7e2dbe8360c6ea966409de77db9ee070ed0c5 (diff)
downloadwebtrees-b1403cd54adcdd7b9451aafc680c644c4b888ea8.tar.gz
webtrees-b1403cd54adcdd7b9451aafc680c644c4b888ea8.tar.bz2
webtrees-b1403cd54adcdd7b9451aafc680c644c4b888ea8.zip
Fan chart: replace jQuery with VanillaJS
Diffstat (limited to 'resources')
-rw-r--r--resources/views/modules/fanchart/chart.phtml39
1 files changed, 19 insertions, 20 deletions
diff --git a/resources/views/modules/fanchart/chart.phtml b/resources/views/modules/fanchart/chart.phtml
index a3561bbd67..4a644d65d2 100644
--- a/resources/views/modules/fanchart/chart.phtml
+++ b/resources/views/modules/fanchart/chart.phtml
@@ -23,27 +23,26 @@ declare(strict_types=1);
</div>
<script>
- jQuery("area")
- .click(function (e) {
+ document.querySelectorAll('area').forEach(function (area) {
+ area.addEventListener('click', function (e) {
e.stopPropagation();
e.preventDefault();
- let target = jQuery(this.hash);
- // position the menu centered immediately above the mouse click position and
- // make sure it doesn’t end up off the screen
- target
- .css({
- left: Math.max(0, e.pageX - (target.outerWidth() / 2)),
- top: Math.max(0, e.pageY - target.outerHeight())
- })
- .toggle()
- .siblings(".fan_chart_menu").hide();
- });
- jQuery(".fan_chart_menu")
- .on("click", "a", function (e) {
- e.stopPropagation();
- });
- jQuery("#fan_chart")
- .click(function () {
- jQuery(".fan_chart_menu").hide();
+ const target = document.querySelector(this.hash);
+ const display = target.style.display;
+
+ // Close any other open menus
+ target.parentElement.querySelectorAll('.fan_chart_menu')
+ .forEach(function (element) {
+ element.style.display = 'none';
+ });
+
+ // Toggle display
+ if (display !== 'block') {
+ // position the menu centered immediately above the mouse click position
+ target.style.display = 'block';
+ target.style.left = Math.max(0, e.pageX - (target.offsetWidth / 2)) + 'px';
+ target.style.top = Math.max(0, e.pageY - 1 - target.offsetHeight) + 'px';
+ }
});
+ });
</script>