2024-06-09 08:04:37 +03:00
|
|
|
import Cookies from "js-cookie";
|
2024-06-09 08:14:56 +03:00
|
|
|
import { el } from "./utils.js";
|
2024-06-09 08:04:37 +03:00
|
|
|
|
|
|
|
const HIDE_INFO_POPUP = "hideInfoPopup";
|
|
|
|
|
2024-06-10 20:58:19 +03:00
|
|
|
let infoPopup;
|
|
|
|
let map;
|
|
|
|
|
|
|
|
function getHidePopup() {
|
|
|
|
const hidePopupCookie = Cookies.get(HIDE_INFO_POPUP);
|
|
|
|
return hidePopupCookie === 'true';
|
|
|
|
}
|
|
|
|
|
|
|
|
function setHidePopup(hidePopupCookie) {
|
|
|
|
Cookies.set(HIDE_INFO_POPUP, hidePopupCookie ? "true" : "false", { expires: 400 });
|
|
|
|
}
|
|
|
|
|
|
|
|
export function showPopup() {
|
|
|
|
infoPopup.style.display = "block";
|
|
|
|
map.style.display = "none";
|
|
|
|
|
|
|
|
const hidePopupCookie = getHidePopup();
|
|
|
|
|
|
|
|
if (hidePopupCookie) {
|
|
|
|
const noShowCheckbox = document.querySelector('input[name="no-show"]');
|
|
|
|
noShowCheckbox.checked = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function hidePopup() {
|
|
|
|
infoPopup.style.display = "none";
|
|
|
|
map.style.display = "block";
|
|
|
|
}
|
|
|
|
|
2024-06-09 08:04:37 +03:00
|
|
|
document.addEventListener("DOMContentLoaded", function () {
|
2024-06-10 20:58:19 +03:00
|
|
|
infoPopup = el("info-popup");
|
2024-06-09 08:14:56 +03:00
|
|
|
const noShowCheckbox = document.querySelector('input[name="no-show"]');
|
|
|
|
const confirmButton = document.querySelector(".info-popup footer button");
|
2024-06-10 20:58:19 +03:00
|
|
|
map = el("map");
|
|
|
|
|
|
|
|
const hidePopupCookie = getHidePopup();
|
2024-06-09 08:04:37 +03:00
|
|
|
|
2024-06-09 08:14:56 +03:00
|
|
|
if (!hidePopupCookie) {
|
2024-06-10 20:58:19 +03:00
|
|
|
showPopup();
|
2024-06-09 08:14:56 +03:00
|
|
|
}
|
2024-06-09 08:04:37 +03:00
|
|
|
|
2024-06-09 08:14:56 +03:00
|
|
|
confirmButton.addEventListener("click", function () {
|
2024-06-10 20:58:19 +03:00
|
|
|
setHidePopup(noShowCheckbox.checked);
|
|
|
|
hidePopup();
|
2024-06-09 08:14:56 +03:00
|
|
|
});
|
2024-06-09 08:04:37 +03:00
|
|
|
});
|