document.addEventListener("DOMContentLoaded", function () { $('select').material_select(); document.getElementById('menu_bouton').addEventListener('click', () => { document.getElementById('menu_bouton').classList.toggle('active'); document.getElementById('header').classList.toggle('active'); document.querySelector('body').classList.toggle('active'); }); const accordeonTitres = document.querySelectorAll('.accordeon .text_ck:first-child'); for (const accordeon of accordeonTitres) { accordeon.addEventListener('click', function () { this.closest('.accordeon ').classList.toggle('active'); const allNextDiv = nextAll(this); for (const div of allNextDiv) { if (div.style.display == 'block') div.style.display = 'none'; else div.style.display = 'block'; } }); } const itemsMenu = document.querySelectorAll('.menu-item ul li a'); for (const itemMenu of itemsMenu) { if (itemMenu.classList.contains('active')) { itemMenu.closest('.menu-item').classList.add('active'); } } if (window.innerWidth < 1200) { document.querySelectorAll('.has_categ').forEach((item) => { item.addEventListener('click', (e) => { let sous_menu = item.querySelector('ul'); let style_sous_menu = window.getComputedStyle(sous_menu, null).getPropertyValue("display"); if (style_sous_menu === 'none') { sous_menu.style.display = 'block'; } else { sous_menu.style.display = 'none'; } e.stopPropagation(); }); }); } const titre1 = document.querySelector('.animation_titre h2:first-child'); const titre2 = document.querySelector('.animation_titre h2:last-child'); if (titre1 && titre2) { const contentTitre1 = titre1.innerHTML; titre1.prepend(contentTitre1 + ' • '); const contentTitre2 = titre2.innerHTML; titre2.prepend(contentTitre2 + ' • '); window.addEventListener('scroll', () => { let value = window.scrollY; titre1.style.transform = 'translateX(' + value * 0.7 + 'px)'; titre2.style.transform = 'translateX(-' + value * 0.7 + 'px)'; }); } filtres_articles_tags(); /*FADE BOUTON SCROLL TO TOP*/ const bouton_top = document.getElementById('bouton_top'); window.addEventListener('scroll', () => { let value = window.scrollY; if (value >= 200) { bouton_top.classList.add('scroll'); } else { bouton_top.classList.remove('scroll'); } }); /*SCROLL TO TOP*/ bouton_top.addEventListener('click', () => { window.scrollTo({ top: 0, behavior: "smooth" }); }); /*On anime si element visible on scroll*/ const options = { rootMargin: "-200px 0px", threshold: 0 } const observer = new IntersectionObserver(handleIntersect, options); const blocs = document.querySelectorAll('.group_cols, .blocs_prodvideo .bloc_image_plus_text_centre, #container_article, .item_article'); blocs.forEach((bloc) => { observer.observe(bloc); }); document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { e.preventDefault(); document.querySelector(this.getAttribute('href')).scrollIntoView({ behavior: 'smooth' }); }); }); }); function handleIntersect(entries) { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('fadeIn'); } }); } const nextAll = (element) => { const nextElements = []; let nextElement = element; while (nextElement.nextElementSibling) { nextElements.push(nextElement.nextElementSibling); nextElement = nextElement.nextElementSibling; } return nextElements; } function filtres_articles_tags() { $('#bandeau_tags p').on('click', function () { $('#bandeau_tags p').removeClass('active'); $(this).addClass('active'); gestion_filtres(); }); } function gestion_filtres() { $('.item_article').show(); /*Filtres tags articles*/ var tag = $('#bandeau_tags p.active').find('span').html(); if (tag == 'Toutes les réalisations') { $('.item_article').show(); } else { $('.item_article').each(function () { var tag_present = false; $(this).find('.tag_article').each(function () { var tag_article = $(this).find('span').html(); if (tag_article == tag) { tag_present = true; } }); if (tag_present == false) { $(this).closest('.item_article').hide(); } }); } } function getContentArticleAjax(idArticle, item) { const infosArticles = item.querySelector('.infos_article').cloneNode(true); $.ajax({ type: "POST", url: "../articlesimple?id_article=" + idArticle, success: function (data) { $('#contenu_article').remove(); $('.container_bloc_article').after(data); document.querySelector('#contenu_article .group_cols .cols:last-child').prepend(infosArticles); $('#contenu_article .group_cols .cols:last-child').prepend(` `); document.querySelector('body').style.overflow = "hidden"; document.querySelector('.wrapper').style.zIndex = "2"; ferme_contenu_article(); } }); } function ferme_contenu_article() { document.getElementById('close_contenu_article').addEventListener('click', () => { document.getElementById('contenu_article').remove(); document.querySelector('body').style.overflow = "initial"; document.querySelector('.wrapper').style.zIndex = "0"; }); }