More actions
Indice: nel rail sopra la TOC nativa (riuso TOC); float dove il rail non c'è |
Toggle apri/chiudi indice + rail-move |
||
| Line 1: | Line 1: | ||
/* All JavaScript here will be loaded for users of the Citizen skin */ | /* All JavaScript here will be loaded for users of the Citizen skin */ | ||
/* Indice d'archivio: dove esiste il rail di Citizen (pagine con sezioni) lo | /* Indice d'archivio: | ||
1) dove esiste il rail di Citizen (pagine con sezioni) lo mettiamo lì, SOPRA | |||
la TOC nativa (che riusiamo); dove il rail non esiste l'indice resta una | |||
colonna flottante (.ai-rail) e non sparisce. | |||
2) il box è collassabile (toggle "Indice"): su pagine con TOC lunga si chiude | |||
l'indice e si tiene la TOC. La testata (link alla Dashboard) resta sempre. */ | |||
mw.hook( 'wikipage.content' ).add( function () { | mw.hook( 'wikipage.content' ).add( function () { | ||
var box = document.querySelector( '.archivio-indice.ai-rail' ); | var box = document.querySelector( '.archivio-indice.ai-rail' ); | ||
if ( | if ( box ) { | ||
var rail = | |||
document.querySelector( '.citizen-page-sidebar' ) || | |||
document.querySelector( '.citizen-sidebar' ) || | |||
document.querySelector( '.citizen-toc-container' ); | |||
if ( rail ) { | |||
box.classList.remove( 'ai-rail' ); | |||
box.classList.add( 'ai-in-rail' ); | |||
rail.prepend( box ); | |||
} | |||
} | } | ||
// Toggle apri/chiudi | |||
document.querySelectorAll( '.archivio-indice .ai-toggle' ).forEach( function ( t ) { | |||
if ( t.dataset.bound ) { | |||
return; | |||
} | |||
t.dataset.bound = '1'; | |||
var toggle = function () { | |||
t.closest( '.archivio-indice' ).classList.toggle( 'ai-collapsed' ); | |||
}; | |||
t.addEventListener( 'click', toggle ); | |||
t.addEventListener( 'keydown', function ( e ) { | |||
if ( e.key === 'Enter' || e.key === ' ' ) { | |||
e.preventDefault(); | |||
toggle(); | |||
} | |||
} ); | |||
} ); | |||
} ); | } ); | ||
Revision as of 20:39, 15 June 2026
/* All JavaScript here will be loaded for users of the Citizen skin */
/* Indice d'archivio:
1) dove esiste il rail di Citizen (pagine con sezioni) lo mettiamo lì, SOPRA
la TOC nativa (che riusiamo); dove il rail non esiste l'indice resta una
colonna flottante (.ai-rail) e non sparisce.
2) il box è collassabile (toggle "Indice"): su pagine con TOC lunga si chiude
l'indice e si tiene la TOC. La testata (link alla Dashboard) resta sempre. */
mw.hook( 'wikipage.content' ).add( function () {
var box = document.querySelector( '.archivio-indice.ai-rail' );
if ( box ) {
var rail =
document.querySelector( '.citizen-page-sidebar' ) ||
document.querySelector( '.citizen-sidebar' ) ||
document.querySelector( '.citizen-toc-container' );
if ( rail ) {
box.classList.remove( 'ai-rail' );
box.classList.add( 'ai-in-rail' );
rail.prepend( box );
}
}
// Toggle apri/chiudi
document.querySelectorAll( '.archivio-indice .ai-toggle' ).forEach( function ( t ) {
if ( t.dataset.bound ) {
return;
}
t.dataset.bound = '1';
var toggle = function () {
t.closest( '.archivio-indice' ).classList.toggle( 'ai-collapsed' );
};
t.addEventListener( 'click', toggle );
t.addEventListener( 'keydown', function ( e ) {
if ( e.key === 'Enter' || e.key === ' ' ) {
e.preventDefault();
toggle();
}
} );
} );
} );