1/* 2 mando.cookiebanner.js: Plugins JavaScript 3 ------------ 4 Job: Cookie Banner 5 Template Version: 1.0 6 Produced by: Heidi Crook 7 Start date: 09/12/2014 8 Edited: 21/10/2025 Francesca Mars to add Clarity and accessibility functionality 9 ------------ 10 Dependancies: /vendor/jquery-cookie.js 11 /vendor/enquire.min.js 12****************************************************************************************************/ 13var cookieInit = function () { 14 15 if (jQuery.cookie) { 16 17 var cookieBanner = $('[data-id="cookie-banner"]'); 18 var closeBtn = $('[data-id="cookie-close"]'); 19 var acceptBtn = $('[data-id="cookie-accept"]'); 20 var manageBtn = $('[data-id="cookie-manage"]'); 21 22 // accept cookies button 23 acceptBtn.click(function () { 24 CookieControl.acceptAll(); 25 cookieBanner.hide(); 26 $.cookie("hideCookieBanner", true, { expires: 365, path: "/" }); 27 }); 28 // open cookie preferences panel 29 manageBtn.click(function () { 30 CookieControl.open(); 31 cookieBanner.hide(); 32 }) 33 34 35 if (!$.cookie("hideCookieBanner")) cookieBanner.show(); 36 37 closeBtn.on("click", function (evt) { 38 39 evt.preventDefault(); 40 cookieBanner.hide(); 41 42 }); 43 }; 44 if (Modernizr.mq('only all')) { 45 var moveCookie = function () { 46 $('[data-id="cookie-banner"]').prependTo('[data-id="mobile-cookie-location"]'); 47 } 48 49 var moveCookieBack = function () { 50 $('[data-id="cookie-banner"]').prependTo('div.m-header'); 51 } 52 53 enquire.register("screen and (max-width:47.938em)", { 54 match: function () { 55 moveCookie(); 56 57 }, 58 unmatch: function () { 59 moveCookieBack(); 60 } 61 }, true); 62 63 } 64} 65function civicChangeHeadings() { 66 setTimeout(function () { 67 const $cccontainer = $('#ccc'); 68 if ($cccontainer.length === 0) return; 69 70 const observer = new MutationObserver((mutationsList) => { 71 mutationsList.forEach(() => { 72 const $h3headings = $('h3.optional-cookie-header'); 73 if ($h3headings.length) { 74 $($h3headings).each(function () { 75 const $this = $(this); 76 if (!$this.prev().is('h2.lbih2')) { 77 const headingText = $.trim($this.text()); 78 $('<h2>', { 79 class: 'lbih2', 80 text: headingText 81 }).insertAfter($this); 82 } 83 $this.remove(); 84 }); 85 } 86 }); 87 }); 88 89 observer.observe($cccontainer[0], { 90 childList: true, 91 subtree: true 92 }); 93 }, 1000); // end timeout 94} 95 96function civicCheckConsentCategories() { 97 setTimeout(function () { 98 if (typeof window.clarity !== 'function') { 99 return; 100 } 101 102 const analytics = CookieControl.getCategoryConsent(0); 103 const advertising = CookieControl.getCategoryConsent(1); 104 105 if (analytics && advertising) { 106 window.clarity('consentv2', { 107 analytics_Storage: "granted", 108 ad_Storage: "granted", 109 }); 110 console.log("analytics granted, ad granted"); 111 } 112 else if (analytics && !advertising) { 113 window.clarity('consentv2', { 114 analytics_Storage: "granted", 115 ad_Storage: "denied", 116 }); 117 console.log("analytics granted, ad denied"); 118 } 119 else if (!analytics && advertising) { 120 window.clarity('consentv2', { 121 analytics_Storage: "denied", 122 ad_Storage: "granted", 123 }); 124 console.log("analytics denied, ad granted"); 125 } 126 else { 127 window.clarity('consentv2', { 128 analytics_Storage: "denied", 129 ad_Storage: "denied", 130 }); 131 console.log("analytics denied, ad denied"); 132 } 133 }, 1000); // end timeout 134} 135 136 137$(document).ready(function () { 138 cookieInit(); 139 civicChangeHeadings(); 140});
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.