|
|
| Line 2: |
Line 2: |
|
| |
|
|
| |
|
| /* Transforma títulos de secção da sidebar em links clicáveis com acordeão independente */ | | /* Any JavaScript here will be loaded for all users on every page load. */ |
| | |
| | // Força o menu lateral a expandir (Vector 2022) se estiver colapsado |
| mw.hook('wikipage.content').add(function () { | | mw.hook('wikipage.content').add(function () { |
| var mapping = { | | if (document.documentElement.classList.contains('vector-feature-main-menu-pinned-disabled')) { |
| 'SENSBLUE MONARCH': '/wiki/SENSBLUE_MONARCH',
| | var pinButton = document.getElementById('vector-main-menu-dropdown-checkbox'); |
| 'SENSBLUE ATLAS': '/wiki/SENSBLUE_ATLAS'
| | if (pinButton) { |
| };
| | // Remove a classe de desativado e força o estado expandido |
| | | document.documentElement.classList.remove('vector-feature-main-menu-pinned-disabled'); |
| var groups = document.querySelectorAll('.vector-main-menu-group');
| | document.documentElement.classList.add('vector-feature-main-menu-pinned-enabled'); |
| | |
| groups.forEach(function (group) {
| |
| var labelSpan = group.querySelector('.vector-menu-heading-label'); | |
| var content = group.querySelector('.vector-menu-content');
| |
| | |
| if (labelSpan && content && !labelSpan.dataset.linkInit) { | |
| labelSpan.dataset.linkInit = "true"; | |
| var text = labelSpan.textContent.trim();
| |
| | |
| if (mapping[text]) {
| |
| // 1. Converte o texto do cabeçalho num link direto
| |
| labelSpan.innerHTML = '<a href="' + mapping[text] + '" style="color: inherit; text-decoration: none;">' + text + '</a>';
| |
| | |
| // 2. Cria o ícone/botão toggle de expandir ao lado
| |
| var toggleBtn = document.createElement('span');
| |
| toggleBtn.innerHTML = ' ▾'; // Seta para baixo
| |
| toggleBtn.style.cursor = 'pointer';
| |
| toggleBtn.style.paddingLeft = '8px';
| |
| labelSpan.appendChild(toggleBtn);
| |
| | |
| // 3. Controla a expansão/recolhimento apenas neste bloco
| |
| content.style.display = 'none'; // Começa recolhido
| |
| | |
| toggleBtn.addEventListener('click', function (e) {
| |
| e.preventDefault();
| |
| e.stopPropagation();
| |
| var isHidden = content.style.display === 'none';
| |
| content.style.display = isHidden ? 'block' : 'none';
| |
| toggleBtn.innerHTML = isHidden ? ' ▴' : ' ▾';
| |
| });
| |
| }
| |
| } | | } |
| }); | | } |
| }); | | }); |
|
| |
|