diff --git a/web/themes/custom/eql/dist/assets/bundle.js b/web/themes/custom/eql/dist/assets/bundle.js index b4c5492..d24b8d7 100644 --- a/web/themes/custom/eql/dist/assets/bundle.js +++ b/web/themes/custom/eql/dist/assets/bundle.js @@ -36,7 +36,7 @@ eval("/**\n * @file\n * External links js file.\n */\n\n (function ($, Drupal, d \*************************/ /***/ (function() { -eval("jQuery(function ($) {\n console.log('salut');\n\n // MENU BURGER\n const burger = document.getElementById(\"block-burger\");\n const burgertitle = document.getElementById(\"block-burger-menu\");\n if (burger && burgertitle) {\n burgertitle.addEventListener(\"click\", function () {\n burger.classList.toggle('opened');\n });\n }\n\n // FAQ — réponses\n const answers = document.getElementsByClassName(\"field--name-field-reponse\");\n const fichiers = document.getElementsByClassName(\"field--name-field-fichiers\");\n const liens = document.getElementsByClassName(\"field--name-field-liens\");\n const ressources = document.getElementsByClassName(\"field--name-field-ress\");\n const questions = document.getElementsByClassName(\"field--name-field-question\");\n\n for (let i = 0; i < questions.length; i++) {\n const q = questions[i];\n q.addEventListener(\"click\", function () {\n // Réponses\n Array.from(answers).forEach(a => a.classList.remove(\"opened\"));\n const r = this.parentNode.querySelector(\".field--name-field-reponse\");\n if (r) r.classList.add(\"opened\");\n\n // Fichiers\n Array.from(fichiers).forEach(f => f.classList.remove(\"opened\"));\n const f = this.parentNode.querySelector(\".field--name-field-fichiers\");\n if (f) f.classList.add(\"opened\");\n\n // Liens\n Array.from(liens).forEach(l => l.classList.remove(\"opened\"));\n const l = this.parentNode.querySelector(\".field--name-field-liens\");\n if (l) l.classList.add(\"opened\");\n\n // Ressources\n Array.from(ressources).forEach(r => r.classList.remove(\"opened\"));\n const res = this.parentNode.querySelector(\".field--name-field-ress\");\n if (res) res.classList.add(\"opened\");\n });\n }\n\n // SLIDESHOW INIT\n $('.path-frontpage .view-actus-blocks-pages .view-content .view-type-slide .views-row-wrapper').slick({\n slidesToShow: 1,\n dots: true,\n arrows: true,\n centerMode: true,\n responsive: [{\n breakpoint: 810,\n settings: {\n slidesToShow: 1,\n adaptiveHeight: true,\n arrows: false,\n draggable: true,\n centerMode: true,\n }\n }]\n });\n\n $('.page-node-type-actualite .block-entity-fieldnodefield-images .field--type-image').slick({\n dots: true,\n arrows: true,\n adaptiveHeight: true,\n responsive: [{\n breakpoint: 800,\n settings: { adaptiveHeight: true }\n }]\n });\n\n $('.page-node-type-projet .block-entity-fieldnodefield-photo .field--type-image').slick({\n slidesToShow: 1,\n dots: true,\n arrows: false,\n draggable: true,\n adaptiveHeight: true,\n responsive: [{\n breakpoint: 800,\n settings: { adaptiveHeight: true }\n }]\n });\n\n // Classes media → .wrapper-ressource\n $(\".wrapper-ressource\").each(function () {\n const media = $(this).find(\".field--name-field-type-de-media\").text().trim();\n const className = media\n .toLowerCase()\n .normalize(\"NFD\").replace(/[\\u0300-\\u036f]/g, \"\")\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/(^-|-$)/g, '');\n $(this).addClass('type-media-' + className);\n });\n console.log(\"classses media\");\n\n // SLIDES RECONSTRUCTION LORS DU CHARGEMENT COMPLET\n $(window).on('load', function () {\n const $viewContent = $('.path-ressources .view-content').first();\n if ($viewContent.length === 0) return;\n $viewContent.addClass('view-ressources-hidden');\n console.log($viewContent);\n\n\n const allowedTypes = [\n 'type-publication-issue-du-programme-eqld',\n 'type-paroles-de-laureats',\n 'type-les-projets-en-images',\n 'type-presse'\n ];\n\n // const $viewContent = $('.view-content');\n const allRows = $('.path-ressources .view-base-de-donnees .views-row').detach();\n function toLabel(str) {\n return str.replace('type-', '').replace(/-/g, ' ').replace(/\\b\\w/g, l => l.toUpperCase());\n } \n allowedTypes.forEach(type => {\n const label = toLabel(type); \n const $slide = $(`\n
\n `);\n $viewContent.append($slide);\n console.log(allowedTypes);\n\n });\n\n allRows.each(function () {\n const $row = $(this);\n const classList = $row.attr('class').split(/\\s+/);\n classList.forEach(cls => {\n if (allowedTypes.includes(cls)) {\n $(`.view-type-slide.${cls} .views-row-wrapper`).append($row.clone(true, true));\n }\n });\n console.log(classList);\n\n });\n\n $('.path-ressources .view:not(.view-partenaires) .view-content .view-type-slide .views-row-wrapper').slick({\n slidesToShow: 3,\n dots: false,\n arrows: true,\n infinite: false,\n centerMode: false,\n responsive: [{\n breakpoint: 810,\n settings: {\n slidesToShow: 3,\n arrows: false,\n draggable: true,\n centerMode: true,\n }\n }]\n });\n // Supprimer les .view-type-slide originales générées par Drupal (vides ou non autorisées)\n $('.path-ressources .view-base-de-donnees .view-type-slide').each(function () {\n const classes = $(this).attr('class').split(/\\s+/);\n const isCustom = classes.some(cls => allowedTypes.includes(cls));\n if (!isCustom) {\n $(this).remove();\n }\n console.log(classes);\n });\n \n $viewContent.removeClass('view-ressources-hidden');\n\n });\n\n // Ouvrir les liens externes dans un nouvel onglet\n document.querySelectorAll('a[href^=\"http\"]').forEach(link => {\n if (!link.href.includes(location.hostname)) {\n link.setAttribute('target', '_blank');\n link.setAttribute('rel', 'noopener noreferrer');\n }\n });\n\n // Scroll automatique au filtre\n const form = document.querySelector(\".views-exposed-form\");\n if (form) form.setAttribute(\"action\", form.action.split(\"#\")[0] + \"#filtres\");\n\n if (window.location.hash === \"#filtres\") {\n const target = document.getElementById(\"filtres\");\n if (target) {\n const offset = 300;\n const top = target.getBoundingClientRect().top + window.pageYOffset - offset;\n window.scrollTo({ top: top, behavior: \"smooth\" });\n }\n }\n\n // MASQUER TYPE DE RESSOURCE DOUBLON\n $(\".view-type-slide\").each(function () {\n const h3Content = $(this).find(\"h3\").text().trim();\n $(this).find(\".field--name-field-type-de-ressource\").each(function () {\n if ($(this).text().trim() === h3Content) {\n $(this).hide();\n }\n });\n });\n});\n\n\n//# sourceURL=webpack://dev.eql.fr/./scripts/main.js?"); +eval("jQuery(function ($) {\n console.log('salut');\n\n // MENU BURGER\n const burger = document.getElementById(\"block-burger\");\n const burgertitle = document.getElementById(\"block-burger-menu\");\n if (burger && burgertitle) {\n burgertitle.addEventListener(\"click\", function () {\n burger.classList.toggle('opened');\n });\n }\n\n // FAQ — réponses\n const answers = document.getElementsByClassName(\"field--name-field-reponse\");\n const fichiers = document.getElementsByClassName(\"field--name-field-fichiers\");\n const liens = document.getElementsByClassName(\"field--name-field-liens\");\n const ressources = document.getElementsByClassName(\"field--name-field-ress\");\n const questions = document.getElementsByClassName(\"field--name-field-question\");\n\n for (let i = 0; i < questions.length; i++) {\n const q = questions[i];\n q.addEventListener(\"click\", function () {\n // Réponses\n Array.from(answers).forEach(a => a.classList.remove(\"opened\"));\n const r = this.parentNode.querySelector(\".field--name-field-reponse\");\n if (r) r.classList.add(\"opened\");\n\n // Fichiers\n Array.from(fichiers).forEach(f => f.classList.remove(\"opened\"));\n const f = this.parentNode.querySelector(\".field--name-field-fichiers\");\n if (f) f.classList.add(\"opened\");\n\n // Liens\n Array.from(liens).forEach(l => l.classList.remove(\"opened\"));\n const l = this.parentNode.querySelector(\".field--name-field-liens\");\n if (l) l.classList.add(\"opened\");\n\n // Ressources\n Array.from(ressources).forEach(r => r.classList.remove(\"opened\"));\n const res = this.parentNode.querySelector(\".field--name-field-ress\");\n if (res) res.classList.add(\"opened\");\n });\n }\n\n // SLIDESHOW INIT\n $('.path-frontpage .view-actus-blocks-pages .view-content .view-type-slide .views-row-wrapper').slick({\n slidesToShow: 1,\n dots: true,\n arrows: true,\n centerMode: true,\n responsive: [{\n breakpoint: 810,\n settings: {\n slidesToShow: 1,\n adaptiveHeight: true,\n arrows: false,\n draggable: true,\n centerMode: true,\n }\n }]\n });\n\n $('.page-node-type-actualite .block-entity-fieldnodefield-images .field--type-image').slick({\n dots: true,\n arrows: true,\n adaptiveHeight: true,\n responsive: [{\n breakpoint: 800,\n settings: { adaptiveHeight: true }\n }]\n });\n\n $('.page-node-type-projet .block-entity-fieldnodefield-photo .field--type-image').slick({\n slidesToShow: 1,\n dots: true,\n arrows: false,\n draggable: true,\n adaptiveHeight: true,\n responsive: [{\n breakpoint: 800,\n settings: { adaptiveHeight: true }\n }]\n });\n\n // Classes media → .wrapper-ressource\n $(\".wrapper-ressource\").each(function () {\n const media = $(this).find(\".field--name-field-type-de-media\").text().trim();\n const className = media\n .toLowerCase()\n .normalize(\"NFD\").replace(/[\\u0300-\\u036f]/g, \"\")\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/(^-|-$)/g, '');\n $(this).addClass('type-media-' + className);\n });\n console.log(\"classses media\");\n\n // SLIDES RECONSTRUCTION LORS DU CHARGEMENT COMPLET\n $(window).on('load', function () {\n const $viewContent = $('.path-ressources .view-content').first();\n if ($viewContent.length === 0) return;\n $viewContent.addClass('view-ressources-hidden');\n console.log($viewContent);\n\n\n const allowedTypes = [\n 'type-publication-issue-du-programme-eqld',\n 'type-paroles-de-laureats',\n 'type-les-projets-en-images',\n 'type-presse'\n ];\n\n // const $viewContent = $('.view-content');\n const allRows = $('.path-ressources .view-base-de-donnees .views-row').detach();\n function toLabel(str) {\n return str.replace('type-', '').replace(/-/g, ' ').replace(/\\b\\w/g, l => l.toUpperCase());\n } \n allowedTypes.forEach(type => {\n const label = toLabel(type); \n const $slide = $(`\n \n `);\n $viewContent.append($slide);\n console.log(allowedTypes);\n\n });\n\n allRows.each(function () {\n const $row = $(this);\n const classList = $row.attr('class').split(/\\s+/);\n classList.forEach(cls => {\n if (allowedTypes.includes(cls)) {\n $(`.view-type-slide.${cls} .views-row-wrapper`).append($row.clone(true, true));\n }\n });\n console.log(classList);\n\n });\n\n $('.path-ressources .view:not(.view-partenaires) .view-content .view-type-slide .views-row-wrapper').slick({\n slidesToShow: 3,\n dots: false,\n arrows: true,\n infinite: false,\n centerMode: false,\n responsive: [{\n breakpoint: 810,\n settings: {\n slidesToShow: 3,\n arrows: false,\n draggable: true,\n centerMode: true,\n }\n }]\n });\n // Supprimer les .view-type-slide originales générées par Drupal (vides ou non autorisées)\n $('.path-ressources .view-base-de-donnees .view-type-slide').each(function () {\n const classes = $(this).attr('class').split(/\\s+/);\n const isCustom = classes.some(cls => allowedTypes.includes(cls));\n if (!isCustom) {\n $(this).remove();\n }\n console.log(classes);\n });\n \n $viewContent.removeClass('view-ressources-hidden');\n\n });\n\n // Ouvrir les liens externes dans un nouvel onglet\n document.querySelectorAll('a[href^=\"http\"]').forEach(link => {\n if (!link.href.includes(location.hostname)) {\n link.setAttribute('target', '_blank');\n link.setAttribute('rel', 'noopener noreferrer');\n }\n });\n\n // Scroll automatique au filtre\n if (document.body.classList.contains(\"path-projets\")) {\n const form = document.querySelector(\".views-exposed-form\");\n if (form) form.setAttribute(\"action\", form.action.split(\"#\")[0] + \"#filtres\");\n\n if (window.location.hash === \"#filtres\") {\n const target = document.getElementById(\"filtres\");\n if (target) {\n const offset = 300;\n const top = target.getBoundingClientRect().top + window.pageYOffset - offset;\n window.scrollTo({ top: top, behavior: \"smooth\" });\n }\n }\n\n // MASQUER TYPE DE RESSOURCE DOUBLON\n $(\".view-type-slide\").each(function () {\n const h3Content = $(this).find(\"h3\").text().trim();\n $(this).find(\".field--name-field-type-de-ressource\").each(function () {\n if ($(this).text().trim() === h3Content) {\n $(this).hide();\n }\n });\n });\n }\n});\n\n\n//# sourceURL=webpack://dev.eql.fr/./scripts/main.js?"); /***/ }) diff --git a/web/themes/custom/eql/scripts/main.js b/web/themes/custom/eql/scripts/main.js index 736dec5..dd1332b 100644 --- a/web/themes/custom/eql/scripts/main.js +++ b/web/themes/custom/eql/scripts/main.js @@ -178,25 +178,27 @@ jQuery(function ($) { }); // Scroll automatique au filtre - const form = document.querySelector(".views-exposed-form"); - if (form) form.setAttribute("action", form.action.split("#")[0] + "#filtres"); + if (document.body.classList.contains("path-projets")) { + const form = document.querySelector(".views-exposed-form"); + if (form) form.setAttribute("action", form.action.split("#")[0] + "#filtres"); - if (window.location.hash === "#filtres") { - const target = document.getElementById("filtres"); - if (target) { - const offset = 300; - const top = target.getBoundingClientRect().top + window.pageYOffset - offset; - window.scrollTo({ top: top, behavior: "smooth" }); - } - } - - // MASQUER TYPE DE RESSOURCE DOUBLON - $(".view-type-slide").each(function () { - const h3Content = $(this).find("h3").text().trim(); - $(this).find(".field--name-field-type-de-ressource").each(function () { - if ($(this).text().trim() === h3Content) { - $(this).hide(); + if (window.location.hash === "#filtres") { + const target = document.getElementById("filtres"); + if (target) { + const offset = 300; + const top = target.getBoundingClientRect().top + window.pageYOffset - offset; + window.scrollTo({ top: top, behavior: "smooth" }); } + } + + // MASQUER TYPE DE RESSOURCE DOUBLON + $(".view-type-slide").each(function () { + const h3Content = $(this).find("h3").text().trim(); + $(this).find(".field--name-field-type-de-ressource").each(function () { + if ($(this).text().trim() === h3Content) { + $(this).hide(); + } + }); }); - }); + } });