Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MediaWiki:Citizen.js: Difference between revisions

MediaWiki interface page
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:
  mettiamo lì, SOPRA la TOC nativa (che riusiamo); dove il rail non esiste
  1) dove esiste il rail di Citizen (pagine con sezioni) lo mettiamo lì, SOPRA
  (pagine senza sezioni) l'indice resta una colonna flottante (.ai-rail) e non
      la TOC nativa (che riusiamo); dove il rail non esiste l'indice resta una
   sparisce mai. Sulla Dashboard l'indice non ha .ai-rail (è nel suo layout),
      colonna flottante (.ai-rail) e non sparisce.
  quindi questo hook non lo tocca. */
   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 ( !box ) {
if ( box ) {
return;
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 );
}
}
}
var rail =
 
document.querySelector( '.citizen-page-sidebar' ) ||
// Toggle apri/chiudi
document.querySelector( '.citizen-sidebar' ) ||
document.querySelectorAll( '.archivio-indice .ai-toggle' ).forEach( function ( t ) {
document.querySelector( '.citizen-toc-container' );
if ( t.dataset.bound ) {
if ( !rail ) {
return;
return; // niente rail: l'indice resta flottante nel contenuto
}
}
t.dataset.bound = '1';
box.classList.remove( 'ai-rail' ); // via il float
var toggle = function () {
box.classList.add( 'ai-in-rail' );
t.closest( '.archivio-indice' ).classList.toggle( 'ai-collapsed' );
rail.prepend( box ); // indice sopra la TOC nativa
};
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();
			}
		} );
	} );
} );