diff --git a/resources/assets/images/2024-ad.png b/resources/assets/images/2024-ad.png new file mode 100644 index 0000000..500da5c Binary files /dev/null and b/resources/assets/images/2024-ad.png differ diff --git a/resources/sass/fo/vendor/_bootstrap.scss b/resources/sass/fo/vendor/_bootstrap.scss index 513133f..79a51d2 100644 --- a/resources/sass/fo/vendor/_bootstrap.scss +++ b/resources/sass/fo/vendor/_bootstrap.scss @@ -36,6 +36,7 @@ @import "bootstrap/scss/utilities"; @import "bootstrap/scss/close"; @import "bootstrap/scss/breadcrumb"; +@import "bootstrap/scss/modal"; // 6. Optionally include utilities API last to generate classes based on the Sass map in `_utilities.scss` @import "bootstrap/scss/utilities/api"; diff --git a/resources/sass/fo/vendor/_ldcweb-cookies.scss b/resources/sass/fo/vendor/_ldcweb-cookies.scss index 1395bb5..ef17209 100644 --- a/resources/sass/fo/vendor/_ldcweb-cookies.scss +++ b/resources/sass/fo/vendor/_ldcweb-cookies.scss @@ -306,7 +306,7 @@ button { } } - &-modal .modal { + &-modal { z-index: 200; display: flex; width: 100%; diff --git a/resources/ts/fo/fo.ts b/resources/ts/fo/fo.ts index acf1f36..2f9213a 100644 --- a/resources/ts/fo/fo.ts +++ b/resources/ts/fo/fo.ts @@ -18,6 +18,9 @@ window.Fancybox = Fancyapps.Fancybox; // FSLIGHTBOX import "fslightbox"; +// MODULES +import "./modules/ad_modal"; + // CUSTOM import "./base/common"; import "./burgermenu"; diff --git a/resources/ts/fo/modules/ad_modal.ts b/resources/ts/fo/modules/ad_modal.ts new file mode 100644 index 0000000..0e73a34 --- /dev/null +++ b/resources/ts/fo/modules/ad_modal.ts @@ -0,0 +1,79 @@ +import { Modal } from "bootstrap"; + +document.addEventListener("DOMContentLoaded", function () { + const adModal = document.getElementById("adModal"); + + if (!adModal) { + return; + } + + const callback = (mutationList: Array, observer: MutationObserver) => { + for (const mutation of mutationList) { + if (mutation.type === "attributes") { + // Display only if the tiemstamp is correct and if no other modal is opened. + if (getAdModalCache() && !this.body.classList.contains("cn-open") && !this.body.classList.contains("modal-open")) { + displayAdModal(adModal); + observer.disconnect(); + } + } + } + }; + + const observer = new MutationObserver(callback); + observer.observe(this.body, { attributes: true }); + + if (getAdModalCache() && !this.body.classList.contains("cn-open")) { + displayAdModal(adModal); + } + + // Set the timer also if we click on the link + const modalLink = document.getElementById("adModalLink"); + if (modalLink) { + modalLink.addEventListener("click", function () { + updateAdModalCache(); + }); + } + +}); + +function displayAdModal(adModal: HTMLElement) +{ + const myModal = new Modal(adModal); + myModal.show(); + adModal.addEventListener("hidden.bs.modal", function () { + updateAdModalCache(); + }); +} + +/** Check if we need to show the modal according to the stored timer */ +function getAdModalCache(): boolean { + const localAdModalTimer = localStorage.getItem("hideAdModalUntil"); + if (localAdModalTimer !== null) { + const localAdModalTimerJson = JSON.parse(localAdModalTimer); + const localStoredTime = new Date(localAdModalTimerJson.value); + + if (isTimestampTooOld(localStoredTime)) { + localStorage.removeItem("hideAdModalUntil"); + return true; + } + return false; + } + return true; +} + +/** Update the local stored timestamp */ +function updateAdModalCache(): void { + const time = { value: new Date() }; + localStorage.setItem("hideAdModalUntil", JSON.stringify(time)); +} + +/** Check if the stored timestamp is older than yesterday */ +function isTimestampTooOld(timestamp: Date): boolean +{ + const yesterday = new Date(); + yesterday.setDate(yesterday.getDate() - 1); + if (timestamp.getTime() - yesterday.getTime() > 0) { + return false; + } + return true; +} diff --git a/resources/views/fo/layout.blade.php b/resources/views/fo/layout.blade.php index ebcf474..6462e30 100644 --- a/resources/views/fo/layout.blade.php +++ b/resources/views/fo/layout.blade.php @@ -12,6 +12,26 @@ @yield('content') + + @if (!request()->routeIs('map')) + + @endif + @include('fo.layouts.footer') @include('vendor.cn-cookies') diff --git a/resources/views/fo/pages/map.blade.php b/resources/views/fo/pages/map.blade.php index b3c2ac6..f0405ab 100644 --- a/resources/views/fo/pages/map.blade.php +++ b/resources/views/fo/pages/map.blade.php @@ -5,22 +5,21 @@ @section('breadcrumb', request()->route()->getName()) @push('styles') - + @endpush - @section('content')
- Logo 100% local + Logo 100% local
- Un plat de poulet rôti et ses accompagnements sortant du four + Un plat de poulet rôti et ses accompagnements sortant du four
-