1(function ($, Drupal, document) { 2 let scriptHasRunOnce = false; 3 4 setTimeout(function () { 5 let messageText = 'To view this content, you need to'; 6 let messageLinkText = 'accept the following cookies:'; 7 let preferenceLabel = 'Preferences'; 8 let statisticsLabel = 'Statistics'; 9 let marketingLabel = 'Marketing'; 10 11 Drupal.behaviors.cookieConsentNotice = { 12 attach(context, settings) { 13 if ( 14 typeof drupalSettings.cookieConsentNotice.messageText !== 15 'undefined' && 16 drupalSettings.cookieConsentNotice.messageText !== null 17 ) { 18 messageText = drupalSettings.cookieConsentNotice.messageText; 19 } 20 if ( 21 typeof drupalSettings.cookieConsentNotice.messageLinkText !== 22 'undefined' && 23 drupalSettings.cookieConsentNotice.messageLinkText !== null 24 ) { 25 messageLinkText = drupalSettings.cookieConsentNotice.messageLinkText; 26 } 27 if ( 28 typeof drupalSettings.cookieConsentNotice.preferenceLabel !== 29 'undefined' && 30 drupalSettings.cookieConsentNotice.preferenceLabel !== null 31 ) { 32 preferenceLabel = drupalSettings.cookieConsentNotice.preferenceLabel; 33 } 34 if ( 35 typeof drupalSettings.cookieConsentNotice.statisticsLabel !== 36 'undefined' && 37 drupalSettings.cookieConsentNotice.statisticsLabel !== null 38 ) { 39 statisticsLabel = drupalSettings.cookieConsentNotice.statisticsLabel; 40 } 41 if ( 42 typeof drupalSettings.cookieConsentNotice.marketingLabel !== 43 'undefined' && 44 drupalSettings.cookieConsentNotice.marketingLabel !== null 45 ) { 46 marketingLabel = drupalSettings.cookieConsentNotice.marketingLabel; 47 } 48 49 if (!scriptHasRunOnce) { 50 scriptHasRunOnce = true; 51 52 const newDiv = document.createElement('div'); 53 54 let parentElement = ''; 55 let cookiesListItems = ''; 56 let cookiesClassItems = ''; 57 let cookieClass = ''; 58 59 if ($('.cookieconsent-optin-preferences', context).length) { 60 const translatablePreferences = Drupal.t(preferenceLabel); 61 cookiesListItems += `<li style="display: list-item;" class="cookieconsent-optout-preferences">${translatablePreferences}</li>`; 62 if ( 63 jQuery('.cookieconsent-optin-preferences').css('display') !== 64 'none' 65 ) { 66 cookiesClassItems = 'cookieconsent-optout-preferences'; 67 } 68 parentElement = $('.cookieconsent-optin-preferences').parent(); 69 cookieClass = '.cookieconsent-optin-preferences'; 70 } 71 if ($('.cookieconsent-optin-statistics', context).length) { 72 const translatableStatistics = Drupal.t(statisticsLabel); 73 cookiesListItems += `<li style="display: list-item;" class="cookieconsent-optout-statistics">${translatableStatistics}</li>`; 74 if ( 75 jQuery('.cookieconsent-optin-statistics').css('display') !== 76 'none' 77 ) { 78 cookiesClassItems = 'cookieconsent-optout-statistics'; 79 } 80 parentElement = $('.cookieconsent-optin-statistics').parent(); 81 cookieClass = '.cookieconsent-optin-statistics'; 82 } 83 if ($('.cookieconsent-optin-marketing', context).length) { 84 const translatableMarketing = Drupal.t(marketingLabel); 85 cookiesListItems += `<li style="display: list-item;" class="cookieconsent-optout-marketing">${translatableMarketing}</li>`; 86 if ( 87 jQuery('.cookieconsent-optin-marketing').css('display') !== 'none' 88 ) { 89 cookiesClassItems = 'cookieconsent-optout-marketing'; 90 } 91 parentElement = $('.cookieconsent-optin-marketing').parent(); 92 cookieClass = '.cookieconsent-optin-marketing'; 93 } 94 95 newDiv.innerHTML = `${Drupal.t( 96 `${messageText} <a href="#" onclick="CookieConsent.renew()">${messageLinkText}</a>`, 97 )}<ul>${cookiesListItems}</ul>`; 98 99 newDiv.className = `cookie-consent-div ${cookiesClassItems}`; 100 101 // only append the new div if the parent element exists 102 if (parentElement !== '') { 103 parentElement.append(newDiv); 104 } 105 106 // repeatedly check if the iframe is being displayed, if it is then 107 // remove the cookies message div before the user has set any cookies 108 // the display sometimes needs a bit of help... 109 const displayCheckInterval = setInterval(function () { 110 if (cookieClass !== '' && document.querySelector(cookieClass)) { 111 const iframeDisplayStyle = getComputedStyle( 112 document.querySelector(cookieClass), 113 ).display; 114 115 if (iframeDisplayStyle !== 'none') { 116 document.querySelector('.cookie-consent-div').style.display = 117 'none'; 118 119 // kill the interval to prevent unnecessary processing overhead 120 clearInterval(displayCheckInterval); 121 } 122 } 123 }, 500); 124 } 125 }, 126 }; 127 128 const domReady = (callback) => { 129 const listener = () => { 130 callback(); 131 document.removeEventListener('DOMContentLoaded', listener); 132 }; 133 if (document.readyState !== 'loading') { 134 setTimeout(callback, 0); 135 } else { 136 document.addEventListener('DOMContentLoaded', listener); 137 } 138 }; 139 140 domReady(() => { 141 Drupal.attachBehaviors(document); 142 }); 143 }, 1000); 144})(jQuery, Drupal, document);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.