1import * as menu from './menu.js'; 2 3const abreDropdown = ev => { 4 ev.stopPropagation(); 5 fechaDropdowns(); 6 menu.fecha(ev); 7 const b = ev.currentTarget; 8 const d = b.parentNode.querySelector('div'); 9 const rect = b.getBoundingClientRect(); 10 const y = (rect.top + rect.bottom) / 2; 11 const x = (rect.left + rect.right) / 2; 12 if (y < window.innerHeight / 2) { 13 d.style.top = '0'; 14 d.style.bottom = 'auto'; 15 } else { 16 d.style.top = 'auto'; 17 d.style.bottom = '0'; 18 } 19 if (x < window.innerWidth / 2) { 20 d.style.left = '0'; 21 d.style.right = 'auto'; 22 } else { 23 d.style.left = 'auto'; 24 d.style.right = '0'; 25 } 26 d.classList.add('aberto'); 27}; 28 29const fechaDropdown = ev => { 30 ev.stopPropagation(); 31 const b = ev.currentTarget; 32 setTimeout(() => { 33 b.parentNode.classList.remove('aberto'); 34 }, 100); 35}; 36 37const fechaDropdowns = () => { 38 document.querySelectorAll('.buttons > div.aberto').forEach(dd => dd.classList.remove('aberto')); 39}; 40 41const registraDropdowns = () => { 42 document.querySelectorAll('.buttons > button, .buttons > a.button').forEach(b => { 43 b.addEventListener('click', abreDropdown); 44 }); 45 46 document.querySelectorAll('.buttons > div > button, .buttons > div > a.button').forEach(b => { 47 b.addEventListener('click', fechaDropdown); 48 }); 49}; 50 51const back = ev => { 52 53 if (history.length > 1) { 54 window.history.back(); 55 return; 56 } 57 window.close(); 58}; 59 60const registraBotoesVoltar = () => { 61 document.querySelectorAll('button.voltar, button.back').forEach(b => { 62 b.addEventListener('click', back); 63 }); 64}; 65 66document.body.addEventListener('click', fechaDropdowns); 67 68const observer = new MutationObserver(() => { 69 registraDropdowns(); 70 registraBotoesVoltar(); 71 const botoesDocados = document.querySelector('button.novo,button.next,a.button.novo,a.button.next'); 72 observer.disconnect(); 73 if (botoesDocados) { 74 document.body.classList.add('botoes-docados'); 75 } else { 76 document.body.classList.remove('botoes-docados'); 77 } 78 observer.observe(document.body, { attributes: true, childList: true, subtree: true }); 79}); 80observer.observe(document.body, { attributes: true, childList: true, subtree: true }); 81 82registraDropdowns(); 83 84if (document.querySelector('button.novo, a.button.novo, button.next, a.button.next')) { 85 document.getElementById('regiao-botoes').classList.remove('oculta'); 86} 87 88export {fechaDropdowns};
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.