0
0
mirror of https://github.com/Maks1mS/free-ozon-dpr.git synced 2025-01-15 03:41:04 +03:00
free-ozon-dpr/src/info-popup.js

52 lines
1.2 KiB
JavaScript
Raw Normal View History

import Cookies from "js-cookie";
2024-06-09 08:14:56 +03:00
import { el } from "./utils.js";
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";
}
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: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: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
});
});