|
|
| Line 1: |
Line 1: |
| /* Any JavaScript here will be loaded for all users on every page load. */ | | /* Any JavaScript here will be loaded for all users on every page load. */ |
|
| |
|
| (function() {
| |
| function initSidebarDropdown() {
| |
| // Procura todos os links na barra lateral
| |
| var links = document.querySelectorAll('.vector-main-menu-sidebar a, .mw-sidebar-navigation a, #mw-panel-nav a');
| |
|
| |
| links.forEach(function(link) {
| |
| // Se encontrar o link que diz exatamente "PROBES"
| |
| if (link.textContent.trim() === 'PROBES') {
| |
| var parentLi = link.closest('li');
| |
| if (!parentLi) return;
| |
|
| |
| // Encontra a lista ul subsequente que contém as sondas
| |
| var subList = parentLi.querySelector('ul') || (parentLi.nextElementSibling && parentLi.nextElementSibling.tagName === 'UL' ? parentLi.nextElementSibling : null);
| |
|
| |
| if (subList) {
| |
| // 1. Esconde as sondas imediatamente
| |
| subList.style.display = 'none';
| |
|
| |
| // 2. Injeta uma seta visual antes do link
| |
| var arrow = document.createElement('span');
| |
| arrow.innerHTML = '▶ ';
| |
| arrow.style.cursor = 'pointer';
| |
| arrow.style.marginRight = '5px';
| |
| arrow.style.display = 'inline-block';
| |
| arrow.style.transition = 'transform 0.2s';
| |
| link.insertBefore(arrow, link.firstChild);
| |
|
| |
| // 3. Altera o comportamento do clique no bloco inteiro
| |
| var clickTarget = link.parentElement;
| |
| clickTarget.style.cursor = 'pointer';
| |
|
| |
| clickTarget.addEventListener('click', function(e) {
| |
| // Se o link tiver '#' (âncora), impede de recarregar a página
| |
| if (link.getAttribute('href').indexOf('#') !== -1) {
| |
| e.preventDefault();
| |
| e.stopPropagation();
| |
| }
| |
|
| |
| // Alterna a visibilidade
| |
| if (subList.style.display === 'none') {
| |
| subList.style.display = 'block';
| |
| arrow.style.transform = 'rotate(90deg)';
| |
| } else {
| |
| subList.style.display = 'none';
| |
| arrow.style.transform = 'rotate(0deg)';
| |
| }
| |
| });
| |
| }
| |
| }
| |
| });
| |
| }
| |
|
| |
| // Executa assim que o documento estiver pronto
| |
| if (document.readyState === 'loading') {
| |
| document.addEventListener('DOMContentLoaded', initSidebarDropdown);
| |
| } else {
| |
| initSidebarDropdown();
| |
| }
| |
| })();
| |
|
| |
|
|
| |
|