1(function (Drupal, once, $) { 2 'use strict'; 3 4 Drupal.behaviors.dhcareContextualFix = { 5 attach: function (context) { 6 once('dhcare-contextual-fix', 'html', context).forEach(function () { 7 document.addEventListener('click', function (e) { 8 if (e.target.closest('.contextual')) { 9 return; 10 } 11 // Close via Backbone model so the VisualView re-renders correctly. 12 if (Drupal.contextual && Drupal.contextual.collection) { 13 Drupal.contextual.collection.each(function (model) { 14 model.close().blur(); 15 }); 16 } 17 }, true); 18 }); 19 }, 20 }; 21 22 // Auto-open the Worldwide/country-selector popup the first time a visitor 23 // loads the site, then leave it purely click-triggered (via #block-worldwide) 24 // for every visit after that. Relies on the simple_popup_blocks module 25 // having already wrapped #block-dhcare-countryselector and bound its own 26 // click handler to #block-worldwide; we just simulate that click once. 27 Drupal.behaviors.dhcareWorldwideAutoPopup = { 28 attach: function (context) { 29 once('dhcare-worldwide-auto-popup', '#block-worldwide', context).forEach(function (el) { 30 var cookieName = 'dhcare_worldwide_seen'; 31 if (document.cookie.indexOf(cookieName + '=') !== -1) { 32 return; 33 } 34 35 function markSeenAndOpen() { 36 var expires = new Date(); 37 expires.setTime(expires.getTime() + (100 * 24 * 60 * 60 * 1000)); 38 document.cookie = cookieName + '=1; expires=' + expires.toGMTString() + '; path=/'; 39 40 // Give simple_popup_blocks.js a moment to finish wrapping the block 41 // and binding its click handler before we simulate the click. 42 setTimeout(function () { 43 $(el).trigger('click'); 44 }, 300); 45 } 46 47 // Don't stack this popup on top of the Usercentrics cookie-consent 48 // banner (cookies_consent module, script#usercentrics-cmp). Its UI 49 // renders inside a shadow root (#usercentrics-root) as a 50 // [data-testid="uc-default-banner"] dialog, so rather than relying 51 // on a specific JS event name from that third-party widget (which 52 // varies by CMP version), poll the actual DOM for that dialog and 53 // open once it's no longer showing. 54 function isConsentBannerOpen() { 55 var host = document.getElementById('usercentrics-root'); 56 var root = host && host.shadowRoot; 57 var dialog = root && root.querySelector('[data-testid="uc-default-banner"]'); 58 if (!dialog) { 59 return false; 60 } 61 var style = window.getComputedStyle(dialog); 62 return style.display !== 'none' && style.visibility !== 'hidden' && dialog.getClientRects().length > 0; 63 } 64 65 var elapsed = 0; 66 var pollInterval = 250; 67 var initialGrace = 2000; // let the banner render before assuming it won't show 68 var maxTotalWait = 5 * 60 * 1000; // safety net if it's left open indefinitely 69 var bannerSeen = false; 70 var timer = setInterval(function () { 71 elapsed += pollInterval; 72 var open = isConsentBannerOpen(); 73 if (open) { 74 bannerSeen = true; 75 } 76 if ((open && elapsed < maxTotalWait) || (!bannerSeen && elapsed < initialGrace)) { 77 return; 78 } 79 clearInterval(timer); 80 markSeenAndOpen(); 81 }, pollInterval); 82 }); 83 }, 84 }; 85 86 // On mobile, reinitialise the homepage slideshow with adaptiveHeight so the 87 // container always matches the active slide's image height regardless of the 88 // image dimensions uploaded in the future. 89 Drupal.behaviors.dhcareSlideshowMobile = { 90 attach: function (context) { 91 if (window.innerWidth > 767) { 92 return; 93 } 94 once('dhcare-slideshow-mobile', '.path-frontpage .slideshow-items', context).forEach(function (el) { 95 var $el = $(el); 96 // Wait until Slick has finished its own init before we patch it. 97 $el.on('init', function () { 98 $el.slick('setOption', 'adaptiveHeight', true, true); 99 }); 100 // If Slick already ran (page cached), patch it immediately. 101 if ($el.hasClass('slick-initialized')) { 102 $el.slick('setOption', 'adaptiveHeight', true, true); 103 } 104 }); 105 }, 106 }; 107 108}(Drupal, once, jQuery));
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.