From 08beeced358050426b04008f3675ebb572d60672 Mon Sep 17 00:00:00 2001 From: Rumperuu Date: Wed, 24 Aug 2022 10:41:23 +0000 Subject: [PATCH] Fix details toggling --- resources/views/tracker.blade.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/resources/views/tracker.blade.php b/resources/views/tracker.blade.php index 8cdb23a..ed9757d 100644 --- a/resources/views/tracker.blade.php +++ b/resources/views/tracker.blade.php @@ -12,10 +12,10 @@ - + - +

Where in the World is Ben?

@@ -32,8 +32,8 @@
    @foreach($trip->checkins as $checkin) -
  1. -
    +
  2. +

    {{ $checkin->title ?? "[No title]" }}

    {{ $checkin->date }}
    {{ $checkin->note ?? "[No note]" }}
    @@ -71,8 +71,18 @@ checkinMarkers[{{ $checkin->id }}] = marker; @endforeach - function openCheckin(checkinId) { - checkinMarkers[checkinId].openPopup(); + function toggleCheckin(isOpen, checkinId) { + if (isOpen) { + var checkins = document.querySelectorAll('details'); + + checkinMarkers[checkinId].openPopup(); + + checkins.forEach(checkin => { + if (checkin.id != checkinId && checkin.open) checkin.open = false; + }); + } else { + checkinMarkers[checkinId].closePopup(); + } }