| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- <?php
- session_start();
- // Gérer le toggle du menu
- if (isset($_GET['menu'])) {
- $_SESSION['active_menu'] = $_GET['menu'] === '2' ? '2' : '1';
- }
- // Définir le menu par défaut si non défini
- if (!isset($_SESSION['active_menu'])) {
- $_SESSION['active_menu'] = '1';
- }
- ?>
- <!DOCTYPE html>
- <html lang="fr">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Application Layout - Dashboard</title>
-
- <!-- Tailwind CSS CDN (ou utilisez votre installation locale) -->
- <script src="https://cdn.tailwindcss.com"></script>
- </head>
- <body class="bg-gray-50 dark:bg-neutral-900">
-
- <?php
- if ($_SESSION['active_menu'] === '2') {
- include 'menu2.php';
- } else {
- include 'menu.php';
- }
- ?>
-
- <!-- Preline UI - Chargé à la fin du body pour une initialisation correcte -->
- <script src="https://cdn.jsdelivr.net/npm/preline@2.1.0/dist/preline.js"></script>
- <script>
- // Script pour s'assurer que le dropdown de notifications fonctionne
- document.addEventListener('DOMContentLoaded', function() {
- const notificationButton = document.getElementById('hs-notification-dropdown');
- const notificationMenu = document.getElementById('notification-dropdown-menu');
-
- if (notificationButton && notificationMenu) {
- // Calculer la position du dropdown par rapport à la cloche
- function updateDropdownPosition() {
- const buttonRect = notificationButton.getBoundingClientRect();
- const menuWidth = 400; // Largeur du menu
- const menuHeight = notificationMenu.offsetHeight;
-
- // Positionner le dropdown à droite de la cloche
- notificationMenu.style.top = (buttonRect.bottom + 8) + 'px';
- notificationMenu.style.right = (window.innerWidth - buttonRect.right) + 'px';
- notificationMenu.style.maxWidth = '400px';
- }
-
- notificationButton.addEventListener('click', function(e) {
- e.stopPropagation();
- const isExpanded = notificationButton.getAttribute('aria-expanded') === 'true';
- const newExpanded = !isExpanded;
-
- notificationButton.setAttribute('aria-expanded', newExpanded);
-
- if (newExpanded) {
- updateDropdownPosition();
- notificationMenu.classList.remove('opacity-0', 'invisible', 'translate-y-2');
- notificationMenu.classList.add('opacity-100', 'visible', 'translate-y-0');
- } else {
- notificationMenu.classList.remove('opacity-100', 'visible', 'translate-y-0');
- notificationMenu.classList.add('opacity-0', 'invisible', 'translate-y-2');
- }
- });
-
- // Fermer le dropdown en cliquant en dehors
- document.addEventListener('click', function(e) {
- if (!notificationButton.contains(e.target) && !notificationMenu.contains(e.target)) {
- notificationMenu.classList.remove('opacity-100', 'visible', 'translate-y-0');
- notificationMenu.classList.add('opacity-0', 'invisible', 'translate-y-2');
- notificationButton.setAttribute('aria-expanded', 'false');
- }
- });
-
- // Mettre à jour la position lors du redimensionnement
- window.addEventListener('resize', function() {
- if (notificationButton.getAttribute('aria-expanded') === 'true') {
- updateDropdownPosition();
- }
- });
- }
- });
-
- // Script pour s'assurer que l'accordéon fonctionne
- (function() {
- function initAccordions() {
- const accordionButtons = document.querySelectorAll('.hs-accordion-toggle');
-
- accordionButtons.forEach(function(button) {
- const accordion = button.closest('.hs-accordion');
- const content = accordion ? accordion.querySelector('.hs-accordion-content') : null;
-
- if (!content) return;
-
- // Vérifier si un gestionnaire d'événements existe déjà
- if (button.dataset.accordionInitialized) return;
- button.dataset.accordionInitialized = 'true';
-
- button.addEventListener('click', function(e) {
- e.preventDefault();
- e.stopPropagation();
-
- const isExpanded = button.getAttribute('aria-expanded') === 'true';
- const newExpanded = !isExpanded;
-
- // Toggle l'état aria
- button.setAttribute('aria-expanded', newExpanded);
-
- // Toggle la classe active sur l'accordéon et le bouton pour les styles Preline UI
- accordion.classList.toggle('active', newExpanded);
- button.classList.toggle('hs-accordion-active', newExpanded);
-
- // Gérer l'affichage du contenu avec animation
- if (newExpanded) {
- // Ouvrir l'accordéon
- content.classList.remove('hidden');
- // Calculer la hauteur réelle
- const height = content.scrollHeight;
- // Définir la hauteur initiale à 0
- content.style.height = '0px';
- // Forcer le reflow
- content.offsetHeight;
- // Animer vers la hauteur réelle
- content.style.height = height + 'px';
- // Nettoyer après l'animation
- setTimeout(function() {
- content.style.height = '';
- }, 300);
- } else {
- // Fermer l'accordéon
- const height = content.scrollHeight;
- content.style.height = height + 'px';
- // Forcer le reflow
- content.offsetHeight;
- // Animer vers 0
- content.style.height = '0px';
- // Cacher après l'animation
- setTimeout(function() {
- content.classList.add('hidden');
- content.style.height = '';
- }, 300);
- }
- });
- });
- }
-
- // Essayer plusieurs fois pour s'assurer que le DOM est prêt
- if (document.readyState === 'loading') {
- document.addEventListener('DOMContentLoaded', function() {
- setTimeout(initAccordions, 100);
- });
- } else {
- setTimeout(initAccordions, 100);
- }
-
- // Réinitialiser après un délai pour capturer les éléments chargés dynamiquement
- setTimeout(initAccordions, 500);
- })();
- </script>
- </body>
- </html>
|