1/** 2 * @file 3 * Global utilities. 4 * 5 */ 6 (function($, Drupal) { 7 8 'use strict'; 9 10 Drupal.behaviors.banner_withdraw = { 11 attach: function(context, settings) { 12 13 //check if consent has been set 14 if (document.cookie.includes('cookie-agreed')) { 15 // Add an observer 16 const startObserving = (domNode, classToLookFor) => { 17 let observer; 18 let timeoutFlag = false; 19 20 // Create the MutationObserver 21 observer = new MutationObserver(mutations => { 22 mutations.forEach(mutation => { 23 const elementAdded = Array.from(mutation.addedNodes).some(element => { 24 if (element.classList && element.classList.contains(classToLookFor)) { 25 //Add bottom 0 to the banner on page load. This overrides the bottom set by ECC module 26 element.style.bottom = "0"; 27 observer.disconnect(); 28 clearTimeout(timeoutId); // Clear the timeout 29 timeoutFlag = true; // Set the flag 30 } 31 }); 32 }); 33 }); 34 35 // Observe the target node 36 observer.observe(domNode, { 37 childList: true, 38 attributes: true, 39 characterData: true, 40 subtree: true, 41 }); 42 43 // Set a timeout of 5 seconds. to stop observing in case the element is never created 44 // for instance for website with the module ECC but no active banner 45 const timeoutId = setTimeout(() => { 46 if (!timeoutFlag) { 47 observer.disconnect(); 48 } 49 }, 5000); // 5 seconds should be more that enough 50 }; 51 52 startObserving(document.body, 'sliding-popup-bottom'); 53 } 54 55 $('body').on('click', 'button.eu-cookie-withdraw-tab, button.decline-button', function() { 56 57 //Click on privacy setting button : 58 if($(this).hasClass('eu-cookie-withdraw-tab')) { 59 60 if($(this).hasClass('eu-cookie-withdraw-tab-down')) { 61 $(this).removeClass('eu-cookie-withdraw-tab-down'); 62 $('#sliding-popup').removeClass('showECCBanner'); 63 } 64 else { 65 $('.eu-cookie-withdraw-banner').show(); 66 $('.eu-cookie-compliance-banner').show(); 67 $('#sliding-popup').addClass('showECCBanner'); 68 $(this).addClass('eu-cookie-withdraw-tab-down'); 69 } 70 71 } 72 73 74 //Click on reject all button : 75 else if($(this).hasClass('decline-button')) { 76 77 var el = $('.eu-cookie-withdraw-tab'); 78 if(el.hasClass('eu-cookie-withdraw-tab-down')) { 79 el.removeClass('eu-cookie-withdraw-tab-down'); 80 $('#sliding-popup').removeClass('showECCBanner'); 81 } 82 } 83 84 }); 85 86 } 87 }; 88 89 90 })(jQuery, Drupal); 91
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.