diff --git a/dist/js/embedded-content-cookie-compliance.min.js b/dist/js/embedded-content-cookie-compliance.min.js index 3a44ac64d..e0054eaa9 100644 --- a/dist/js/embedded-content-cookie-compliance.min.js +++ b/dist/js/embedded-content-cookie-compliance.min.js @@ -1 +1 @@ -!function(e,Drupal,drupalSettings){const t=()=>{if(Drupal.cookieConsent.getConsentStatus(["preferences","statistics"])&&drupalSettings.embedded_media_attributes)for(const[t,n]of Object.entries(drupalSettings.embedded_media_attributes)){const i=document.createElement("iframe");i.classList.add("media-oembed-content"),i.src=n.src,i.title=n.title,n.height&&(i.height=n.height),n.width&&(i.width=n.width);const a=document.createElement("a");a.classList.add("focusable","skip-link"),a.href=`#${n.skipLinkAfterId}`,a.id=n.skipLinkBeforeId;const o=document.createElement("a");o.classList.add("focusable","skip-link"),o.href=`#${n.skipLinkBeforeId}`,o.id=n.skipLinkAfterId;const r=document.createElement("div");r.appendChild(i),"video"===n.type?(r.classList.add("responsive-video-container"),e(`.embedded-content-cookie-compliance.media-${t}`).empty().append(r).removeClass(`media-${t}`)):"map"===n.type?(r.classList.add("responsive-map-container"),o.classList.add("skip-link--map--after"),a.classList.add("skip-link--map--before"),o.text=Drupal.t("Continue above the map",{},{context:"Skip link after the map for the map paragraph"}),a.text=Drupal.t("Continue below the map",{},{context:"Skip link before the map for the map paragraph"}),e(`.embedded-content-cookie-compliance.media-${t}`).replaceWith(a,r,o)):"journey_planner"===n.type&&(r.classList.add("journey-planner-container"),o.classList.add("skip-link--planner--after"),a.classList.add("skip-link--planner--before"),o.text=Drupal.t("Continue above the journey planner",{},{context:"Skip link after the journey planner for the journey planner paragraph"}),a.text=Drupal.t("Continue below the journey planner",{},{context:"Skip link before the journey planner for the journey planner paragraph"}),e(`.embedded-content-cookie-compliance.media-${t}`).replaceWith(a,r,o))}};e(".embedded-content-cookie-compliance .js-remove").remove(),Drupal.cookieConsent.initialized()?t():Drupal.cookieConsent.loadFunction(t)}(jQuery,Drupal,drupalSettings); \ No newline at end of file +!function(e,Drupal,drupalSettings){const t=()=>{if(Drupal.cookieConsent.getConsentStatus(["preferences","statistics"])&&drupalSettings.embedded_media_attributes)for(const[t,n]of Object.entries(drupalSettings.embedded_media_attributes)){const a=document.createElement("iframe");a.classList.add("media-oembed-content"),a.src=n.src,a.title=n.title,n.height&&(a.height=n.height),n.width&&(a.width=n.width);const i=document.createElement("a");i.classList.add("focusable","skip-link"),i.href=`#${n.skipLinkAfterId}`,i.id=n.skipLinkBeforeId;const o=document.createElement("a");o.classList.add("focusable","skip-link"),o.href=`#${n.skipLinkBeforeId}`,o.id=n.skipLinkAfterId;const r=document.createElement("div");if(r.appendChild(a),"map"===n.type){const n=e(`.embedded-content-cookie-compliance.media-${t}`),a=n.parent().prevAll("h2").first().text().trim()||"";r.classList.add("responsive-map-container"),o.classList.add("skip-link--map--after"),i.classList.add("skip-link--map--before"),o.text=a?Drupal.t("Continue above the @map map",{"@map":a},{context:"Skip link after the map for the map paragraph"}):Drupal.t("Continue above the map",{},{context:"Skip link after the map for the map paragraph"}),i.text=a?Drupal.t("Continue below the @map map",{"@map":a},{context:"Skip link before the map for the map paragraph"}):Drupal.t("Continue below the map",{},{context:"Skip link before the map for the map paragraph"}),n.replaceWith(i,r,o)}else"journey_planner"===n.type&&(r.classList.add("journey-planner-container"),o.classList.add("skip-link--planner--after"),i.classList.add("skip-link--planner--before"),o.text=Drupal.t("Continue above the journey planner",{},{context:"Skip link after the journey planner for the journey planner paragraph"}),i.text=Drupal.t("Continue below the journey planner",{},{context:"Skip link before the journey planner for the journey planner paragraph"}),e(`.embedded-content-cookie-compliance.media-${t}`).replaceWith(i,r,o))}};e(".embedded-content-cookie-compliance .js-remove").remove(),Drupal.cookieConsent.initialized()?t():Drupal.cookieConsent.loadFunction(t)}(jQuery,Drupal,drupalSettings); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 1361bd782..71871c684 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7190,9 +7190,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001696", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001696.tgz", - "integrity": "sha512-pDCPkvzfa39ehJtJ+OwGT/2yvT2SbjfHhiIW2LWOAcMQ7BzwxT/XuyUp4OTOd0XFWA6BKw0JalnBHgSi5DGJBQ==", + "version": "1.0.30001697", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001697.tgz", + "integrity": "sha512-GwNPlWJin8E+d7Gxq96jxM6w0w+VFeyyXRsjU58emtkYqnbwHqXm5uT2uCmO0RQE9htWknOP4xtBlLmM/gWxvQ==", "funding": [ { "type": "opencollective", diff --git a/src/js/embedded-content-cookie-compliance.js b/src/js/embedded-content-cookie-compliance.js index 13f285003..d8d8691e6 100644 --- a/src/js/embedded-content-cookie-compliance.js +++ b/src/js/embedded-content-cookie-compliance.js @@ -4,7 +4,6 @@ */ // eslint-disable-next-line func-names (function ($, Drupal, drupalSettings) { - const loadEmbeddedContent = () => { if ( Drupal.cookieConsent.getConsentStatus(['preferences', 'statistics']) && @@ -28,7 +27,6 @@ skipLinkBefore.href = `#${attributes.skipLinkAfterId}`; skipLinkBefore.id = attributes.skipLinkBeforeId; - const skipLinkAfter = document.createElement('a'); skipLinkAfter.classList.add('focusable', 'skip-link'); skipLinkAfter.href = `#${attributes.skipLinkBeforeId}`; @@ -36,20 +34,28 @@ const containerElement = document.createElement('div'); containerElement.appendChild(iframeElement); - if (attributes.type === 'video') { - containerElement.classList.add('responsive-video-container'); - $(`.embedded-content-cookie-compliance.media-${id}`) - .empty() - .append(containerElement) - .removeClass(`media-${id}`); - } else if (attributes.type === 'map') { + + if (attributes.type === 'map') { + const $mapContainer = $(`.embedded-content-cookie-compliance.media-${id}`); + + // Extract the map name from the wrapping component element. + // Fallback to empty if no title is set. + const mapName = $mapContainer.parent().prevAll('h2').first().text().trim() || ''; + containerElement.classList.add('responsive-map-container'); skipLinkAfter.classList.add('skip-link--map--after'); skipLinkBefore.classList.add('skip-link--map--before'); - skipLinkAfter.text = Drupal.t('Continue above the map', {}, { context: 'Skip link after the map for the map paragraph' }); - skipLinkBefore.text = Drupal.t('Continue below the map', {}, { context: 'Skip link before the map for the map paragraph' }); - $(`.embedded-content-cookie-compliance.media-${id}`) - .replaceWith(skipLinkBefore, containerElement, skipLinkAfter); + + // Adjust the skip link text based on whether mapName is found. + skipLinkAfter.text = mapName + ? Drupal.t('Continue above the @map map', { '@map': mapName }, { context: 'Skip link after the map for the map paragraph' }) + : Drupal.t('Continue above the map', {}, { context: 'Skip link after the map for the map paragraph' }); + + skipLinkBefore.text = mapName + ? Drupal.t('Continue below the @map map', { '@map': mapName }, { context: 'Skip link before the map for the map paragraph' }) + : Drupal.t('Continue below the map', {}, { context: 'Skip link before the map for the map paragraph' }); + + $mapContainer.replaceWith(skipLinkBefore, containerElement, skipLinkAfter); } else if (attributes.type === 'journey_planner') { containerElement.classList.add('journey-planner-container'); skipLinkAfter.classList.add('skip-link--planner--after'); diff --git a/translations/fi.po b/translations/fi.po index f776bd639..eefacdfd1 100644 --- a/translations/fi.po +++ b/translations/fi.po @@ -487,6 +487,14 @@ msgctxt "Skip link before the map for the map paragraph" msgid "Continue below the map" msgstr "Siirry kartan alapuolelle" +msgctxt "Skip link after the map for the map paragraph" +msgid "Continue above the @map map" +msgstr "Siirry kartan @map yläpuolelle" + +msgctxt "Skip link before the map for the map paragraph" +msgid "Continue below the @map map" +msgstr "Siirry kartan @map alapuolelle" + msgctxt "District and project search" msgid "districts" msgstr "aluetta" diff --git a/translations/sv.po b/translations/sv.po index b07134dba..43b6614c3 100644 --- a/translations/sv.po +++ b/translations/sv.po @@ -485,6 +485,14 @@ msgctxt "Skip link before the map for the map paragraph" msgid "Continue below the map" msgstr "Gå förbi kartan nedåt" +msgctxt "Skip link after the map for the map paragraph" +msgid "Continue above the @map map" +msgstr "Gå förbi kartan @map uppåt" + +msgctxt "Skip link before the map for the map paragraph" +msgid "Continue below the @map map" +msgstr "Gå förbi kartan @map nedåt" + msgctxt "District and project search" msgid "districts" msgstr "områden"