More actions
Created page with "→Any JavaScript here will be loaded for all users on every page load.: mw.hook('wikipage.content').add(function ($content) { var box = $content.find('[data-stato-archivio="1"]').first(); if (!box.length) return; // Target: TOC a destra su Vector 2022 (rail del TOC) var target = document.querySelector('.vector-toc') || document.querySelector('.mw-table-of-contents') || document.querySelector('#toc'); if (!target) return; // Se #toc è dentr..." |
No edit summary |
||
| Line 2: | Line 2: | ||
mw.hook('wikipage.content').add(function ($content) { | mw.hook('wikipage.content').add(function ($content) { | ||
var box = $content.find('[data-stato-archivio="1"]').first(); | // 1) trova il box nel contenuto | ||
if (!box.length) return; | var $box = $content.find('[data-stato-archivio="1"]').first(); | ||
if (!$box.length) return; | |||
// | // 2) trova l'area TOC di Citizen | ||
var | // Citizen usa comunemente .citizen-toc per il blocco del ToC (sidebar/rail) | ||
document.querySelector('. | var tocContainer = | ||
document.querySelector(' | document.querySelector('.citizen-toc') || | ||
document.querySelector('#toc'); | document.querySelector('#citizen-toc') || | ||
document.querySelector('#toc'); // fallback estremo | |||
if (! | if (!tocContainer) return; | ||
// | // 3) inserisci il box sopra al contenuto del TOC | ||
var | // se esiste un contenitore interno, mettiamo il box prima della lista | ||
var inner = | |||
tocContainer.querySelector('.citizen-toc-contents') || | |||
tocContainer.querySelector('.toc') || | |||
tocContainer; | |||
inner.parentNode.insertBefore($box[0], inner); | |||
// | // 4) margini “da widget” nella rail | ||
box[0].style.margin = '0 0 12px 0'; | $box[0].style.margin = '0 0 12px 0'; | ||
}); | }); | ||
Revision as of 21:06, 29 December 2025
/* Any JavaScript here will be loaded for all users on every page load. */
mw.hook('wikipage.content').add(function ($content) {
// 1) trova il box nel contenuto
var $box = $content.find('[data-stato-archivio="1"]').first();
if (!$box.length) return;
// 2) trova l'area TOC di Citizen
// Citizen usa comunemente .citizen-toc per il blocco del ToC (sidebar/rail)
var tocContainer =
document.querySelector('.citizen-toc') ||
document.querySelector('#citizen-toc') ||
document.querySelector('#toc'); // fallback estremo
if (!tocContainer) return;
// 3) inserisci il box sopra al contenuto del TOC
// se esiste un contenitore interno, mettiamo il box prima della lista
var inner =
tocContainer.querySelector('.citizen-toc-contents') ||
tocContainer.querySelector('.toc') ||
tocContainer;
inner.parentNode.insertBefore($box[0], inner);
// 4) margini “da widget” nella rail
$box[0].style.margin = '0 0 12px 0';
});