Skip to content
Snippets Groups Projects
Commit 37bb024a authored by Ken Hawkins's avatar Ken Hawkins
Browse files

Add legacy styling support

parent 71936e9e
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,7 @@ function ebiFrameworkCreateDataProtectionBanner() { ...@@ -12,7 +12,7 @@ function ebiFrameworkCreateDataProtectionBanner() {
banner.id = "data-protection-banner"; banner.id = "data-protection-banner";
banner.className = "data-protection-banner"; banner.className = "data-protection-banner";
banner.style = "position: fixed; background-color: #111; width: 100%; padding: .75rem; left: 0; bottom: 0; color: #eee;" banner.style = "position: fixed; background-color: #111; width: 98%; padding: .75rem 1%; left: 0; bottom: 0; color: #eee;"
wrapper.className = "row"; wrapper.className = "row";
wrapper.innerHTML = "" + wrapper.innerHTML = "" +
"<div class='columns medium-8 large-9'>" + "<div class='columns medium-8 large-9'>" +
...@@ -72,15 +72,30 @@ var dataProtectionSettings = new Object(); ...@@ -72,15 +72,30 @@ var dataProtectionSettings = new Object();
/** /**
* The main 'brain' of the EBI Data Protection banner. * The main 'brain' of the EBI Data Protection banner.
* Further documentation at https://www.ebi.ac.uk/style-lab/websites/patterns/banner-data-protection.html * Further documentation at https://www.ebi.ac.uk/style-lab/websites/patterns/banner-data-protection.html
* @param {string} [targetedFrameworkVersion=generic] targeted Framework version; options: 1.1, 1.2, 1.3, compliance * @param {string} [targetedFrameworkVersion=generic] targeted Framework version; options: 1.1, 1.2, 1.3, compliance, other
*/ */
function ebiFrameworkRunDataProtectionBanner(targetedFrameworkVersion) { function ebiFrameworkRunDataProtectionBanner(targetedFrameworkVersion) {
try { try {
if (typeof newDataProtectionNotificationBanner !== "undefined") { if (typeof newDataProtectionNotificationBanner !== "undefined") {
targetedFrameworkVersion = targetedFrameworkVersion || newDataProtectionNotificationBanner.src.split('legacyRequest=')[1] || 'generic'; targetedFrameworkVersion = newDataProtectionNotificationBanner.src.split('legacyRequest=')[1] || 'generic';
} }
var compatibilityStyles = document.createElement('style');
compatibilityStyles.innerHTML = `
.data-protection-banner a,
.data-protection-banner a:hover {
color: #fff;
}
.data-protection-banner .medium-8 {
width: 75%; float: left;
}
.data-protection-banner .medium-4 {
width: 24%; float: right; text-align: right;
}
`;
document.body.appendChild(compatibilityStyles);
// remove any old style cookie banner // remove any old style cookie banner
switch (targetedFrameworkVersion) { switch (targetedFrameworkVersion) {
case '1.1': case '1.1':
...@@ -95,12 +110,17 @@ function ebiFrameworkRunDataProtectionBanner(targetedFrameworkVersion) { ...@@ -95,12 +110,17 @@ function ebiFrameworkRunDataProtectionBanner(targetedFrameworkVersion) {
document.getElementById("cookie-banner").remove(); document.getElementById("cookie-banner").remove();
} }
document.body.style.paddingTop = 0; document.body.style.paddingTop = 0;
document.body.appendChild(compatibilityStyles);
break;
case 'other':
// If you're not using any fomally supported framework, we'll do our best to help out
document.body.appendChild(compatibilityStyles);
break; break;
default: default:
console.warn('You should specify the targeted FrameworkVersion (allowed values: 1.1, 1.2, 1.3, compliance). You sent: ' + targetedFrameworkVersion); console.warn('You should specify the targeted FrameworkVersion (allowed values: 1.1, 1.2, 1.3, compliance, other). You sent: ' + targetedFrameworkVersion);
} }
// Default global values
dataProtectionSettings.message = 'This website requires cookies, and the limited processing of your personal data in order to function. By using the site you are agreeing to this as outlined in our <a target="_blank" href="https://www.ebi.ac.uk/data-protection/privacy-notice/embl-ebi-public-website" class="white-color">Privacy Notice</a> and <a target="_blank" href="https://www.ebi.ac.uk/about/terms-of-use" class="white-color">Terms of Use</a>.'; dataProtectionSettings.message = 'This website requires cookies, and the limited processing of your personal data in order to function. By using the site you are agreeing to this as outlined in our <a target="_blank" href="https://www.ebi.ac.uk/data-protection/privacy-notice/embl-ebi-public-website" class="white-color">Privacy Notice</a> and <a target="_blank" href="https://www.ebi.ac.uk/about/terms-of-use" class="white-color">Terms of Use</a>.';
dataProtectionSettings.serviceId = 'ebi'; dataProtectionSettings.serviceId = 'ebi';
dataProtectionSettings.dataProtectionVersion = '1.0'; dataProtectionSettings.dataProtectionVersion = '1.0';
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment