Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UHF-X Embedded content cookie fix #831

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/css/styles.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/embedded-content-cookie-compliance.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 21 additions & 11 deletions hdbt.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ hdbt-icons:
dist/css/hdbt-icons.css: {}

embedded-content-cookie-compliance:
version: 1.x
version: 1.0
js:
dist/js/embedded-content-cookie-compliance.min.js: {}
dependencies:
Expand Down Expand Up @@ -141,18 +141,22 @@ nav-global:
- hdbt/nav-toggle

event-list:
version: 1.x
version: 1.0
js:
dist/js/linkedevents.min.js: {}
dist/js/linkedevents.min.js: {
preprocess: false
}
dependencies:
- core/drupalSettings
- core/jquery
- core/drupal

school-search:
version: 1.x
version: 1.0
js:
dist/js/school-search.min.js: {}
dist/js/school-search.min.js: {
preprocess: false
}
dependencies:
- core/drupalSettings
- core/drupal
Expand All @@ -169,25 +173,31 @@ hyphenopoly:
}

job-search:
version: 1.x
version: 1.0
js:
dist/js/job-search.min.js: {}
dist/js/job-search.min.js: {
preprocess: false
}
dependencies:
- core/drupalSettings
- core/drupal

district-and-project-search:
version: 1.x
version: 1.0
js:
dist/js/district-and-project-search.min.js: {}
dist/js/district-and-project-search.min.js: {
preprocess: false
}
dependencies:
- core/drupalSettings
- core/drupal

news-archive:
version: 1.x
version: 1.0
js:
dist/js/news-archive.min.js: {}
dist/js/news-archive.min.js: {
preprocess: false
}
dependencies:
- core/drupalSettings
- core/drupal
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions src/js/embedded-content-cookie-compliance.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@
// eslint-disable-next-line func-names
(function ($, Drupal, drupalSettings) {
function loadEmbeddedContent() {
if (typeof Drupal.eu_cookie_compliance === 'undefined') {
if (
typeof Drupal.eu_cookie_compliance === 'undefined' ||
!drupalSettings.embedded_media_attributes
) {
return;
}

if (Drupal.eu_cookie_compliance.hasAgreed('preference') && Drupal.eu_cookie_compliance.hasAgreed('statistics')) {
if (
Drupal.eu_cookie_compliance.hasAgreed('preference') &&
Drupal.eu_cookie_compliance.hasAgreed('statistics')
) {
// eslint-disable-next-line no-restricted-syntax
for (const [id, attributes] of Object.entries(drupalSettings.embedded_media_attributes)) {
const iframeElement = document.createElement('iframe');
Expand Down Expand Up @@ -59,7 +65,7 @@
skipLinkAfter.text = Drupal.t('Continue above the journey planner', {}, { context: 'Skip link after the journey planner for the journey planner paragraph' });
skipLinkBefore.text = Drupal.t('Continue below the journey planner', {}, { context: 'Skip link before the journey planner for the journey planner paragraph' });
$(`.embedded-content-cookie-compliance.media-${id}`)
.replaceWith(skipLinkBefore, containerElement, skipLinkAfter);
.replaceWith(skipLinkBefore, containerElement, skipLinkAfter);
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/scss/06_components/pages/_cookie-compliance.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
}

.cookie-compliance-block {
@include components-container-max-width;
@include component-side-padding;

.cookie-selection-instruction {
@include font('body');
border-bottom: 1px solid $color-black-20;
Expand Down