1/** 2 * @file 3 * Defines Javascript behaviors for the cookies module. 4 */; 5 6(function (Drupal) { 7 'use strict'; 8 9 /** 10 * Define defaults. 11 */ 12 Drupal.behaviors.cookiesGtag = { 13 14 consentGiven: function () { 15 var scriptIds = [ 16 'cookies_gtag_gtag', 17 'cookies_gtag_gtm' 18 ]; 19 for (var scriptId in scriptIds) { 20 var script = document.getElementById(scriptIds[scriptId]); 21 if (script && script.nodeName === 'SCRIPT') { 22 var content = script.innerHTML; 23 var newScript = document.createElement('script'); 24 var attributes = Array.from(script.attributes); 25 for (var attr in attributes) { 26 var name = attributes[attr].nodeName; 27 if (name !== 'type' && name !== 'id') { 28 newScript.setAttribute(name, attributes[attr].nodeValue); 29 } 30 } 31 newScript.innerHTML = content; 32 script.parentNode.replaceChild(newScript, script); 33 } 34 } 35 }, 36 37 attach: function (context) { 38 var self = this; 39 if (!window.gtag) { 40 window.gtag = () => { 41 console.log('gtag tracking is disabled'); 42 }; 43 } 44 document.addEventListener('cookiesjsrUserConsent', function (event) { 45 var service = (typeof event.detail.services === 'object') ? event.detail.services : {}; 46 if (typeof service.gtag !== 'undefined' && service.gtag) { 47 self.consentGiven(context); 48 } 49 }); 50 } 51 }; 52})(Drupal);
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.