fisharebest/webtrees

View on GitHub
resources/views/modules/fanchart/chart.phtml

Summary

Maintainability
Test Coverage
<?php

declare(strict_types=1);

/**
 * @var string $areas
 * @var int    $fanh
 * @var int    $fanw
 * @var string $html
 * @var string $png
 * @var string $title
 */

?>
<?= $html ?>

<map id="fan-chart-map" name="fan-chart-map">
    <?= $areas ?>
</map>

<div class="text-center">
    <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">
</div>

<script>
  jQuery("area")
    .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();
    });
</script>