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

MediaWiki interface page
Revision as of 20:39, 15 June 2026 by Cranio is thinking (talk | contribs) (Toggle apri/chiudi indice + rail-move)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* 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();
			}
		} );
	} );
} );