diff --git a/web/themes/custom/eql/dist/assets/bundle.js b/web/themes/custom/eql/dist/assets/bundle.js index d24b8d7..086bed6 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

${label}

\n
\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?"); +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 $('.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 \n \n ///// fusion views-type-slide de class identique ////////////\n\n const seen = new Set();\n \n $('.view-type-slide').each(function () {\n const $slide = $(this);\n const classes = $slide.attr('class').split(/\\s+/);\n const typeClass = classes.find(cls => cls.startsWith('type-'));\n \n if (typeClass) {\n if (seen.has(typeClass)) {\n // Trouver le premier slide avec cette classe\n const $target = $('.view-type-slide.' + typeClass).first();\n \n // Déplacer les rows de la slide actuelle vers la première\n $slide.find('.views-row').appendTo($target.find('.views-row-wrapper'));\n \n // Supprimer la slide en double\n $slide.remove();\n } else {\n seen.add(typeClass);\n }\n }\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\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/dist/assets/css/bundle.css b/web/themes/custom/eql/dist/assets/css/bundle.css index 8fab42d..09bace1 100644 --- a/web/themes/custom/eql/dist/assets/css/bundle.css +++ b/web/themes/custom/eql/dist/assets/css/bundle.css @@ -5510,11 +5510,6 @@ svg.ext { padding-bottom: 1rem; } } -.path-ressources .layout-content .region-content #block-contenudelapageprincipale .layout--onecol .layout__region--content .block-region-content .block-views-blockbase-de-donnees-block-1 .view-base-de-donnees .view-ressources-hidden { - visibility: hidden; - height: 0; - overflow: hidden; -} .path-ressources .layout-content .region-content #block-contenudelapageprincipale .layout--onecol .layout__region--content .block-region-content .block-views-blockbase-de-donnees-block-1 .view-base-de-donnees .view-content { transition: opacity 0.3s ease; display: flex; @@ -5522,11 +5517,20 @@ svg.ext { flex-wrap: wrap; width: 100%; } +.path-ressources .layout-content .region-content #block-contenudelapageprincipale .layout--onecol .layout__region--content .block-region-content .block-views-blockbase-de-donnees-block-1 .view-base-de-donnees .view-content .view-type-slide.type-publication-issue-du-programme-eqld { + order: 1; +} +.path-ressources .layout-content .region-content #block-contenudelapageprincipale .layout--onecol .layout__region--content .block-region-content .block-views-blockbase-de-donnees-block-1 .view-base-de-donnees .view-content .view-type-slide.type-paroles-de-laureats { + order: 2; +} +.path-ressources .layout-content .region-content #block-contenudelapageprincipale .layout--onecol .layout__region--content .block-region-content .block-views-blockbase-de-donnees-block-1 .view-base-de-donnees .view-content .view-type-slide.type-presse { + order: 4; +} .path-ressources .layout-content .region-content #block-contenudelapageprincipale .layout--onecol .layout__region--content .block-region-content .block-views-blockbase-de-donnees-block-1 .view-base-de-donnees .view-content .view-type-slide:not(footer) { width: 100%; position: relative; z-index: 0; - padding-bottom: 4rem; + padding-bottom: rem; } .path-ressources .layout-content .region-content #block-contenudelapageprincipale .layout--onecol .layout__region--content .block-region-content .block-views-blockbase-de-donnees-block-1 .view-base-de-donnees .view-content .view-type-slide:not(footer)::before { content: ""; @@ -6337,56 +6341,56 @@ article.node-type-ressource .ext { article.node-type-ressource svg.ext { display: none; } -article.node-type-ressource.type-de-ressource-Publication-issue-du-programme-EQLD .wrapper-ressource { +article.node-type-ressource.type-publication-issue-du-programme-eqld .wrapper-ressource { display: grid; grid-template-columns: 1fr 1.8fr; grid-template-rows: repeat(5 1fr); } -article.node-type-ressource.type-de-ressource-Publication-issue-du-programme-EQLD .wrapper-ressource .field--name-field-type-de-ressource { +article.node-type-ressource.type-publication-issue-du-programme-eqld .wrapper-ressource .field--name-field-type-de-ressource { order: 2; grid-row: 2; margin-bottom: 1rem; } -article.node-type-ressource.type-de-ressource-Publication-issue-du-programme-EQLD .wrapper-ressource .field--name-field-type-de-media { +article.node-type-ressource.type-publication-issue-du-programme-eqld .wrapper-ressource .field--name-field-type-de-media { order: 1; grid-row: 1; } -article.node-type-ressource.type-de-ressource-Publication-issue-du-programme-EQLD .wrapper-ressource .field--name-field-images { +article.node-type-ressource.type-publication-issue-du-programme-eqld .wrapper-ressource .field--name-field-images { order: 3; grid-row: 3/span 5; height: auto; width: 90%; } -article.node-type-ressource.type-de-ressource-Publication-issue-du-programme-EQLD .wrapper-ressource .field--name-field-images img { +article.node-type-ressource.type-publication-issue-du-programme-eqld .wrapper-ressource .field--name-field-images img { height: auto; width: 90%; border: 1px solid #a3a3a3; } -article.node-type-ressource.type-de-ressource-Publication-issue-du-programme-EQLD .wrapper-ressource .field--name-title { +article.node-type-ressource.type-publication-issue-du-programme-eqld .wrapper-ressource .field--name-title { grid-row: 3; margin-top: 0; } -article.node-type-ressource.type-de-ressource-Publication-issue-du-programme-EQLD .wrapper-ressource .field--name-title a { +article.node-type-ressource.type-publication-issue-du-programme-eqld .wrapper-ressource .field--name-title a { color: rgb(0, 158, 227); font-size: 1.2rem; font-style: normal; } -article.node-type-ressource.type-de-ressource-Publication-issue-du-programme-EQLD .wrapper-ressource .field--name-field-sous-titre { +article.node-type-ressource.type-publication-issue-du-programme-eqld .wrapper-ressource .field--name-field-sous-titre { grid-row: 4; color: rgb(0, 158, 227); font-size: 0.8rem; font-weight: 800; } -article.node-type-ressource.type-de-ressource-Publication-issue-du-programme-EQLD .wrapper-ressource .field--name-field-auteur-s- { +article.node-type-ressource.type-publication-issue-du-programme-eqld .wrapper-ressource .field--name-field-auteur-s- { grid-row: 5; } -article.node-type-ressource.type-de-ressource-Publication-issue-du-programme-EQLD .wrapper-ressource .field--name-field-edition { +article.node-type-ressource.type-publication-issue-du-programme-eqld .wrapper-ressource .field--name-field-edition { grid-row: 6; } -article.node-type-ressource.type-de-ressource-Publication-issue-du-programme-EQLD .wrapper-ressource .field--name-field-date-de-parution { +article.node-type-ressource.type-publication-issue-du-programme-eqld .wrapper-ressource .field--name-field-date-de-parution { grid-row: 7; } -article.node-type-ressource.type-de-ressource-Publication-issue-du-programme-EQLD .wrapper-ressource .field--name-field-mots-clefs { +article.node-type-ressource.type-publication-issue-du-programme-eqld .wrapper-ressource .field--name-field-mots-clefs { grid-row: 8; } @media (max-width: 479px) { diff --git a/web/themes/custom/eql/eql.theme b/web/themes/custom/eql/eql.theme index 8bda916..1f07fff 100644 --- a/web/themes/custom/eql/eql.theme +++ b/web/themes/custom/eql/eql.theme @@ -9,7 +9,8 @@ // use Drupal\Core\Url; use Drupal\Component\Utility\Html; use Drupal\Component\Transliteration\TransliterationInterface; - +use Drupal\taxonomy\Entity\Term; +use Drupal\Core\Template\Attribute; function eql_preprocess_html(&$variables) { $node = \Drupal::routeMatch()->getParameter('node'); @@ -41,13 +42,13 @@ function eql_preprocess_node(&$variables){ // $variables['attributes']['class'][] = 'type-de-ressource-' . Html::cleanCssIdentifier($type_de_ressource_name); // } // } - if ($node->getType() === 'ressource' && $node->hasField('field_type_de_ressource') && !$node->get('field_type_de_ressource')->isEmpty()) { - foreach ($node->get('field_type_de_ressource')->referencedEntities() as $term) { - $label = $term->label(); // ex: "Presse" - $class = 'type-' . Html::cleanCssIdentifier(strtolower($label)); - $variables['attributes']['class'][] = $class; - } - } + // if ($node->getType() === 'ressource' && $node->hasField('field_type_de_ressource') && !$node->get('field_type_de_ressource')->isEmpty()) { + // foreach ($node->get('field_type_de_ressource')->referencedEntities() as $term) { + // $label = $term->label(); // ex: "Presse" + // $class = 'type-' . Html::cleanCssIdentifier(strtolower($label)); + // $variables['attributes']['class'][] = $class; + // } + // } } function eql_preprocess_field(&$variables) { @@ -104,29 +105,111 @@ function eql_preprocess_layout__threecol_25_50_25(&$variables) { -function eql_preprocess_views_view_unformatted(&$variables) { - // On utilise le service de translittération de Drupal - $transliterator = \Drupal::service('transliteration'); - foreach ($variables['rows'] as &$row) { - if (isset($row['content']['#node'])) { +// function eql_preprocess_views_view_unformatted(&$variables) { +// // On utilise le service de translittération de Drupal +// $transliterator = \Drupal::service('transliteration'); + +// foreach ($variables['rows'] as &$row) { +// if (isset($row['content']['#node'])) { +// $node = $row['content']['#node']; + +// if ($node->hasField('field_type_de_ressource') && !$node->get('field_type_de_ressource')->isEmpty()) { +// foreach ($node->get('field_type_de_ressource')->referencedEntities() as $term) { +// $label = $term->label(); + +// // Supprimer les accents +// $label_ascii = $transliterator->transliterate($label); + +// // Nettoyer pour que ce soit une classe CSS valide +// $class = 'type-' . Html::cleanCssIdentifier(strtolower($label_ascii)); + +// $row['attributes']->addClass($class); +// } +// } +// } +// } +// } + + + +function eql_preprocess_views_view_unformatted(array &$variables) { + $view = $variables['view']; + + if ($view->id() === 'base_de_donnees') { + + $transliterator = \Drupal::service('transliteration'); + + $allowed_types = [ + 'type-paroles-de-laureats', + 'type-publication-issue-du-programme-eqld', + 'type-presse', + 'type-projets-en-images', + ]; + + $slides = []; + foreach ($allowed_types as $type) { + $slides[$type] = [ + 'label' => ucwords(str_replace(['type-', '-', '---'], ['', ' ', ' / '], $type)), + 'rows' => [], + ]; + } + + $unclassified_rows = []; + + foreach ($variables['rows'] as &$row) { + $matched = FALSE; + + if (!isset($row['content']['#node'])) { + $unclassified_rows[] = $row; + continue; + } + $node = $row['content']['#node']; if ($node->hasField('field_type_de_ressource') && !$node->get('field_type_de_ressource')->isEmpty()) { foreach ($node->get('field_type_de_ressource')->referencedEntities() as $term) { $label = $term->label(); - - // Supprimer les accents $label_ascii = $transliterator->transliterate($label); + $type_class = 'type-' . Html::cleanCssIdentifier(strtolower($label_ascii)); - // Nettoyer pour que ce soit une classe CSS valide - $class = 'type-' . Html::cleanCssIdentifier(strtolower($label_ascii)); + // ✅ Ajoute la classe sur le conteneur .views-row + if (!empty($row['attributes'])) { + $row['attributes']->addClass($type_class); + } - $row['attributes']->addClass($class); + // ✅ Ajoute la classe aussi sur l'article (si tu veux) + // S’assurer que l’article a un attribut HTML + if (!isset($row['content']['#attributes']) || !($row['content']['#attributes'] instanceof Attribute)) { + $row['content']['#attributes'] = new Attribute(); + } + $row['content']['#attributes']->addClass($type_class); + + + if (isset($slides[$type_class])) { + $slides[$type_class]['rows'][] = $row; + $matched = TRUE; + } } } + + if (!$matched) { + $unclassified_rows[] = $row; + } } + + $variables['grouped_rows'] = array_filter($slides, fn($s) => !empty($s['rows'])); + $variables['unclassified_rows'] = $unclassified_rows; + $variables['rows'] = []; } } + + + + + + + + diff --git a/web/themes/custom/eql/scripts/main.js b/web/themes/custom/eql/scripts/main.js index dd1332b..d3a5222 100644 --- a/web/themes/custom/eql/scripts/main.js +++ b/web/themes/custom/eql/scripts/main.js @@ -81,64 +81,7 @@ jQuery(function ($) { settings: { adaptiveHeight: true } }] }); - - // Classes media → .wrapper-ressource - $(".wrapper-ressource").each(function () { - const media = $(this).find(".field--name-field-type-de-media").text().trim(); - const className = media - .toLowerCase() - .normalize("NFD").replace(/[\u0300-\u036f]/g, "") - .replace(/[^a-z0-9]+/g, '-') - .replace(/(^-|-$)/g, ''); - $(this).addClass('type-media-' + className); - }); - console.log("classses media"); - - // SLIDES RECONSTRUCTION LORS DU CHARGEMENT COMPLET - $(window).on('load', function () { - const $viewContent = $('.path-ressources .view-content').first(); - if ($viewContent.length === 0) return; - $viewContent.addClass('view-ressources-hidden'); - console.log($viewContent); - - - const allowedTypes = [ - 'type-publication-issue-du-programme-eqld', - 'type-paroles-de-laureats', - 'type-les-projets-en-images', - 'type-presse' - ]; - - // const $viewContent = $('.view-content'); - const allRows = $('.path-ressources .view-base-de-donnees .views-row').detach(); - function toLabel(str) { - return str.replace('type-', '').replace(/-/g, ' ').replace(/\b\w/g, l => l.toUpperCase()); - } - allowedTypes.forEach(type => { - const label = toLabel(type); - const $slide = $(` -
-

