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_gtag_ajax', 18 'cookies_gtag_gtm' 19 ]; 20 for (var scriptId in scriptIds) { 21 var script = document.getElementById(scriptIds[scriptId]); 22 if (script && script.nodeName === 'SCRIPT') { 23 var content = script.innerHTML; 24 var newScript = document.createElement('script'); 25 var attributes = Array.from(script.attributes); 26 for (var attr in attributes) { 27 var name = attributes[attr].nodeName; 28 if (name !== 'type' && name !== 'id') { 29 newScript.setAttribute(name, attributes[attr].nodeValue); 30 } 31 } 32 newScript.innerHTML = content; 33 script.parentNode.replaceChild(newScript, script); 34 } 35 } 36 }, 37 38 attach: function (context) { 39 var self = this; 40 document.addEventListener('cookiesjsrUserConsent', function (event) { 41 var service = (typeof event.detail.services === 'object') ? event.detail.services : {}; 42 if (typeof service.gtag !== 'undefined' && service.gtag) { 43 self.consentGiven(context); 44 } 45 }); 46 } 47 }; 48})(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.