Compare commits
No commits in common. '55d9a76281545f03f76004fd4164aa2f96d48758' and '8c2d5fc6c2bad54d8cd3188ef26609671a450cfd' have entirely different histories.
55d9a76281
...
8c2d5fc6c2
@ -1,69 +0,0 @@ |
||||
package HexGrid::Dynamic; |
||||
|
||||
use v5.30; |
||||
|
||||
use Carp; |
||||
use Data::Dumper; |
||||
|
||||
use feature "signatures"; |
||||
no warnings "experimental::signatures"; |
||||
|
||||
$HexGrid::Dynamic::click_pin = <<EOS; |
||||
function clickPin(pinId, event) { |
||||
event.stopPropagation(); |
||||
let popup = document.getElementById(pinId + '-popup'); |
||||
popup.style.visibility = popup.style.visibility == 'visible' ? 'hidden' : 'visible'; |
||||
} |
||||
EOS |
||||
$HexGrid::Dynamic::click_region = <<EOS; |
||||
function clickRegion(regionId, x, y, event) { |
||||
event.stopPropagation(); |
||||
let popup = document.getElementById(regionId + '-popup'); |
||||
popup.style.visibility = popup.style.visibility == 'visible' ? 'hidden' : 'visible'; |
||||
if (popup.style.visibility == 'visible') |
||||
{ |
||||
popup.transform.baseVal.getItem(0).setTranslate(x, y); |
||||
} |
||||
} |
||||
EOS |
||||
$HexGrid::Dynamic::toggle_coords = <<EOS; |
||||
function toggleCoords(show) { |
||||
for (var elem of document.getElementsByClassName('coords')) { |
||||
elem.style.visibility = show ? 'visible' : 'hidden'; |
||||
} |
||||
} |
||||
EOS |
||||
|
||||
$HexGrid::Dynamic::coords_toggler = <<EOS; |
||||
<label for="show-coords-checkbox">Show coordinates</label> |
||||
<input type="checkbox" checked id="show-coords-checkbox" onclick="toggleCoords(event.srcElement.checked)" /> |
||||
EOS |
||||
|
||||
sub render_html($svg, $options = undef) |
||||
{ |
||||
my $document = "<!DOCTYPE html>"; |
||||
$document .= "\n<html>\n<body>"; |
||||
|
||||
if($options) |
||||
{ |
||||
if (ref $options eq 'HASH') |
||||
{ |
||||
$document .= "\n<script>\n"; |
||||
$document .= $HexGrid::Dynamic::click_pin if $options->{pin_popups}; |
||||
$document .= $HexGrid::Dynamic::click_region if $options->{region_popups}; |
||||
$document .= $HexGrid::Dynamic::toggle_coords if $options->{toggle_coords}; |
||||
$document .= "\n</script>\n"; |
||||
$document .= $HexGrid::Dynamic::coords_toggler if $options->{toggle_coords}; |
||||
} |
||||
else |
||||
{ |
||||
carp("Options passed to HexGrid::Dynamic::render_html must be a hash ref"); |
||||
return; |
||||
} |
||||
} |
||||
|
||||
$document .= "\n" . $svg; |
||||
$document .= "\n</body>\n</html>"; |
||||
return $document; |
||||
} |
||||
1; |
Loading…
Reference in new issue