1(function ($, Drupal, once, drupalSettings) { 2 Drupal.behaviors.languagePathFix = { 3 attach: function (context) { 4 5 var currentLang = drupalSettings.path.currentLanguage; 6 if (!currentLang) { 7 return; 8 } 9 if (currentLang == 'en') { 10 return; 11 } 12 13 var langPrefix = '/' + currentLang; 14 var baseUrl = window.location.origin; 15 var languages = drupalSettings.coaLanguages || []; 16 17 function hasLanguagePrefix(href) { 18 return languages.some(function (lang) { 19 return href === '/' + lang || href.startsWith('/' + lang + '/'); 20 }); 21 } 22 23 function updateLink(element) { 24 var $link = $(element); 25 var rawHref = $link.attr('href'); 26 27 // Skip invalid, anchor-only, or non-navigable links early. 28 if (!rawHref || rawHref.startsWith('#') || rawHref.startsWith('tel') || rawHref.startsWith('email') || rawHref.startsWith('mailto') || rawHref.startsWith('internal')) { 29 return; 30 } 31 32 // Use the resolved absolute URL from the DOM property to reliably 33 // strip the current origin, producing a root-relative path. 34 var resolvedHref = element.href || rawHref; 35 var href = resolvedHref.replace(baseUrl, ''); 36 37 // After stripping the origin, skip any remaining external links. 38 if (href.startsWith('http')) { 39 return; 40 } 41 42 // Skip if any language prefix already exists 43 if (hasLanguagePrefix(href)) { 44 return; 45 } 46 47 // Normalize leading slash 48 if (!href.startsWith('/')) { 49 href = '/' + href; 50 } 51 52 $link.attr('href', langPrefix + href); 53 } 54 55 once('lang-path-fix', 'a.coh-link, .coh-wysiwyg a, .view-multisite-federated-search .row-container a', context) 56 .forEach(updateLink); 57 58 } 59 }; 60 61 Drupal.behaviors.emergencyRoleExpiry = { 62 attach: function (context) { 63 once('emergency-role-expiry', 'body', context).forEach(function () { 64 const roleCheckbox = document.querySelector('#edit-roles-emergency-news-publisher') || document.querySelector('#edit-role-change-emergency-news-publisher'); 65 const expiryWrapper = document.querySelector('#edit-field-emergency-role-expiry-wrapper'); 66 67 if (!roleCheckbox || !expiryWrapper) { 68 return; 69 } 70 71 const dateField = expiryWrapper.querySelector('input[type="date"]'); 72 73 function setExpiryState(checked) { 74 expiryWrapper.style.display = checked ? '' : 'none'; 75 if (dateField) { 76 dateField.required = checked; 77 } 78 if (!checked && dateField) { 79 dateField.value = ''; 80 } 81 } 82 83 // Set initial visibility without clearing a previously saved date. 84 setExpiryState(roleCheckbox.checked); 85 86 roleCheckbox.addEventListener('change', function () { 87 setExpiryState(roleCheckbox.checked); 88 }); 89 }); 90 } 91 }; 92})(jQuery, Drupal, once, drupalSettings);
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.