document.addEventListener('DOMContentLoaded', function () { document.addEventListener('click', function (event) { const clickedButton = event.target.closest( '.gt-facilities-btn, .gt-view-details' ); /* Klik tombol View Details */ if (clickedButton) { event.preventDefault(); event.stopPropagation(); const currentCard = clickedButton.closest('.gt-card'); if (!currentCard) { console.warn('GT Facilities: parent .gt-card tidak ditemukan.'); return; } const currentPanel = currentCard.querySelector('.gt-facilities'); if (!currentPanel) { console.warn( 'GT Facilities: .gt-facilities tidak ditemukan dalam card yang sama.' ); return; } const willOpen = !currentPanel.classList.contains('gt-show'); /* Tutup seluruh panel lain */ document.querySelectorAll('.gt-facilities.gt-show').forEach(function (panel) { panel.classList.remove('gt-show'); }); /* Buka panel yang diklik */ if (willOpen) { currentPanel.classList.add('gt-show'); } return; } /* Klik di dalam facilities tidak langsung menutup */ if (event.target.closest('.gt-facilities')) { event.stopPropagation(); return; } /* Klik di luar menutup semuanya */ document.querySelectorAll('.gt-facilities.gt-show').forEach(function (panel) { panel.classList.remove('gt-show'); }); }); });