xref: /webtrees/resources/views/modules/fanchart/chart.phtml (revision 10e0649788c8d7d4974d81c048ca2b225df8f22e)
17c2c99faSGreg Roach<?php
27c2c99faSGreg Roach
3*10e06497SGreg Roachdeclare(strict_types=1);
4*10e06497SGreg Roach
57c2c99faSGreg Roach/**
67c2c99faSGreg Roach * @var string $areas
77c2c99faSGreg Roach * @var int    $fanh
87c2c99faSGreg Roach * @var int    $fanw
97c2c99faSGreg Roach * @var string $html
107c2c99faSGreg Roach * @var string $png
117c2c99faSGreg Roach * @var string $title
127c2c99faSGreg Roach */
137c2c99faSGreg Roach
147c2c99faSGreg Roach?>
15389266c0SGreg Roach<?= $html ?>
16389266c0SGreg Roach
17389266c0SGreg Roach<map id="fan-chart-map" name="fan-chart-map">
18389266c0SGreg Roach    <?= $areas ?>
19389266c0SGreg Roach</map>
20389266c0SGreg Roach
21389266c0SGreg Roach<div class="text-center">
22242a7862SGreg Roach    <img class="wt-chart-fan-img" src="data:image/png;base64,<?= base64_encode($png) ?>" width="<?= $fanw ?>" height="<?= $fanh ?>" alt="<?= strip_tags($title) ?>" usemap="#fan-chart-map">
23389266c0SGreg Roach</div>
24389266c0SGreg Roach
25389266c0SGreg Roach<script>
26389266c0SGreg Roach  jQuery("area")
27389266c0SGreg Roach    .click(function (e) {
28389266c0SGreg Roach      e.stopPropagation();
29389266c0SGreg Roach      e.preventDefault();
307c2c99faSGreg Roach      let target = jQuery(this.hash);
31389266c0SGreg Roach      // position the menu centered immediately above the mouse click position and
32389266c0SGreg Roach      // make sure it doesn’t end up off the screen
33389266c0SGreg Roach      target
34389266c0SGreg Roach        .css({
35389266c0SGreg Roach          left: Math.max(0, e.pageX - (target.outerWidth() / 2)),
36389266c0SGreg Roach          top:  Math.max(0, e.pageY - target.outerHeight())
37389266c0SGreg Roach        })
38389266c0SGreg Roach        .toggle()
39389266c0SGreg Roach        .siblings(".fan_chart_menu").hide();
40389266c0SGreg Roach    });
41389266c0SGreg Roach  jQuery(".fan_chart_menu")
42389266c0SGreg Roach    .on("click", "a", function (e) {
43389266c0SGreg Roach      e.stopPropagation();
44389266c0SGreg Roach    });
45389266c0SGreg Roach  jQuery("#fan_chart")
467c2c99faSGreg Roach    .click(function () {
47389266c0SGreg Roach      jQuery(".fan_chart_menu").hide();
48389266c0SGreg Roach    });
49389266c0SGreg Roach</script>
50