${label}

-
-
- `); - $viewContent.append($slide); - console.log(allowedTypes); - - }); - - allRows.each(function () { - const $row = $(this); - const classList = $row.attr('class').split(/\s+/); - classList.forEach(cls => { - if (allowedTypes.includes(cls)) { - $(`.view-type-slide.${cls} .views-row-wrapper`).append($row.clone(true, true)); - } - }); - console.log(classList); - - }); - + $('.path-ressources .view:not(.view-partenaires) .view-content .view-type-slide .views-row-wrapper').slick({ slidesToShow: 3, dots: false, @@ -155,19 +98,47 @@ jQuery(function ($) { } }] }); - // Supprimer les .view-type-slide originales générées par Drupal (vides ou non autorisées) - $('.path-ressources .view-base-de-donnees .view-type-slide').each(function () { - const classes = $(this).attr('class').split(/\s+/); - const isCustom = classes.some(cls => allowedTypes.includes(cls)); - if (!isCustom) { - $(this).remove(); - } - console.log(classes); - }); - - $viewContent.removeClass('view-ressources-hidden'); + + + ///// fusion views-type-slide de class identique //////////// + const seen = new Set(); + + $('.view-type-slide').each(function () { + const $slide = $(this); + const classes = $slide.attr('class').split(/\s+/); + const typeClass = classes.find(cls => cls.startsWith('type-')); + + if (typeClass) { + if (seen.has(typeClass)) { + // Trouver le premier slide avec cette classe + const $target = $('.view-type-slide.' + typeClass).first(); + + // Déplacer les rows de la slide actuelle vers la première + $slide.find('.views-row').appendTo($target.find('.views-row-wrapper')); + + // Supprimer la slide en double + $slide.remove(); + } else { + seen.add(typeClass); + } + } + }); + + + // Classes media → .wrapper-ressource + $(".wrapper-ressource").each(function () { + const media = $(this).find(".field--name-field-type-de-media").text().trim(); + const className = media + .toLowerCase() + .normalize("NFD").replace(/[\u0300-\u036f]/g, "") + .replace(/[^a-z0-9]+/g, '-') + .replace(/(^-|-$)/g, ''); + $(this).addClass('type-media-' + className); }); + console.log("classses media"); + + // Ouvrir les liens externes dans un nouvel onglet document.querySelectorAll('a[href^="http"]').forEach(link => { diff --git a/web/themes/custom/eql/scss/pages/ressources.scss b/web/themes/custom/eql/scss/pages/ressources.scss index 731c7c0..955fec6 100644 --- a/web/themes/custom/eql/scss/pages/ressources.scss +++ b/web/themes/custom/eql/scss/pages/ressources.scss @@ -275,22 +275,27 @@ } - .view-ressources-hidden { - visibility: hidden; - height: 0; - overflow: hidden; - } + // .view-ressources-hidden { + // visibility: hidden; + // height: 0; + // overflow: hidden; + // } .view-content{ transition: opacity 0.3s ease; display: flex; flex-direction: row; flex-wrap: wrap; width: 100%; + .view-type-slide.type-publication-issue-du-programme-eqld{ + order: 1; + } + .view-type-slide.type-paroles-de-laureats{order: 2;} + .view-type-slide.type-presse{order: 4;} .view-type-slide:not(footer){ width: 100%; position: relative; z-index: 0; - padding-bottom: 4rem; + padding-bottom: rem; &::before { content: ""; position: absolute; diff --git a/web/themes/custom/eql/scss/partials/_node-type-ressource-teaser.scss b/web/themes/custom/eql/scss/partials/_node-type-ressource-teaser.scss index 31eea2a..3887f92 100644 --- a/web/themes/custom/eql/scss/partials/_node-type-ressource-teaser.scss +++ b/web/themes/custom/eql/scss/partials/_node-type-ressource-teaser.scss @@ -9,7 +9,7 @@ article.node-type-ressource{ svg.ext{ display: none; } - &.type-de-ressource-Publication-issue-du-programme-EQLD{ + &.type-publication-issue-du-programme-eqld{ // background-color: $background-actus; .wrapper-ressource{ display: grid; diff --git a/web/themes/custom/eql/templates/partials/form.html.twig b/web/themes/custom/eql/templates/partials/form.html.twig index 7d41d59..ac95695 100644 --- a/web/themes/custom/eql/templates/partials/form.html.twig +++ b/web/themes/custom/eql/templates/partials/form.html.twig @@ -13,14 +13,14 @@ */ #}
- + - + - - - - + + + +
diff --git a/web/themes/custom/eql/templates/views-view-unformatted--base-de-donnees.html.twig b/web/themes/custom/eql/templates/views-view-unformatted--base-de-donnees.html.twig new file mode 100644 index 0000000..10fd936 --- /dev/null +++ b/web/themes/custom/eql/templates/views-view-unformatted--base-de-donnees.html.twig @@ -0,0 +1,43 @@ +{# +/** + * @file + * Theme override to display a view of unformatted rows. + * + * Available variables: + * - title: The title of this group of rows. May be empty. + * - rows: A list of the view's row items. + * - attributes: The row's HTML attributes. + * - content: The row's content. + * - view: The view object. + * - default_row_class: A flag indicating whether default classes should be + * used on rows. + * + * @see template_preprocess_views_view_unformatted() + */ +#} + +{% + set view_wrapper_class = [ + default_row_class ? 'views-row-wrapper', + ] +%} +{% if grouped_rows is defined %} + {% for type_class, group in grouped_rows %} +
+

{{ group.label }}

+
+ {% for row in group.rows %} + + {{ row.content }} +
+ {% endfor %} +
+ + {% endfor %} +{% else %} + {% for row in rows %} + + {{ row.content }} + + {% endfor %} +{% endif %} diff --git a/web/themes/custom/eql/templates/views-view.html.twig b/web/themes/custom/eql/templates/views-view.html.twig index 8b276ae..24f2e6e 100644 --- a/web/themes/custom/eql/templates/views-view.html.twig +++ b/web/themes/custom/eql/templates/views-view.html.twig @@ -66,9 +66,9 @@ {% if rows %} {% set content_classes = ['view-content'] %} - {% if view.id == 'base_de_donnees' %} + {# {% if view.id == 'base_de_donnees' %} {% set content_classes = content_classes|merge(['view-ressources-hidden']) %} - {% endif %} + {% endif %} #} {{ rows }}