templates/section/popup.html.twig line 1

Open in your IDE?
  1. <style>
  2.     .slider-container {
  3.         position: relative;
  4.         width: 100%;
  5.         height: 100%;
  6.         display: flex;
  7.         align-items: center;
  8.         justify-content: center;
  9.         overflow: hidden;
  10.     }
  11.     .slide {
  12.         display: none;
  13.         width: 100%;
  14.         height: 100%;
  15.         align-items: center;
  16.         justify-content: center;
  17.     }
  18.     .slide.active {
  19.         display: flex;
  20.     }
  21.     .slide img {
  22.         width: 100%;
  23.         border-radius: 5px;
  24.         cursor: pointer;
  25.     }
  26.     .slider-btn {
  27.         position: absolute;
  28.         top: 50%;
  29.         transform: translateY(-50%);
  30.         border: none;
  31.         background: rgba(0, 0, 0, 0.5);
  32.         color: white;
  33.         font-size: 35px;
  34.         width: 50px;
  35.         height: 60px;
  36.         cursor: pointer;
  37.         z-index: 10;
  38.         border-radius: 5px;
  39.     }
  40.     .slider-btn:hover {
  41.         background: rgba(0, 0, 0, 0.8);
  42.     }
  43.     .prev {
  44.         left: 20px;
  45.     }
  46.     .next {
  47.         right: 20px;
  48.     }
  49.     .dots {
  50.         position: absolute;
  51.         bottom: 20px;
  52.         left: 50%;
  53.         transform: translateX(-50%);
  54.         display: flex;
  55.         gap: 8px;
  56.     }
  57.     .dot {
  58.         width: 12px;
  59.         height: 12px;
  60.         background: rgba(255, 255, 255, 0.5);
  61.         border-radius: 50%;
  62.         cursor: pointer;
  63.     }
  64.     .dot.active {
  65.         background: white;
  66.     }
  67.     @media (max-width: 768px) {
  68.         .slide img {
  69.             max-width: 95%;
  70.             max-height: 60vh;
  71.         }
  72.         .slider-btn {
  73.             width: 40px;
  74.             height: 50px;
  75.             font-size: 25px;
  76.         }
  77.         .prev {
  78.             left: 5px;
  79.         }
  80.         .next {
  81.             right: 5px;
  82.         }
  83.     }
  84. </style>
  85. <div id="imageModal" class="modal" style="text-align: center !important;">
  86.     <span class="close" id="closeModal"
  87.           style="cursor: pointer; font-size: 30px; position: absolute; top: 10px; right: 20px; z-index: 9999; color: white;">
  88.         &times;
  89.     </span>
  90.     <div class="modal-body text-center slider-container">
  91.         <!-- Slide 1 -->
  92.         <div class="slide active">
  93.             <a href="{{ path('front.inter.thematique') }}">
  94.                 <img src="{{ asset('public/popup/calendrier_nouveau.jpeg') }}" style="wodth: 50%; height: 40%;" alt="Formation">
  95.             </a>
  96.         </div>
  97.         <!-- Slide 2 -->
  98.         <div class="slide">
  99.             <a href="https://cimef-international.org/nos-thematiques/conformite-et-regulation/lutte-contre-le-blanchiment-de-capitaux-et-le-financement-du-terrorisme-lab-ft-securiser-vos-operations-et-renforcer-votre-conformite">
  100.                 <img src="{{ asset('public/popup/lutte-contre-le-blachiment.jpeg') }}" style="wodth: 50%; height: 40%;" alt="Formation">
  101.             </a>
  102.         </div>
  103.         <!-- Slide 3 -->
  104.         <div class="slide">
  105.             <a href="https://cimef-international.org/nos-thematiques/conformite-et-regulation/conformite-reglementaire-et-obligations-aml-kyc-dans-l-espace-uemoa-cemac">
  106.                 <img src="{{ asset('public/popup/commite-de-reglementaire.jpeg') }}" style="wodth: 50%; height: 40%;" alt="Formation">
  107.             </a>
  108.         </div>
  109.         
  110.         <!-- Slide 4 -->
  111.         <div class="slide">
  112.             <a href="https://cimef-international.org/nos-thematiques/conformite-et-regulation/construire-et-developper-un-partenariat-efficace-entre-les-institutions-de-regulation-pratiques-internationales-et-cas-sectoriels">
  113.                 <img src="{{ asset('public/popup/PPP.jpg.jpeg') }}" style="wodth: 50%; height: 40%;" alt="Formation">
  114.             </a>
  115.         </div>
  116.         
  117.         <!-- Slide 5 -->
  118.         <div class="slide">
  119.             <a href="https://cimef-international.org/formations/seminaires-internationaux/les-formats-et-les-traitements-des-operations-bancaires-via-le-systeme-swift-mx-iso-20022-les-aspects-operationnels/2014code">
  120.                 <img src="{{ asset('public/popup/BANK-ASSUR-1.jpg.jpeg') }}" style="wodth: 50%; height: 40%;" alt="Formation">
  121.             </a>
  122.         </div>
  123.         <!-- Boutons -->
  124.         <button class="slider-btn prev" id="prevSlide">&#10094;</button>
  125.         <button class="slider-btn next" id="nextSlide">&#10095;</button>
  126.         <!-- Indicateurs 
  127.         <div class="dots">
  128.             <span class="dot active" data-slide="0"></span>
  129.             <span class="dot" data-slide="1"></span>
  130.             <span class="dot" data-slide="2"></span>
  131.         </div>
  132.         -->
  133.     </div> 
  134. </div>
  135. <script>
  136.     document.addEventListener("DOMContentLoaded", function () {
  137.     
  138.         const modal = document.getElementById("imageModal");
  139.         const closeModal = document.getElementById("closeModal");
  140.         const openModal = document.getElementById("openModal");
  141.     
  142.         const slides = document.querySelectorAll(".slide");
  143.         const dots = document.querySelectorAll(".dot");
  144.     
  145.         const prevBtn = document.getElementById("prevSlide");
  146.         const nextBtn = document.getElementById("nextSlide");
  147.     
  148.         let currentSlide = 0;
  149.         let autoSlide;
  150.         let isVisible = false; // état suivi manuellement, pas relu à chaque mutation
  151.     
  152.         function showSlide(index) {
  153.             if (index >= slides.length) {
  154.                 currentSlide = 0;
  155.             } else if (index < 0) {
  156.                 currentSlide = slides.length - 1;
  157.             } else {
  158.                 currentSlide = index;
  159.             }
  160.             slides.forEach((slide, i) => {
  161.                 slide.classList.toggle("active", i === currentSlide);
  162.             });
  163.             dots.forEach((dot, i) => {
  164.                 dot.classList.toggle("active", i === currentSlide);
  165.             });
  166.         }
  167.     
  168.         function nextSlide() {
  169.             showSlide(currentSlide + 1);
  170.         }
  171.     
  172.         function prevSlide() {
  173.             showSlide(currentSlide - 1);
  174.         }
  175.     
  176.         function startAutoSlide() {
  177.             stopAutoSlide();
  178.             autoSlide = setInterval(nextSlide, 2000);
  179.         }
  180.     
  181.         function stopAutoSlide() {
  182.             clearInterval(autoSlide);
  183.         }
  184.     
  185.         function isModalVisible() {
  186.             return getComputedStyle(modal).display !== "none";
  187.         }
  188.     
  189.         // Démarrage automatique dès que la modal est visible au chargement
  190.         if (modal && isModalVisible()) {
  191.             isVisible = true;
  192.             startAutoSlide();
  193.         }
  194.     
  195.         if (openModal) {
  196.             openModal.addEventListener("click", function (event) {
  197.                 event.preventDefault();
  198.                 modal.style.display = "flex";
  199.                 isVisible = true;
  200.                 startAutoSlide();
  201.             });
  202.         }
  203.     
  204.         // Ne réagit que si la visibilité a réellement changé (pas à chaque mutation de style)
  205.         const observer = new MutationObserver(() => {
  206.             const nowVisible = isModalVisible();
  207.             if (nowVisible === isVisible) return; // rien n'a changé côté visibilité, on ignore
  208.             isVisible = nowVisible;
  209.             if (isVisible) {
  210.                 startAutoSlide();
  211.             } else {
  212.                 stopAutoSlide();
  213.             }
  214.         });
  215.         observer.observe(modal, { attributes: true, attributeFilter: ["style", "class"] });
  216.     
  217.         closeModal.addEventListener("click", function () {
  218.             modal.style.display = "none";
  219.             isVisible = false;
  220.             stopAutoSlide();
  221.         });
  222.     
  223.         modal.addEventListener("click", function (event) {
  224.             if (event.target === modal) {
  225.                 modal.style.display = "none";
  226.                 isVisible = false;
  227.                 stopAutoSlide();
  228.             }
  229.         });
  230.     
  231.         nextBtn.addEventListener("click", function (event) {
  232.             event.preventDefault();
  233.             event.stopPropagation();
  234.             nextSlide();
  235.         });
  236.     
  237.         prevBtn.addEventListener("click", function (event) {
  238.             event.preventDefault();
  239.             event.stopPropagation();
  240.             prevSlide();
  241.         });
  242.     
  243.         dots.forEach((dot, index) => {
  244.             dot.addEventListener("click", function (event) {
  245.                 event.preventDefault();
  246.                 event.stopPropagation();
  247.                 showSlide(index);
  248.             });
  249.         });
  250.     
  251.         modal.addEventListener("mouseenter", stopAutoSlide);
  252.         modal.addEventListener("mouseleave", function () {
  253.             if (isVisible) {
  254.                 startAutoSlide();
  255.             }
  256.         });
  257.     }); 
  258. </script>