1/* Labamu Region Switcher v1.12.0 */ 2(function () { 3 'use strict'; 4 5 document.addEventListener('DOMContentLoaded', function () { 6 var switcher = document.getElementById('lbmSwitcher'); 7 var trigger = document.getElementById('lbmTrigger'); 8 var dropdown = document.getElementById('lbmDropdown'); 9 10 if (!switcher || !trigger || !dropdown) return; 11 12 // Move dropdown to body to escape any overflow:hidden parent (e.g. Elementor sections) 13 document.body.appendChild(dropdown); 14 dropdown.style.position = 'fixed'; 15 dropdown.style.zIndex = '999999'; 16 17 function reposition() { 18 var rect = trigger.getBoundingClientRect(); 19 var vw = window.innerWidth; 20 var margin = 8; 21 var maxW = vw - margin * 2; 22 23 // On small screens let the dropdown fill most of the viewport width 24 dropdown.style.maxWidth = maxW + 'px'; 25 dropdown.style.width = ''; 26 27 var dropW = dropdown.offsetWidth || 220; 28 var left = rect.right - dropW; 29 30 // Clamp so it never goes off either edge 31 if (left + dropW > vw - margin) left = vw - margin - dropW; 32 if (left < margin) left = margin; 33 34 dropdown.style.top = (rect.bottom + 6) + 'px'; 35 dropdown.style.left = left + 'px'; 36 } 37 38 function open() { 39 dropdown.style.display = 'block'; 40 reposition(); 41 switcher.classList.add('is-open'); 42 trigger.setAttribute('aria-expanded', 'true'); 43 } 44 45 function close() { 46 dropdown.style.display = 'none'; 47 switcher.classList.remove('is-open'); 48 trigger.setAttribute('aria-expanded', 'false'); 49 } 50 51 function toggle() { 52 dropdown.style.display === 'block' ? close() : open(); 53 } 54 55 trigger.addEventListener('click', function (e) { 56 e.stopPropagation(); 57 toggle(); 58 }); 59 60 document.addEventListener('click', function (e) { 61 if (!switcher.contains(e.target) && !dropdown.contains(e.target)) close(); 62 }); 63 64 document.addEventListener('keydown', function (e) { 65 if (e.key === 'Escape') close(); 66 }); 67 68 trigger.addEventListener('keydown', function (e) { 69 if (e.key === 'Enter' || e.key === ' ') { 70 e.preventDefault(); 71 toggle(); 72 } 73 }); 74 75 // Reposition on scroll or resize while open 76 window.addEventListener('scroll', function () { 77 if (dropdown.style.display === 'block') reposition(); 78 }, true); 79 80 window.addEventListener('resize', function () { 81 if (dropdown.style.display === 'block') reposition(); 82 }); 83 }); 84})();
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.