forked from vectordotdev/vector
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WEB-3464] Adds TrustArc cookie consent banner (vectordotdev#18741)
* Add TrustArc cookie consent banner * Update config.toml * Update cookie-banner.js
- Loading branch information
1 parent
7dce292
commit 43428d3
Showing
4 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
window.addEventListener('load', function () { | ||
const { env } = document.documentElement.dataset; | ||
|
||
if (env !== 'development') { | ||
// add trustarc script to head | ||
const trustarc = document.createElement('script'); | ||
trustarc.setAttribute('src','https://consent.trustarc.com/v2/notice/ufocto'); | ||
document.head.appendChild(trustarc); | ||
|
||
// add divs | ||
const divA = document.createElement("div"); | ||
const divB = document.createElement("div"); | ||
divA.id = "teconsent"; | ||
divA.style = "cursor: pointer; color:#fff" | ||
divB.id = "consent-banner"; | ||
divB.style = "position:fixed; bottom:0px; right:0px; width:100%;"; | ||
document.body.appendChild(divA); | ||
document.body.appendChild(divB); | ||
|
||
// update Cookie link | ||
this.setTimeout(function () { | ||
const banner = document.getElementById('consent-banner'); | ||
const prefsElement = document.getElementById('teconsent'); | ||
const cookieLink = document.querySelector('footer a[href*="/cookies"]'); | ||
prefsElement.className = cookieLink.className; | ||
|
||
if (banner) { | ||
// listen for click and remove banner to avoid interfering with | ||
document.addEventListener('click', function (event) { | ||
const targetElement = event.target; | ||
if (targetElement.matches('#truste-consent-required') || targetElement.matches('#truste-consent-button')) { | ||
banner.remove(); | ||
} | ||
}); | ||
} | ||
|
||
// replace Cookie link with Prefs div | ||
return (cookieLink && document.getElementById('teconsent').innerHTML.length > 0) ? cookieLink.replaceWith(prefsElement) : false; | ||
}, 200); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters