Wire clear-hex dialog back up

This commit is contained in:
Catalin Constantin Mititiuc 2025-06-16 22:41:33 -07:00
parent e4d88c3ebe
commit 2499b8c268
2 changed files with 16 additions and 17 deletions

View File

@ -373,6 +373,7 @@
<button
style="display: block; margin-left: auto;"
value="confirm"
formmethod="dialog"
>Confirm</button>
</div>
</form>

View File

@ -226,6 +226,7 @@ export function start(el) {
// For when the pointer leaves the window
document.querySelector('object').addEventListener('pointerout', e => {
if (clearHexDialog.open) return;
console.log('object pointerout');
console.log('Left map... CLEARING HOVERS');
svg.querySelectorAll('.hover').forEach(el => el.classList.remove('hover'));
@ -410,19 +411,15 @@ export function start(el) {
grid.addEventListener('click', clickHandler);
const clearHexDialog = document.querySelector('#clear-hex');
//clearHexDialog.addEventListener('close', e => {
// if (clearHexDialog.returnValue === 'confirm') {
// [...top.container.children].forEach(child => {
// top.collection.delete(child);
// child.remove();
// });
// }
//});
//clearHexDialog.querySelector('button[value="confirm"]').addEventListener('click', function(e) {
// e.preventDefault();
// clearHexDialog.close(this.value);
//});
clearHexDialog.addEventListener('close', e => {
if (clearHexDialog.returnValue === 'confirm') {
[...frontmost.children].forEach(child => {
frontmostStore.delete(child);
child.remove();
});
}
});
//gridTop.addEventListener('pointerleave', workaroundForWebKitBug233432(e => {
// console.log('pointerleave top', performance.now(), top.cell);
@ -443,11 +440,12 @@ export function start(el) {
//}));
//topHex.addEventListener('click', clickHandler);
//
//topHex.addEventListener('contextmenu', e => {
// e.preventDefault();
// getSelected() ? sightLine.toggleLock(top.cell) : clearHexDialog.showModal();
//});
grid.addEventListener('contextmenu', e => {
e.preventDefault();
getSelected() ? sightLine.toggleLock(grid.querySelector('.hover')) : clearHexDialog.showModal();
});
const startingLocations = svg.querySelector('.start-locations');
startingLocations && getUnits(startingLocations).forEach(unit => unit.addEventListener('click', selectOffBoard));