carte interactive sur page node projet

This commit is contained in:
2025-11-25 17:04:11 +01:00
parent ed3e38a2ce
commit f05fee5e4c
3 changed files with 35 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ const isHomePage = document.querySelector('main#home') !== null;
const isLessitesPage = document.querySelector('div#lessites') !== null; const isLessitesPage = document.querySelector('div#lessites') !== null;
const isNodeTypeSitePage = document.body.classList.contains('node-type-site'); const isNodeTypeSitePage = document.body.classList.contains('node-type-site');
const isCandidaturePage = document.querySelector('main#pour_candidater') !== null; const isCandidaturePage = document.querySelector('main#pour_candidater') !== null;
const isNodeTypeProjetPage = document.body.classList.contains('node-type-projet');
// Identifier le cercle de la page courante pour node-type-site // Identifier le cercle de la page courante pour node-type-site
let currentPageCircle = null; let currentPageCircle = null;
@@ -25,6 +26,30 @@ if (isNodeTypeSitePage) {
} }
} }
} }
// Identifier le cercle du SITE lié quand on est sur une page node-type-projet
if (isNodeTypeProjetPage && svgElement) {
// On récupère le lien vers le site lié dans le bloc "Site lié"
const linkedSiteLink = document.querySelector('.field_field_site_projet article.node-type-site a[href*="/sites/"]');
if (linkedSiteLink) {
// On normalise le chemin (sans domaine) de l'URL du site
const sitePath = new URL(linkedSiteLink.getAttribute('href'), window.location.origin).pathname;
// On cherche le cercle dont le data-url pointe vers le même site
const correspondingCircle = Array.from(svgElement.querySelectorAll('circle.site-link')).find(circle => {
const circleUrl = circle.getAttribute('data-url');
if (!circleUrl) return false;
const circlePath = new URL(circleUrl, window.location.origin).pathname;
return circlePath === sitePath;
});
if (correspondingCircle) {
currentPageCircle = correspondingCircle;
currentPageCircle.setAttribute('fill', 'red'); // Met en rouge le cercle du site lié
}
}
}
// Fonction pour afficher le popup // Fonction pour afficher le popup
@@ -123,6 +148,14 @@ svgElement.addEventListener('click', function(event) {
} }
} }
} }
if (isNodeTypeProjetPage) {
if (event.target.classList.contains('site-link')) {
const targetUrl = event.target.getAttribute('data-url');
if (targetUrl) {
window.location.href = targetUrl; // Redirige vers le data-url correspondant
}
}
}
}); });
// Fonction pour gérer l'agrandissement de views-row au survol des cercles // Fonction pour gérer l'agrandissement de views-row au survol des cercles

View File

@@ -4337,6 +4337,7 @@ body {
} }
.node-type-projet .layout--threecol-25-50-25 .layout__region--first .block-region-first .field_field_site_projet .node-type-site .more-link { .node-type-projet .layout--threecol-25-50-25 .layout__region--first .block-region-first .field_field_site_projet .node-type-site .more-link {
width: fit-content; width: fit-content;
display: inline-flex;
background: black; background: black;
} }
@media (max-width: 810px) { @media (max-width: 810px) {

View File

@@ -71,6 +71,7 @@
} }
.more-link{ .more-link{
width: fit-content; width: fit-content;
display: inline-flex;
// padding-left: 0.5rem; // padding-left: 0.5rem;
background: black; background: black;
@media (max-width:810px) { @media (max-width:810px) {