MediaWiki:Common.js: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
| Line 3: | Line 3: | ||
// ========================================================================== | // ========================================================================== | ||
// CONTROLADOR DE DROPDOWN INDEPENDENTE NO ÍNDICE (TOC) - | // CONTROLADOR DE DROPDOWN INDEPENDENTE NO ÍNDICE (TOC) - FIX TOTAL | ||
// ========================================================================== | // ========================================================================== | ||
// | // Almeja estritamente as listas internas de conteúdo numérico, ignorando totalmente os blocos de topo | ||
$(' | $('.vector-toc-contents .vector-toc-list .vector-toc-list-item').each(function() { | ||
var $listItem = $(this); | var $listItem = $(this); | ||
// Se for o | // Camada extra de proteção: Se for o botão colapsável nativo ou o cabeçalho, ignora completamente | ||
if ($listItem.find('#vector-toc-collapsed-button').length > 0 || $listItem.hasClass('vector-toc-title')) { | if ($listItem.find('.vector-toc-title, #vector-toc-collapsed-button, .vector-toc-header').length > 0 || $listItem.hasClass('vector-toc-title')) { | ||
return; | return; | ||
} | } | ||
var $subList = $listItem.children(' | var $subList = $listItem.children('.vector-toc-list, ul'); | ||
// Só | // Só injeta a seta se este item contiver subcapítulos (filhos reais) | ||
if ($subList.length > 0 && $subList.children(' | if ($subList.length > 0 && $subList.children('.vector-toc-list-item, li').length > 0) { | ||
// | // Verifica se a seta já existe para evitar duplicações ao recarregar | ||
if ($listItem.children('.toc-toggle-arrow').length === 0) { | if ($listItem.children('.toc-toggle-arrow').length === 0) { | ||
var $arrow = $('<span class="toc-toggle-arrow">▶</span>'); | var $arrow = $('<span class="toc-toggle-arrow">▶</span>'); | ||
// Evento | // Evento focado unicamente na nossa seta customizada | ||
$arrow.click(function(e) { | $arrow.click(function(e) { | ||
e.preventDefault(); | e.preventDefault(); | ||
| Line 33: | Line 31: | ||
}); | }); | ||
// | // Coloca a seta na raiz do item de lista (ao lado esquerdo do link) | ||
$listItem.prepend($arrow); | $listItem.prepend($arrow); | ||
} | } | ||