From ce0b6edefa8cbbdabea655eb66442f094af628dd Mon Sep 17 00:00:00 2001 From: RezenkovD Date: Mon, 14 Aug 2023 09:40:25 +0300 Subject: [PATCH] feat: add save state after close popup --- vr_club_site/templates/site/js/calendar.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vr_club_site/templates/site/js/calendar.js b/vr_club_site/templates/site/js/calendar.js index ede05b3..91be04d 100644 --- a/vr_club_site/templates/site/js/calendar.js +++ b/vr_club_site/templates/site/js/calendar.js @@ -124,6 +124,8 @@ document.addEventListener("DOMContentLoaded", function () { var popupScrollPosition; function openPopup(day, month, year) { popupScrollPosition = window.scrollY; + const state = { popupOpen: true, day: day, month: month, year: year }; + history.pushState(state, null, ''); // Збереження стану в історії браузера const dateDiv = document.querySelector('.booking-date'); const monthsNames = [ "січня", @@ -159,13 +161,14 @@ function closePopup() { popup.style.display = 'none'; body.style.overflow = 'auto'; window.scrollTo(0, popupScrollPosition); + history.pushState(null, null, ''); } window.addEventListener('popstate', function(event) { var state = event.state; if (state && state.popupOpen) { - openPopup(day, month, year); + openPopup(state.day, state.month, state.year); } else { closePopup(); }