1(function (Drupal, once) { 2 Drupal.behaviors.pgi_modal_tracking_behavior = { 3 attach: function (context) { 4 once('pgi_modal_tracking_behavior', '.pds-modal-dialog', context).forEach(function (modal, index, modalArray) { 5 let modaltitleElem = modal.querySelector("pds-heading") || modal.querySelector("h3"); 6 const modaltitle = modaltitleElem ? modaltitleElem.innerHTML.trim() : ''; 7 Drupal.pfgElementViewObserver( 8 modal, 9 { 10 'event': 'modalView', 11 'modaltitle': modaltitle // title of the modal area 12 }, 13 0.1 14 ); 15 const clickdiv = modal.querySelector('div'); 16 clickdiv.addEventListener('click', (event) => { 17 window.dataLayer = window.dataLayer || []; 18 window.dataLayer.push({ 19 'event': 'modalClick', 20 'modaltitle': modaltitle, // title of the modal area 21 'clicktext': event.target?.innerText 22 }); 23 }); 24 }); 25 } 26 } 27}(Drupal, once));
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.