MediaWiki:Vector.js
Nota: dopo aver pubblicato, potrebbe essere necessario pulire la cache del proprio browser per vedere i cambiamenti.
- Firefox / Safari: tieni premuto il tasto delle maiuscole Shift e fai clic su Ricarica, oppure premi Ctrl-F5 o Ctrl-R (⌘-R su Mac)
- Google Chrome: premi Ctrl-Shift-R (⌘-Shift-R su un Mac)
- Internet Explorer / Edge: tieni premuto il tasto Ctrl e fai clic su Aggiorna, oppure premi Ctrl-F5
- Opera: premi Ctrl-F5.
/* Il codice JavaScript inserito qui viene caricato dagli utenti che usano la skin Vector */
// Codice importato da [[MediaWiki:Monobook.js]]
( function( mw, $ ) {
//============================================================
// Menu caratteri speciali
//============================================================
/**
* Aggiunge il menu a tendina per selezionare un sottoinsieme di caratteri speciali
*/
function aggiungiMenuSubsetCaratteri() {
var $specialchars = $( '#specialchars' );
if ( $specialchars.length ) {
var $sel = $( '<select>' ),
// Oggetto del tipo { ID sottosezione : Nome da mostrare }
options = {
'Latino': 'Latino esteso',
'Wiki': 'Wiki',
'Greco_antico': 'Greco antico',
'Greco_moderno': 'Greco moderno',
'Cirillico': 'Cirillico',
'Arabo': 'Arabo',
'Ebraico': 'Ebraico e yiddish',
'Armeno': 'Armeno',
'Geroglifico': 'Geroglifico',
'Vietnamita': 'Vietnamita',
'IPA': 'IPA',
'Matematico': 'Matematica'
};
for( var id in options ) {
$sel.append( $( '<option>', {
text: options[ id ],
value: id
} ) );
}
$sel.css( 'display', 'inline' );
$sel.on( 'change', function() {
scegliSubsetCaratteri( $( this ).val() );
} );
$specialchars.prepend( $sel );
/* default subset - try to use a cookie some day */
scegliSubsetCaratteri( 'Latino' );
}
}
/*
* select subsection of special characters
* @param {string} val ID dell'elemento selezionato
*/
function scegliSubsetCaratteri( val ) {
var $l = $( '#specialchars p' );
$l.each( function() {
$( this ).toggle( $( this ).attr( 'id' ) === val );
$( this ).css( 'visibility', $( this ).attr( 'id' ) === val ? 'visible' : 'hidden' );
} );
}
$( aggiungiMenuSubsetCaratteri );
// END Menu caratteri speciali
/**
* Funzione di appoggio per template titolo errato e simili.
* Importata da itwp, https://it.wikipedia.org/w/index.php?title=MediaWiki:Common.js&oldid=102712037
*/
function checkRealTitleBanner() {
/**
* Possibilità di disabilitarlo.
* (Sì. Può essere fastidioso... :)
*/
if ( window.disableCheckRealTitleBanner ) {
return;
}
var $realTitleBanner = $( '#RealTitleBanner' );
if ( $realTitleBanner.length && !$( '#DisableRealTitle' ).length ) {
var $realTitle = $realTitleBanner.find( '#RealTitle' );
var $firstH1 = $( 'h1:first' );
if ( $realTitle.length && $firstH1.length ) {
$realTitleBanner.hide();
$firstH1.html( $realTitle.html() );
document.title = $realTitle.text() + ' - Wikipedia';
}
}
}
$( checkRealTitleBanner );
/** Fix al layout della Pagina principale *********************************************************
*
* Descrizione: Aggiunge un link alla lista completa di tutte
* le wikipedia in tutte le lingue disponibili.
* Da un codice di: [[en:User:AzaToth]], [[en:User:R. Koot]]
* Sistemato da: [[n:Utente:Tooby]] <--- liberi di giustiziarlo
*/
function mainPageAppendCompleteListLink() {
var $link = $( '<a>' )
.attr( 'href', '//meta.wikimedia.org/wiki/Lista_di_Wikipedie' )
.text( 'Lista completa' );
var $liNode = $( '<li>' )
.append( $link )
.addClass( 'interwiki-completelist' );
$( "#p-lang div ul" )
.addClass( 'interwiki-completelist' )
.append( $liNode );
}
if ( mw.config.get( 'wgIsMainPage' ) ) {
$( mainPageAppendCompleteListLink );
}
/**
* Codice per il template galleria, importato da itwp.
* https://it.wikipedia.org/w/index.php?title=MediaWiki:Common.js&oldid=102712037
*/
function updateImageGroup( currImg, $images, $countInfo, $prevLink, $nextLink ) {
$images.hide().eq( currImg ).show();
$countInfo.html( '(' + ( currImg + 1 ) + '/' + $images.length + ')' );
$prevLink.toggle( currImg !== 0 );
$nextLink.toggle( currImg !== $images.length - 1 );
}
function initImageGroup() {
$( 'div.ImageGroup > div.ImageGroupUnits' ).each( function( i, imageGroupUnits ) {
var currImg = 0;
var $images = $( imageGroupUnits ).children( '.center' );
var $countInfo = $( '<kbd>' ).css( 'font-size', '110%' );
var $prevLink = $( '<a>' )
.attr( 'href', '#' ).attr( 'title', 'Immagine precedente' )
.text( '◀' ).css( 'text-decoration', 'none' )
.click( function( e ) {
e.preventDefault();
updateImageGroup( currImg -= 1, $images, $countInfo, $prevLink, $nextLink );
} );
var $nextLink = $( '<a>' )
.attr( 'href', '#' ).attr( 'title', 'Immagine successiva' )
.text( '▶' ).css( 'text-decoration', 'none' )
.click( function( e ) {
e.preventDefault();
updateImageGroup( currImg += 1, $images, $countInfo, $prevLink, $nextLink );
} );
updateImageGroup( currImg, $images, $countInfo, $prevLink, $nextLink );
$( imageGroupUnits ).prepend( $prevLink, $countInfo, $nextLink );
} );
}
$( initImageGroup );
// Toglie "Soggetto/Intestazione" nelle creazioni delle discussioni al Bar
if ( mw.config.get( 'wgNamespaceNumber' ) === 4 &&
mw.config.get( 'wgPageName' ).indexOf( "Wikipedia:Bar/" ) === 0 &&
mw.config.get( 'wgAction' ) === "edit" &&
document.URL.indexOf( "§ion=new&preload=" ) !== -1
) {
$( function() {
$( '#wpSummaryLabel' ).hide();
$( '#wpSummary' ).hide();
} );
}
// In futuro andrebbe spostato in un gadget attivato di default come su itwp
mw.loader.load( '//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript' );
}( mediaWiki, jQuery ) );