Utente:FRacco/Sandbox2: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
D'oh!!!
ripulisco!
Riga 1:
 
== Aggiornamento codici dicembre 2013 ...D'OH! ==
 
=== [[MediaWiki:Common.js]] ===
<pre>
/* Il codice JavaScript inserito qui viene caricato da ciascuna pagina, per tutti gli utenti */
 
// <nowiki> Codice JavaScript: inizio...
 
/* Modifica il testo della linguetta "Voce" in "Pagina principale"
* e aggiunge il link all'elenco completo di tutte le lingue
*
* Ultimo controllo al codice: 12/12/2013 */
 
if ( mw.config.get( 'wgIsMainPage' ) || mw.config.get( 'wgPageName' ) === 'Discussione:Pagina_principale' ) {
$( document ).ready( function() {
if ( mw.config.get( 'wgUserLanguage' ) === 'it' )
$( '#ca-nstab-main a' ).text( 'Pagina principale' );
mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/Wikiquote/it#Lista_delle_Wikiquote',
'Elenco completo', 'interwiki-completelist', 'Elenco completo delle Wikiquote' );
} );
};
 
 
/* Change Special:Search to use a drop-down menu
*
* Description: Change Special:Search to use a drop-down menu,
* with the default being the internal MediaWiki engine
*
* Created and maintained by: [[w:en:User:Gracenotes]]
*
* Ultimo controllo al codice: 20/02/2014 */
 
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' )
$( function() {
var searchEngines = [];
var createOption = function( site, action, mainQ, addQ, addV ) {
var opt = document.createElement( 'option' );
opt.appendChild( document.createTextNode( site ) );
searchEngines[searchEngines.length] = [action, mainQ, addQ, addV];
return opt;
};
 
var searchForm = document.forms['powersearch'] || document.forms['search'];
var searchBox = searchForm.lsearchbox || searchForm.search;
var selectBox = document.createElement( 'select' );
selectBox.id = 'searchEngine';
searchForm.onsubmit = function() {
var optSelected = searchEngines[document.getElementById( 'searchEngine' ).selectedIndex];
searchForm.action = optSelected[0];
searchBox.name = optSelected[1];
searchForm.title.value = optSelected[3];
searchForm.title.name = optSelected[2];
};
 
selectBox.appendChild( createOption( 'MediaWiki', mw.config.get( 'wgScriptPath' ) + '/index.php', 'search', 'title', 'Special:Search' ) );
selectBox.appendChild( createOption( 'Google', '//www.google.com/search', 'q', 'sitesearch', 'it.wikiquote.org') );
selectBox.appendChild( createOption( 'Yahoo', 'http://search.yahoo.com/search', 'p', 'vs', 'it.wikiquote.org') );
selectBox.appendChild( createOption( 'Windows Live', 'http://search.live.com/results.aspx', 'q', 'q1', 'site:it.wikiquote.org' ) );
searchBox.style.marginLeft = '0px';
 
// 'searchText' is the firt search text. 'powerSearchText' is the second, used only if the first is not existent (e.g.: not yet done any search)
buttonSearch = document.getElementById( 'searchText' ) || document.getElementById( 'powerSearchText' );
buttonSearch.parentNode.insertBefore( selectBox, buttonSearch.nextSibling );
} );
 
 
/* Correzione della posizione del link [modifica] delle sezioni.
*
* Copyright 2006, Marc Mongenet
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* See www.gnu.org/licenses/gpl.html
*
* The function looks for <span class="mw-editsection">, and move them
* at the end of their parent and display them inline in small font.
* var oldEditsectionLinks=true disables the function.
*
* Ultimo controllo al codice: 12/12/2013 */
 
var setModifySectionStyle = $( function() {
try {
if ( !( typeof oldEditsectionLinks == 'undefined' || oldEditsectionLinks == false ) ) return;
var spans = document.getElementsByTagName( 'span' );
for ( var s = 0; s < spans.length; s++ ) {
var span = spans[s];
if ( span.className == 'mw-editsection' ) {
span.style.fontSize = 'x-small';
span.style.fontWeight = 'normal';
span.style.cssFloat = span.style.styleFloat = 'none';
span.parentNode.appendChild( document.createTextNode( ' ' ) );
span.parentNode.appendChild( span );
}
}
} catch (e) { /* something went wrong */ }
} );
 
$( document ).ready( setModifySectionStyle );
 
 
/* Test if an element has a certain class
*
* Description: Uses regular expressions and caching for better performance.
* Maintainers: [[wikt:en:User:Mike Dillon]], [[w:en:User:R. Koot]], [[w:en:User:SG]]
*
* Ultimo controllo al codice: 12/12/2013 */
 
// DEPRECATO; sostituito con $( element ).hasClass( className )
 
var hasClass = function( element, className ) {
return $( element ).hasClass( className );
};
 
 
/* Working-code of "Metaboxes"
*
* Descrizione: Codice di gestione del [[Template:Metabox]]
*
* Vedi: [[w:ca:Plantilla:Metacaixa]]
* Creato da: [[w:ca:User:Peleguer]]
*
* Traduzione delle variabili:
*
* MetaCaixa = MetaBox
* MetaCaixaInit = inizializza i metabox
* MetaCaixaMostraPestanya = mostra la scheda del metabox
* mc/Mc = metabox
* bt/Bt = bottone
* ps/Ps = scheda
* mcBoto = bottone del metabox
* mcBotoSel = bottone selezionato del metabox
* mcContingut = contenuto del metabox
* mcPestanya = scheda del metabox
*
* Ultimo controllo al codice: 12/12/2013 */
 
function MetaCaixaInit() {
 
// Se ci sono dei metabox nella pagina, assegna gli eventi ai bottoni
 
var i = 0; //inizializza il contatore dei metabox
for ( i = 0; i <= 9; i++ ) {
var vMc = document.getElementById( "mc" + i );
if ( !vMc ) break;
var j = 1; //inizializza il contatore dei bottoni del metabox
var vPsIni = 0; //inizializza la scheda visibile inizialmente
for ( j = 1; j <= 9; j++ ) {
var vBt = document.getElementById( "mc" + i + "bt" + j );
if ( !vBt ) break;
vBt.onclick = MetaCaixaMostraPestanya; //assegna ad ogni bottone l'evento onclick
if ( vBt.className === "mcBotoSel" )
vPsIni = j; //memorizza la scheda visibile inizialmente
}
if (vPsIni === 0) { //se non c'è una scheda visibile inizialmente, ne assegna una casuale
vPsIni = 1 + Math.floor( ( j - 1 ) * Math.random() );
document.getElementById( "mc" + i + "ps" + vPsIni ).style.display = "block";
document.getElementById( "mc" + i + "ps" + vPsIni ).style.visibility = "visible";
document.getElementById( "mc" + i + "bt" + vPsIni ).className = "mcBotoSel";
}
}
};
 
function MetaCaixaMostraPestanya() {
 
// Eseguita al click sul bottone della scheda,
// rende visibile la scheda selezionata, nasconde le altre
 
var vMcNom = this.id.substr( 0, 3 ); //dal nome del pulsante, si deduce il nome del metabox
var vIndex = this.id.substr( 5, 1 ); //e l'indice della scheda
var i = 1;
for ( i = 1; i <= 9; i++ ) { //ricerca tutte le schede del metabox
var vPsElem = document.getElementById( vMcNom + "ps" + i );
if ( !vPsElem ) break;
if ( vIndex == i ) { //se la scheda è quella selezionata, la visualizza e aggiorna il bottone
vPsElem.style.display = "block";
vPsElem.style.visibility = "visible";
document.getElementById( vMcNom + "bt" + i ).className = "mcBotoSel";
} else { //altrimenti la nasconde e aggiorna il bottone
vPsElem.style.display = "none";
vPsElem.style.visibility = "hidden";
document.getElementById( vMcNom + "bt" + i ).className = "mcBoto";
}
}
return false; //evita di ricaricare la pagina
};
 
$( document ).ready( MetaCaixaInit );
 
 
/* Simula i titoli delle sezioni senza indicizzazione e senza link di modifica
*
* Per garantire l'accessibilità anche agli utenti che non utilizzano JavaScript
* nel [[Mediawiki:Common.css]] vengono definite le classi: nojs-h1... h2/h3/h4/h5/h6,
* che qui vengono rimosse.
*
* Vedi: [[Template:Titolo sezione]]
* Creato da: [[q:it:User:FRacco]]
*
* Ultimo controllo al codice: 12/12/2013 */
 
var headersClass = $( function() {
for ( j = 1; j <= 6; j++ ) {
$( ".h" + j ).removeClass( "nojs-h" + j ).html( function( undefined, text ) {
return "<h" + j + ">" + text + "</h" + j + ">";
} );
};
} );
 
$( document ).ready( headersClass );
 
 
/* Collegamento diretto alla pagina di upload di Commons nel portlet Strumenti */
 
$( function() {
mw.util.addPortletLink( 'p-tb', '//commons.wikimedia.org/wiki/Special:UploadWizard', 'Carica su Commons',
't-uploadcommons', 'Carica file multimediali su Commons', 'm', '#t-specialpages');
} );
 
 
/* Attiva i pulsanti per Wikiquote della la barra di modifica (versione classica e versione avanzata) */
 
importScript( "MediaWiki:Toolbar.js" );
 
 
/* Attiva la visualizzazione delle note sopra la nota stessa all'interno di un riquadro (REFERENCE TOOLTIP) */
 
importScript( "MediaWiki:ReferenceTooltip.js" );
importStylesheet( "MediaWiki:ReferenceTooltip.css" );
 
 
/* Attiva tutti gli effetti di apertura e chiusura di oggetti e tabelle "collassabili" */
 
importScript( "MediaWiki:Apri-chiudi.js" );
importStylesheet( "MediaWiki:Apri-chiudi.css" );
 
 
/* Più lingue selezionabili: importazione da Commons */
 
mw.loader.load( '//commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-LanguageSelect.js&action=raw&ctype=text/javascript' );
 
 
/* Interprogetto: importazione da Commons
*
* Funzione di gestione dei collegamenti dell'interprogetto nella barra di sinistra */
 
mw.loader.load( '//commons.wikimedia.org/w/index.php?title=MediaWiki:InterProject.js&action=raw&ctype=text/javascript' );
 
// Codice JavaScript: ...fine </nowiki>
</pre>
 
----
 
== Aggiornamento codici dicembre 2013 ==
 
=== [[MediaWiki:Monobook.js]] ===
<pre>
/* Il codice JavaScript inserito qui viene caricato dagli utenti che usano la skin Monobook */
 
/* attualmente non c'è necessità di alcun codice specifico per questa skin */
</pre>
 
=== [[MediaWiki:Vector.js]] ===
<pre>
/* Il codice JavaScript inserito qui viene caricato dagli utenti che usano la skin Vector */
 
/* attualmente non c'è necessità di alcun codice specifico per questa skin */
</pre>
 
=== [[MediaWiki:Common.js]] ===
<pre>
/* Il codice JavaScript inserito qui viene caricato da ciascuna pagina, per tutti gli utenti */
 
// <no<nowiki></nowiki>wiki> Codice JavaScript: inizio...
 
/* Modifica il testo della linguetta "Voce" in "Pagina principale"
* e aggiunge il link all'elenco completo di tutte le lingue
*
* Ultimo controllo al codice: 12/12/2013 */
 
if ( mw.config.get( 'wgIsMainPage' ) || mw.config.get( 'wgPageName' ) === 'Discussione:Pagina_principale' ) {
$( document ).ready( function() {
if ( mw.config.get( 'wgUserLanguage' ) === 'it' )
$( '#ca-nstab-main a' ).text( 'Pagina principale' );
mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/Wikiquote/it#Lista_delle_Wikiquote',
'Elenco completo', 'interwiki-completelist', 'Elenco completo delle Wikiquote' );
} );
};
 
 
/* Change Special:Search to use a drop-down menu
*
* Description: Change Special:Search to use a drop-down menu,
* with the default being the internal MediaWiki engine
*
* Created and maintained by: [[w:en:User:Gracenotes]]
*
* Ultimo controllo al codice: 12/12/2013 */
 
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' )
$( function() {
var searchEngines = [];
var createOption = function( site, action, mainQ, addQ, addV ) {
var opt = document.createElement( 'option' );
opt.appendChild( document.createTextNode( site ) );
searchEngines[searchEngines.length] = [action, mainQ, addQ, addV];
return opt;
};
 
var searchForm = document.forms['powersearch'] || document.forms['search'];
var searchBox = searchForm.lsearchbox || searchForm.search;
var selectBox = document.createElement( 'select' );
selectBox.id = 'searchEngine';
searchForm.onsubmit = function() {
var optSelected = searchEngines[document.getElementById( 'searchEngine' ).selectedIndex];
searchForm.action = optSelected[0];
searchBox.name = optSelected[1];
searchForm.title.value = optSelected[3];
searchForm.title.name = optSelected[2];
};
 
selectBox.appendChild( createOption( 'MediaWiki', mw.config.get( 'wgScriptPath' ) + '/index.php', 'search', 'title', 'Special:Search' ) );
selectBox.appendChild( createOption( 'Google', '//www.google.com/search', 'q', 'sitesearch', 'it.wikiquote.org') );
selectBox.appendChild( createOption( 'Yahoo', '//search.yahoo.com/search', 'p', 'vs', 'it.wikiquote.org') );
selectBox.appendChild( createOption( 'Windows Live', '//search.live.com/results.aspx', 'q', 'q1', 'site:it.wikiquote.org' ) );
searchBox.style.marginLeft = '0px';
 
// 'searchText' is the firt search text. 'powerSearchText' is the second, used only if the first is not existent (e.g.: not yet done any search)
buttonSearch = document.getElementById( 'searchText' ) || document.getElementById( 'powerSearchText' );
buttonSearch.parentNode.insertBefore( selectBox, buttonSearch.nextSibling );
} );
 
 
/* Correzione della posizione del link [modifica] delle sezioni.
*
* Copyright 2006, Marc Mongenet
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* See www.gnu.org/licenses/gpl.html
*
* The function looks for <span class="mw-editsection">, and move them
* at the end of their parent and display them inline in small font.
* var oldEditsectionLinks=true disables the function.
*
* Ultimo controllo al codice: 12/12/2013 */
 
var setModifySectionStyle = $( function() {
try {
if ( !( typeof oldEditsectionLinks == 'undefined' || oldEditsectionLinks == false ) ) return;
var spans = document.getElementsByTagName( 'span' );
for ( var s = 0; s < spans.length; s++ ) {
var span = spans[s];
if ( span.className == 'mw-editsection' ) {
span.style.fontSize = 'x-small';
span.style.fontWeight = 'normal';
span.style.cssFloat = span.style.styleFloat = 'none';
span.parentNode.appendChild( document.createTextNode( ' ' ) );
span.parentNode.appendChild( span );
}
}
} catch (e) { /* something went wrong */ }
} );
 
$( document ).ready( setModifySectionStyle );
 
 
/* Test if an element has a certain class
*
* Description: Uses regular expressions and caching for better performance.
* Maintainers: [[wikt:en:User:Mike Dillon]], [[w:en:User:R. Koot]], [[w:en:User:SG]]
*
* Ultimo controllo al codice: 12/12/2013 */
 
// DEPRECATO; sostituito con $( element ).hasClass( className )
 
var hasClass = function( element, className ) {
return $( element ).hasClass( className );
};
 
 
/* Working-code of "Metaboxes"
*
* Descrizione: Codice di gestione del [[Template:Metabox]]
*
* Vedi: [[w:ca:Plantilla:Metacaixa]]
* Creato da: [[w:ca:User:Peleguer]]
*
* Traduzione delle variabili:
*
* MetaCaixa = MetaBox
* MetaCaixaInit = inizializza i metabox
* MetaCaixaMostraPestanya = mostra la scheda del metabox
* mc/Mc = metabox
* bt/Bt = bottone
* ps/Ps = scheda
* mcBoto = bottone del metabox
* mcBotoSel = bottone selezionato del metabox
* mcContingut = contenuto del metabox
* mcPestanya = scheda del metabox
*
* Ultimo controllo al codice: 12/12/2013 */
 
function MetaCaixaInit() {
 
// Se ci sono dei metabox nella pagina, assegna gli eventi ai bottoni
 
var i = 0; //inizializza il contatore dei metabox
for ( i = 0; i <= 9; i++ ) {
var vMc = document.getElementById( "mc" + i );
if ( !vMc ) break;
var j = 1; //inizializza il contatore dei bottoni del metabox
var vPsIni = 0; //inizializza la scheda visibile inizialmente
for ( j = 1; j <= 9; j++ ) {
var vBt = document.getElementById( "mc" + i + "bt" + j );
if ( !vBt ) break;
vBt.onclick = MetaCaixaMostraPestanya; //assegna ad ogni bottone l'evento onclick
if ( vBt.className === "mcBotoSel" )
vPsIni = j; //memorizza la scheda visibile inizialmente
}
if (vPsIni === 0) { //se non c'è una scheda visibile inizialmente, ne assegna una casuale
vPsIni = 1 + Math.floor( ( j - 1 ) * Math.random() );
document.getElementById( "mc" + i + "ps" + vPsIni ).style.display = "block";
document.getElementById( "mc" + i + "ps" + vPsIni ).style.visibility = "visible";
document.getElementById( "mc" + i + "bt" + vPsIni ).className = "mcBotoSel";
}
}
};
 
function MetaCaixaMostraPestanya() {
 
// Eseguita al click sul bottone della scheda,
// rende visibile la scheda selezionata, nasconde le altre
 
var vMcNom = this.id.substr( 0, 3 ); //dal nome del pulsante, si deduce il nome del metabox
var vIndex = this.id.substr( 5, 1 ); //e l'indice della scheda
var i = 1;
for ( i = 1; i <= 9; i++ ) { //ricerca tutte le schede del metabox
var vPsElem = document.getElementById( vMcNom + "ps" + i );
if ( !vPsElem ) break;
if ( vIndex == i ) { //se la scheda è quella selezionata, la visualizza e aggiorna il bottone
vPsElem.style.display = "block";
vPsElem.style.visibility = "visible";
document.getElementById( vMcNom + "bt" + i ).className = "mcBotoSel";
} else { //altrimenti la nasconde e aggiorna il bottone
vPsElem.style.display = "none";
vPsElem.style.visibility = "hidden";
document.getElementById( vMcNom + "bt" + i ).className = "mcBoto";
}
}
return false; //evita di ricaricare la pagina
};
 
$( document ).ready( MetaCaixaInit );
 
 
/* Simula i titoli delle sezioni senza indicizzazione e senza link di modifica
*
* Per garantire l'accessibilità anche agli utenti che non utilizzano JavaScript
* nel [[Mediawiki:Common.css]] vengono definite le classi: nojs-h1... h2/h3/h4/h5/h6,
* che qui vengono rimosse.
*
* Vedi: [[Template:Titolo sezione]]
* Creato da: [[q:it:User:FRacco]]
*
* Ultimo controllo al codice: 12/12/2013 */
 
var headersClass = $( function() {
for ( j = 1; j <= 6; j++ ) {
$( ".h" + j ).removeClass( "nojs-h" + j ).html( function( undefined, text ) {
return "<h" + j + ">" + text + "</h" + j + ">";
} );
};
} );
 
$( document ).ready( headersClass );
 
 
/* Collegamento diretto alla pagina di upload di Commons nel portlet Strumenti */
 
$( function() {
mw.util.addPortletLink( 'p-tb', '//commons.wikimedia.org/wiki/Special:UploadWizard', 'Carica su Commons',
't-uploadcommons', 'Carica file multimediali su Commons', 'm', '#t-specialpages');
} );
 
 
/* Attiva i pulsanti per Wikiquote della la barra di modifica (versione classica e versione avanzata) */
 
importScript( "MediaWiki:Toolbar.js" );
 
 
/* Attiva la visualizzazione delle note sopra la nota stessa all'interno di un riquadro (REFERENCE TOOLTIP) */
 
importScript( "MediaWiki:ReferenceTool.js" );
importStylesheet( "MediaWiki:ReferenceTool.css" );
 
 
/* Attiva tutti gli effetti di apertura e chiusura di oggetti e tabelle "collassabili" */
 
importScript( "MediaWiki:Apri-chiudi.js" );
importStylesheet( "MediaWiki:Apri-chiudi.css" );
 
 
/* Più lingue selezionabili: importazione da Commons */
 
mw.loader.load( '//commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-LanguageSelect.js&action=raw&ctype=text/javascript' );
 
 
/* Interprogetto: importazione da Commons
*
* Funzione di gestione dei collegamenti dell'interprogetto nella barra di sinistra */
 
mw.loader.load( '//commons.wikimedia.org/w/index.php?title=MediaWiki:InterProject.js&action=raw&ctype=text/javascript' );
 
// Codice JavaScript: ...fine </no<nowiki></nowiki>wiki>
</pre>
 
=== [[MediaWiki:Toolbar.js]] ===
<pre>
// <no<nowiki></nowiki>wiki> Codice JavaScript: inizio...
 
/* Pulsanti predefiniti di Wikiquote per la barra degli strumenti di modifica (toolbar)
*
* Vedi: [[Aiuto:Barra degli strumenti di modifica]]
* Ultimo controllo al codice: 12/12/2013 */
 
/* Barra degli strumenti classica (mediawiki edit toolbar) */
 
var classicToolbarButtons = function() {
 
mw.toolbar.addButtons(
 
// aggiunge il pulsante per il "Redirect"
 
{
"imageFile": "//upload.wikimedia.org/wikipedia/commons/c/c8/Button_redirect.png",
"speedTip": "Redirect/Rinvia",
"tagOpen": "#RINVIA [[",
"tagClose": "]]",
"sampleText": "Nome della pagina di destinazione",
"imageId": "mw-toolbar-q-redirect"
},
 
// aggiunge il pulsante per una nuova riga
 
{
"imageFile": "//upload.wikimedia.org/wikipedia/commons/a/ac/Button_redir_rtl.png",
"speedTip": "Nuova riga",
"tagOpen": "<br /> ",
"tagClose": "",
"sampleText": "",
"imageId": "mw-toolbar-q-nuovariga"
},
 
// agiunge il pulsante per una nuova battuta al dialogo
 
{
"imageFile": "//upload.wikimedia.org/wikipedia/commons/1/11/Button_Nuvola_apps_edu_lang.png",
"speedTip": "Aggiungi una battuta al dialogo",
"tagOpen": "'''",
"tagClose": "''': Testo della battuta. <br />",
"sampleText": "Nome del personaggio",
"imageId": "mw-toolbar-q-battuta"
},
 
// aggiunge il pulsante per l'Ndr
 
{
"imageFile": "//upload.wikimedia.org/wikipedia/commons/c/c1/Button_city_silhouette.png",
"speedTip": "Inserisci NDR (usato per contestualizzazioni e/o bibliografie)",
"tagOpen": "{{NDR|",
"tagClose": "}}",
"sampleText": "nota di contestualizzazione o bibliografia",
"imageId": "mw-toolbar-q-ndr"
},
 
// aggiunge il pulsante per l'interprogetto
 
{
"imageFile": "//upload.wikimedia.org/wikipedia/commons/c/cb/Button_wikipedia.png",
"speedTip": "Inserisci collegamenti ad altri progetti Wikimedia",
"tagOpen": "\n==Altri progetti==\n{{interprogetto|w",
"tagClose": "}}\n",
"sampleText": "",
"imageId": "mw-toolbar-q-interprogetto"
},
 
// aggiunge il pulsante per le opere su Wikipedia
 
{
"imageFile": "//upload.wikimedia.org/wikipedia/commons/f/fb/Button_references2_new.png",
"speedTip": "Collegamento alla voce sull'opera in Wikipedia, da aggiungere alla sezione Altri progetti",
"tagOpen": "\n===Opere===\n{{Pedia|",
"tagClose": "|''Titolo dell'opera se diverso dal titolo della voce''|(anno)}}\n",
"sampleText": "Titolo della voce",
"imageId": "mw-toolbar-q-opere"
} );
};
 
/* Barra degli strumenti avanzata (wikiEditor toolbar) */
 
var wikiEditorButtons = function() {
 
// crea un nuovo gruppo "Wikiquote" nella sezione principale "main"
 
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'groups': {
'wikiquote': {
'label': 'Wikiquote'
}
}
} );
 
// aggiunge i pulsanti al gruppo "Wikiquote"
 
// aggiunge il pulsante per una nuova battuta al dialogo
 
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'wikiquote',
'tools': {
'battuta': {
label: 'Aggiungi una battuta al dialogo', //testo visualizzato al passaggio del mouse
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/b/b9/Nuvola_apps_edu_languages.png/22px-Nuvola_apps_edu_languages.png',
action: {
type: 'encapsulate',
options: {
pre: "'''", //testo prima
peri: "Nome del personaggio", //testo di esempio
post: "''': Testo della battuta. <br />" //testo dopo
}
}
}
}
} );
 
// aggiunge il pulsante per l'Ndr
 
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'wikiquote',
'tools': {
'ndr': {
label: 'Inserisci NDR (usato per contestualizzazioni e/o bibliografie)', //testo visualizzato al passaggio del mouse
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/c/c3/Emblem-pictures.svg/22px-Emblem-pictures.svg.png',
action: {
type: 'encapsulate',
options: {
pre: "{{NDR|", //testo prima
peri: "nota di contestualizzazione o bibliografia", //testo di esempio
post: "}}" //testo dopo
}
}
}
}
} );
 
// aggiunge il pulsante per l'interprogetto
 
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'wikiquote',
'tools': {
'interprogetto': {
label: 'Inserisci collegamenti ad altri progetti Wikimedia', //testo visualizzato al passaggio del mouse
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/8/80/Wikipedia-logo-v2.svg/22px-Wikipedia-logo-v2.svg.png',
action: {
type: 'encapsulate',
options: {
pre: "\n==Altri progetti==\n{{interprogetto|w", //testo prima
peri: "", //testo di esempio
post: "}}\n" //testo dopo
}
}
}
}
} );
 
// aggiunge il pulsante per le opere su Wikipedia
 
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'wikiquote',
'tools': {
'opere': {
label: 'Collegamento alla voce sull\'opera in Wikipedia, da aggiungere alla sezione Altri progetti', //testo visualizzato al passaggio del mouse
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/4/4b/Books-aj.svg_aj_ashton_01.svg/22px-Books-aj.svg_aj_ashton_01.svg.png',
action: {
type: 'encapsulate',
options: {
pre: "\n===Opere===\n{{Pedia|", //testo prima
peri: "Titolo della voce", //testo di esempio
post: "|''Titolo dell'opera se diverso dal titolo della voce''|(anno)}}\n" //testo dopo
}
}
}
}
} );
};
 
 
// Check if view is in edit mode and the required modules are available. Then, customize the toolbar...
// Note: usebetatoolbar can be used to check if a user is using the wikiEditor (true) or the old toolbar (false)
 
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
mw.loader.using( 'user.options', function() {
if ( mw.user.options.get( 'usebetatoolbar' ) ) {
mw.loader.using( 'ext.wikiEditor.toolbar', function() {
$( document ).ready( wikiEditorButtons );
} );
} else {
mw.loader.using( 'mediawiki.action.edit', function() {
$( classicToolbarButtons );
} );
}
} );
};
 
// Codice JavaScript: ...fine </no<nowiki></nowiki>wiki>
</pre>
 
=== [[MediaWiki:ReferenceTooltip.js]] ===
<pre>
// <no<nowiki></nowiki>wiki> Codice JavaScript: inizio...
 
/* REFERENCE TOOLTIPS - Vedi [[mw:Reference Tooltips]]
*
* Codice originale: [[w:en:MediaWiki:Gadget-ReferenceTooltips.js]]
*
* Ultimo controllo al codice: 12/12/2013 */
 
window.pg || $(document).ready( function($) {
 
// Make sure we are in article, project, or help namespace
if ( wgCanonicalNamespace === '' || wgCanonicalNamespace === 'Project' || wgCanonicalNamespace === 'Help' ) {
function toggleRT(o){
mw.loader.using("jquery.cookie",function(){
$.cookie("RTsettings",o+"|"+ settings[1] + "|" + settings[2], {path:"/",expires:90});
location.reload();
})
}
var settings = document.cookie.split("RTsettings=")[1];
settings = settings ? settings.split(";")[0].split("%7C") : [1, 200, +("ontouchstart" in document.documentElement)];
if( settings[0] == 0 ) {
var footer = $("#footer-places, #f-list");
if( footer.length === 0 ) {
footer = $("#footer li").parent();
}
footer.append($("<li>").append($("<a>").text("Abilita i tooltip delle note").attr("href","javascript:(function(){})()").click(function(){toggleRT(1)})));
return;
}
var isTouchscreen = +settings[2],
timerLength = isTouchscreen ? 0 : +settings[1],
settingsMenu;
$(".reference").each( function() {
var tooltipNode, hideTimer, showTimer, checkFlip = false;
function findRef( h ){
h = h.firstChild.getAttribute("href"); h = h && h.split("#"); h = h && h[1];
h = h && document.getElementById( h );
h = h && h.nodeName == "LI" && h;
return h;
}
function hide( refLink ){
if( tooltipNode && tooltipNode.parentNode == document.body ) {
hideTimer = setTimeout( function() {
$(tooltipNode).animate({opacity: 0}, 100, function(){ document.body.removeChild( tooltipNode ) })
}, isTouchscreen ? 16 : 100)
} else {
var h = findRef( refLink );
h && (h.style.border = "");
}
}
function show(){
if( !tooltipNode.parentNode || tooltipNode.parentNode.nodeType === 11 ){
document.body.appendChild( tooltipNode );
checkFlip = true;
}
$(tooltipNode).stop().animate({opacity: 1}, 100)
clearTimeout( hideTimer );
}
function openSettingsMenu(){
if( settingsMenu ) {
settingsMenu.dialog( "open" );
} else {
settingsMenu = $("<form>").append(
$("<button>").css("width","100%").text("Disabilita i tooltip delle note").button().click(function(){toggleRT(0)}),
$("<br>"),
$("<small>").text("Una volta disabilitati, i tooltip delle note possono venire riabilitati grazie ad un link posto in fondo alla pagina."),
$("<hr>"),
$("<label>").text("Tempo prima dell'apparizione del tooltip (in millisecondi): ").append($("<input>").attr({"type":"number","value":settings[1],step:50,min:0,max:5000})),
$("<br>"),
$("<span>").text("I tooltip vengono attivati tramite:"),
$("<label>").append(
$("<input>").attr({"type":"radio", "name":"RTActivate", "checked":settings[2]==0&&"checked", "disabled":"ontouchstart" in document.documentElement&&"disabled"}),
"sosta del cursore sulla nota"
),
$("<label>").append(
$("<input>").attr({"type":"radio", "name":"RTActivate", "checked":settings[2]==1&&"checked"}),
"click sulla nota"
)
).submit(function(e){e.preventDefault()}).dialog({modal:true,width:500,title:"Preferenze",buttons:{"Salva le preferenze":function(){
var a = this.getElementsByTagName("input"),
b = +a[0].value;
$.cookie("RTsettings","1|"+ (b > -1 && b < 5001 ? b : settings[1]) + (a[1].checked ? "|0" : "|1"), {path:"/",expires:90});
location.reload();
}}});
}
}
$(this)[ isTouchscreen ? 'click' : 'hover' ](function( e ){
var _this = this;
if( isTouchscreen ) {
e.preventDefault();
(tooltipNode && tooltipNode.parentNode == document.body) || setTimeout( function(){
$( document.body ).on("click touchstart", function( e ) {
e = e || event;
e = e.target || e.srcElement;
for( ; e && !$( e ).hasClass( "referencetooltip" ) ; )
e = e.parentNode;
if( !e ){
clearTimeout( showTimer );
hide( _this );
$(document.body).off("click touchstart", arguments.callee)
}
})
}, 0);
}
showTimer && clearTimeout( showTimer );
showTimer = setTimeout( function() {
var h = findRef( _this );
if( !h ){return};
if( !isTouchscreen && ( window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0 ) + $(window).height() > $( h ).offset().top + h.offsetHeight ) {
h.style.border = "#080086 2px solid";
return;
}
if(!tooltipNode){
tooltipNode = document.createElement("ul");
tooltipNode.className = "referencetooltip";
var c = tooltipNode.appendChild( h.cloneNode( true ) );
try {
if( c.firstChild.nodeName != "A" ) {
while( c.childNodes[1].nodeName == "A" && c.childNodes[1].getAttribute( "href" ).indexOf("#cite_ref-") !== -1 ) {
do { c.removeChild( c.childNodes[1] ) } while ( c.childNodes[1].nodeValue == " " );
}
}
} catch (e) { mw.log(e) }
c.removeChild( c.firstChild );
$( tooltipNode.firstChild.insertBefore( document.createElement( "span" ), tooltipNode.firstChild.firstChild ) ).addClass("RTsettings").attr("title", "Preferenze").click(function(){
mw.loader.using(["jquery.cookie","jquery.ui.dialog"], openSettingsMenu);
})
tooltipNode.appendChild( document.createElement( "li" ) );
isTouchscreen || $(tooltipNode).hover(show, hide);
}
show();
var o = $(_this).offset(), oH = tooltipNode.offsetHeight;
$(tooltipNode).css({top: o.top - oH, left: o.left - 7 });
if( tooltipNode.offsetHeight > oH ) { // is it squished against the right side of the page?
$(tooltipNode).css({left:'auto',right:0});
tooltipNode.lastChild.style.marginLeft = (o.left - tooltipNode.offsetLeft) + "px";
}
if( checkFlip ) {
if( o.top < tooltipNode.offsetHeight + ( window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0 ) ) { // is part of it above the top of the screen?
$(tooltipNode).addClass("RTflipped").css({top: o.top + 12});
} else if( tooltipNode.className === "referencetooltip RTflipped" ) { // cancel previous
$(tooltipNode).removeClass("RTflipped");
}
checkFlip = false;
}
}, timerLength);
}, isTouchscreen ? undefined : function(){clearTimeout(showTimer); hide(this); } )
} );
}
} );
 
// Codice JavaScript: ...fine </no<nowiki></nowiki>wiki>
</pre>
 
=== [[MediaWiki:Apri-chiudi.js]] ===
<pre>
// <no<nowiki></nowiki>wiki> Codice JavaScript: inizio...
 
/* Dynamic Navigation Bars
*
* Vedi: [[w:en:Wikipedia:NavFrame]]
*
* Codice originale: [[w:en:MediaWiki:Common.js]]
* integrato con: [[w:it:MediaWiki:Common.js]]
* da: [[q:it:User:FRacco]]
*
* Ultimo controllo al codice: 12/12/2013 */
 
// set up the words in your language
 
var NavigationBarHide = "« Nascondi";
var NavigationBarShow = "» Mostra";
 
// set up max count of Navigation Bars on page, if there are more (or equal), all will be hidden
// NavigationBarShowDefault = 0; all bars will be hidden
// NavigationBarShowDefault = n; on pages with more than "n" bars all bars will be hidden
 
var NavigationBarShowDefault = 0;
 
// shows and hides content and picture (if available) of navigation bars
// Parameters:
// indexNavigationBar: the index of navigation bar to be toggled
 
window.toggleNavigationBar = function( indexNavigationBar, event ) {
var NavFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
var NavToggle = document.getElementById( 'NavToggle' + indexNavigationBar );
var NavChild;
 
if ( !NavFrame || !NavToggle ) {
return false;
}
 
// if shown now
 
if ( NavToggle.firstChild.data === NavigationBarHide ) {
for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
NavChild.style.display = 'none';
}
}
NavToggle.firstChild.data = NavigationBarShow;
 
// if hidden now
 
} else if ( NavToggle.firstChild.data === NavigationBarShow ) {
for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
NavChild.style.display = 'block';
}
}
NavToggle.firstChild.data = NavigationBarHide;
}
 
if ( event ) event.preventDefault();
};
 
// adds show/hide-button to navigation bars
 
function createNavigationBarToggleButton() {
var indexNavigationBar = 0;
var NavFrame;
var NavChild;
 
// iterate over all div-elements
 
var divs = document.getElementsByTagName( 'div' );
for ( var i = 0; ( NavFrame = divs[i] ); i++ ) {
 
// if found a navigation bar
 
if ( $( NavFrame ).hasClass( 'NavFrame' ) ) {
indexNavigationBar++;
var NavToggle = document.createElement( 'a' );
NavToggle.className = 'NavToggle';
NavToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
NavToggle.setAttribute( 'href', '#' );
$( NavToggle ).on( 'click', $.proxy( window.toggleNavigationBar, window, indexNavigationBar ) );
 
var isCollapsed = $( NavFrame ).hasClass( 'collapsed' );
 
/* Check if any children are already hidden. This loop is here for backwards compatibility:
* the old way of making NavFrames start out collapsed was to manually add style="display:none"
* to all the NavPic/NavContent elements. Since this was bad for accessibility (no way to make
* the content visible without JavaScript support), the new recommended way is to add the class
* "collapsed" to the NavFrame itself, just like with collapsible tables. */
 
for ( NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling ) {
if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
if ( NavChild.style.display === 'none' ) {
NavFrame.className += ' collapsed';
isCollapsed = true;
}
}
}
 
if ( isCollapsed ) {
for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
NavChild.style.display = 'none';
}
}
}
 
var NavToggleText = document.createTextNode( isCollapsed ? NavigationBarShow : NavigationBarHide );
NavToggle.appendChild( NavToggleText );
 
// add NavToggle-Button as first div-element in < div class="NavFrame" >
 
/* Find the NavHead and attach the toggle link
* (Must be this complicated because Moz's firstChild handling is borked) */
 
for ( var j = 0; j < NavFrame.childNodes.length; j++ ) {
if ( $( NavFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {
NavToggle.style.color = NavFrame.childNodes[j].style.color;
NavFrame.childNodes[j].appendChild( NavToggle );
}
}
NavFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
}
}
 
// if more (or equal) Navigation Bars found than Default: hide all
// (except for ones defined with "collapsed" or "expanded" class)
 
if ( indexNavigationBar >= NavigationBarShowDefault ) {
for ( var i = 1; i <= indexNavigationBar; i++ ) {
NavFrame = document.getElementById( 'NavFrame' + i );
if ( !$( NavFrame ).hasClass( 'collapsed' ) && !$( NavFrame ).hasClass( 'expanded' ) )
window.toggleNavigationBar( i );
}
}
};
 
mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );
 
 
/* Tabelle collassabili (CollapsibleTables)
*
* Descrizione: Permette alle tabelle di espandersi e contrarsi, mostrando solo il titolo.
*
* Vedi: [[w:en:Wikipedia:Collapsible tables]]
*
* Codice originale: [[w:en:MediaWiki:Common.js]]
* Mantenimento: [[w:en:User:R. Koot]]
*
* Ultimo controllo al codice: 12/12/2013 */
 
// set up the words in your language
 
var collapseCaption = "▲ Nascondi";
var expandCaption = "▼ Mostra";
 
// set up max count of collapsible tables on page,
// if there are more (or equal), all ".autocollapse"
// tables will be hidden
 
var autoCollapse = 2;
 
window.collapseTable = function( tableIndex ) {
var Button = document.getElementById( "collapseButton" + tableIndex );
var Table = document.getElementById( "collapsibleTable" + tableIndex );
 
if ( !Table || !Button ) {
return false;
}
 
var Rows = Table.rows;
var i;
 
if ( Button.firstChild.data === collapseCaption ) {
for ( i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = "none";
}
Button.firstChild.data = expandCaption;
} else {
for ( i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = Rows[0].style.display;
}
Button.firstChild.data = collapseCaption;
}
};
 
function createCollapseButtons() {
var tableIndex = 0;
var NavigationBoxes = {};
var Tables = document.getElementsByTagName( "table" );
var i;
function handleButtonLink( index, e ) {
window.collapseTable( index );
e.preventDefault();
}
 
for ( i = 0; i < Tables.length; i++ ) {
if ( $( Tables[i] ).hasClass( "collapsible" ) ) {
 
// aggiunge il pulsante e il numero di incremento soltanto se c'è una riga di intestazione per lavorarci
 
var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0];
if (!HeaderRow) continue;
var Header = HeaderRow.getElementsByTagName( "th" )[0];
if (!Header) continue;
 
NavigationBoxes[ tableIndex ] = Tables[i];
Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
 
var Button = document.createElement( "span" );
var ButtonLink = document.createElement( "a" );
var ButtonText = document.createTextNode( collapseCaption );
 
Button.className = "collapseButton";
/* gli stili sono dichiarati nel relativo Cascading Style Sheet (CSS) */
 
ButtonLink.style.color = Header.style.color;
ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
ButtonLink.setAttribute( "href", "#" );
$( ButtonLink ).on( "click", $.proxy( handleButtonLink, ButtonLink, tableIndex ) );
ButtonLink.appendChild( ButtonText );
 
Button.appendChild( document.createTextNode( "[" ) );
Button.appendChild( ButtonLink );
Button.appendChild( document.createTextNode( "]" ) );
 
Header.insertBefore( Button, Header.firstChild );
tableIndex++;
}
}
 
for ( i = 0; i < tableIndex; i++ ) {
if ( $( NavigationBoxes[i] ).hasClass( "collapsed" ) || ( tableIndex >= autoCollapse && $( NavigationBoxes[i] ).hasClass( "autocollapse" ) ) ) {
window.collapseTable( i );
}
else if ( $( NavigationBoxes[i] ).hasClass( "innercollapse" ) ) {
var element = NavigationBoxes[i];
while ( ( element = element.parentNode ) ) {
if ( $( element ).hasClass( "outercollapse" ) ) {
window.collapseTable ( i );
break;
}
}
}
}
}
 
mw.hook( 'wikipage.content' ).add( createCollapseButtons );
 
 
/* jQuery makeCollapsible modificato
*
* script iniziale: [[mw:RL/DM#jquery.makeCollapsible]]
* autore iniziale: Krinkle <krinklemail@gmail.com>
*
* modifiche eseguite da: [[w:fr:User:Lgd]]
*
* Doppia licenza:
* @licenza CC-BY 3.0 <creativecommons.org/licenses/by/3.0>
* @licenza GPL2 <www.gnu.org/licenses/old-licenses/gpl-2.0.html>
*
* Ultimo controllo al codice: 12/12/2013 */
 
// set up the words in your language
 
var collapsetextDef = "Nascondi";
var collapsetextAll = "Nascondi tutto";
var expandtextDef = "Mostra";
var expandtextAll = "Mostra tutto";
 
var newCollapsible = function( $ ) {
 
return $( '.it-collapsible' ).each( function() {
var _fn = 'jquery.newCollapsible> ';
 
// Define reused variables and functions
var $that = $( this ).addClass( 'it-collapsible' ), // case: $( '#myAJAXelement' ).newCollapsible()
that = this,
collapsetext = $( this ).attr( 'data-collapsetext' ),
expandtext = $( this ).attr( 'data-expandtext' ),
toggleElement = function( $collapsible, action, $defaultToggle, instantHide ) {
 
// Validate parameters
if ( !$collapsible.jquery ) { // $collapsible must be an instance of jQuery
return;
}
if ( action != 'expand' && action != 'collapse' ) {
// action must be string with 'expand' or 'collapse'
return;
}
if ( typeof $defaultToggle == 'undefined' ) {
$defaultToggle = null;
}
if ( $defaultToggle !== null && !( $defaultToggle instanceof $ ) ) {
// is optional (may be undefined), but if defined it must be an instance of jQuery.
// If it's not, abort right away.
// After this $defaultToggle is either null or a valid jQuery instance.
return;
}
 
var $containers = null;
 
if ( action == 'collapse' ) {
 
// Collapse the element
if ( $collapsible.is( 'table' ) && $collapsible.find( 'caption' ).length ) {
// only table with caption
// Hide all table rows of this table
// Slide doens't work with tables, but fade does as of jQuery 1.1.3
// http://stackoverflow.com/questions/467336#920480
$containers = $collapsible.find( '>tbody>tr' );
if ( $defaultToggle ) {
$containers.stop( true, true ).fadeOut();
} else {
if ( instantHide ) {
$containers.hide();
} else {
$containers.stop( true, true ).fadeOut();
}
}
 
} else if ( !$collapsible.is( 'ul' ) && !$collapsible.is( 'ol' ) && !$that.is( 'table' ) ) {
// <div>, <p> etc. but not ul ol and tables without caption
var $collapsibleContent = $collapsible.find( '> .it-collapsible-content' );
 
// If a collapsible-content is defined, collapse it
if ( $collapsibleContent.length ) {
if ( instantHide ) {
$collapsibleContent.hide();
} else {
$collapsibleContent.slideUp();
}
 
// Otherwise assume this is a customcollapse with a remote toggle...
// ...and there is no collapsible-content because the entire element should be toggled
} else {
if ( $collapsible.is( 'tr' ) || $collapsible.is( 'td' ) || $collapsible.is( 'th' ) ) {
$collapsible.fadeOut();
} else {
$collapsible.slideUp();
}
}
}
 
} else {
 
// Expand the element
if ( $collapsible.is( 'table' ) && $collapsible.find( 'caption' ).length ) {
$containers = $collapsible.find( '>tbody>tr' );
if ( $defaultToggle ) {
$containers.stop( true, true ).fadeIn();
} else {
$containers.stop( true, true ).fadeIn();
}
 
} else if ( !$collapsible.is( 'ul' ) && !$collapsible.is( 'ol' ) && !$that.is( 'table' ) ) {
// <div>, <p> etc.but not ul ol and not tables without caption
var $collapsibleContent = $collapsible.find( '> .it-collapsible-content' );
 
// If a collapsible-content is defined, collapse it
if ( $collapsibleContent.length ) {
$collapsibleContent.slideDown();
 
// Otherwise assume this is a customcollapse with a remote toggle...
// ...and there is no collapsible-content because the entire element should be toggled
} else {
if ( $collapsible.is( 'tr' ) || $collapsible.is( 'td' ) || $collapsible.is( 'th' ) ) {
$collapsible.fadeIn();
} else {
$collapsible.slideDown();
}
}
}
}
},
 
// Toggles collapsible and togglelink class and updates text label
toggleLinkDefault = function( that, e ) {
var $that = $(that),
$collapsible = $that.closest( '.it-collapsible.it-made-collapsible' ).toggleClass( 'it-collapsed' );
e.preventDefault();
e.stopPropagation();
 
// It's expanded right now
if ( !$that.hasClass( 'it-collapsible-toggle-collapsed' ) ) {
// Change link to "Show"
$that.removeClass( 'it-collapsible-toggle-expanded' ).addClass( 'it-collapsible-toggle-collapsed' );
if ( $that.find( '> a' ).length ) {
$that.find( '> a' ).text( expandtext );
} else {
$that.text( expandtext );
}
// Collapse element
toggleElement( $collapsible, 'collapse', $that );
 
// It's collapsed right now
} else {
// Change link to "Hide"
$that.removeClass( 'it-collapsible-toggle-collapsed' ).addClass( 'it-collapsible-toggle-expanded' );
if ( $that.find( '> a' ).length ) {
$that.find( '> a' ).text( collapsetext );
} else {
$that.text( collapsetext );
}
// Expand element
toggleElement( $collapsible, 'expand', $that );
}
return;
},
 
// Toggles collapsible and togglelink class
toggleLinkPremade = function( $that, e ) {
var $collapsible = $that.eq(0).closest( '.it-collapsible.it-made-collapsible' ).toggleClass( 'it-collapsed' );
if ( $( e.target ).is( 'a' ) ) {
return true;
}
e.preventDefault();
e.stopPropagation();
 
// It's expanded right now
if ( !$that.hasClass( 'it-collapsible-toggle-collapsed' ) ) {
// Change toggle to collapsed
$that.removeClass( 'it-collapsible-toggle-expanded' ).addClass( 'it-collapsible-toggle-collapsed' );
// Collapse element
toggleElement( $collapsible, 'collapse', $that );
 
// It's collapsed right now
} else {
// Change toggle to expanded
$that.removeClass( 'it-collapsible-toggle-collapsed' ).addClass( 'it-collapsible-toggle-expanded' );
// Expand element
toggleElement( $collapsible, 'expand', $that );
}
return;
},
 
// Toggles customcollapsible
toggleLinkCustom = function( $that, e, $collapsible ) {
// For the initial state call of customtogglers there is no event passed
if ( e ) {
e.preventDefault();
e.stopPropagation();
}
// Get current state and toggle to the opposite
var action = $collapsible.hasClass( 'it-collapsed' ) ? 'expand' : 'collapse';
$collapsible.toggleClass( 'it-collapsed' );
toggleElement( $collapsible, action, $that );
};
 
// Use custom text or default ?
if( !collapsetext ) {
//collapsetext = mw.message( 'collapsible-collapse' );
collapsetext = collapsetextDef;
}
if ( !expandtext ) {
//expandtext = mw.message( 'collapsible-expand' );
expandtext = expandtextDef;
}
 
// Create toggle link with a space around the brackets (&nbsp;[text]&nbsp;)
var $toggleLink =
$( '<a href="#"></a>' )
.text( collapsetext )
.wrap( '<span class="it-collapsible-toggle"></span>' )
.parent()
.bind( 'click.it-collapse', function( e ) {
toggleLinkDefault( this, e );
} );
 
// Return if it has been enabled already.
if ( $that.hasClass( 'it-made-collapsible' ) ) {
return;
} else {
$that.addClass( 'it-made-collapsible' );
}
 
// Check if this element has a custom position for the toggle link
// (ie. outside the container or deeper inside the tree)
// Then: Locate the custom toggle link(s) and bind them
if ( ( $that.attr( 'id' ) || '' ).indexOf( 'it-customcollapsible-' ) === 0 ) {
 
var thatId = $that.attr( 'id' ),
$customTogglers = $( '.' + thatId.replace( 'it-customcollapsible', 'it-customtoggle' ) );
mw.log( _fn + 'Found custom collapsible: #' + thatId );
 
// Double check that there is actually a customtoggle link
if ( $customTogglers.length ) {
$customTogglers.bind( 'click.it-collapse', function( e ) {
toggleLinkCustom( $( this ), e, $that );
} );
} else {
mw.log( _fn + '#' + thatId + ': Missing toggler!' );
}
 
// Initial state
if ( $that.hasClass( 'it-collapsed' ) ) {
$that.removeClass( 'it-collapsed' );
toggleLinkCustom( $customTogglers, null, $that );
}
 
// If this is not a custom case, do the default:
// Wrap the contents add the toggle link
} else {
 
// Elements are treated differently
if ( $that.is( 'table' ) && $that.find( 'caption' ).length ) { // only table with caption
// The toggle-link will be in the caption
var $caption = $( 'caption', that ),
$toggle = $caption.find( '> .it-collapsible-toggle' );
 
// If theres no toggle link, add it to the caption
if ( !$toggle.length ) {
$caption.eq( -1 ).prepend( $toggleLink );
} else {
$toggleLink = $toggle.unbind( 'click.it-collapse' ).bind( 'click.it-collapse', function( e ) {
toggleLinkPremade( $toggle, e );
} );
}
 
} else if ( !$that.is( 'ul' ) && !$that.is( 'ol' ) && !$that.is( 'table' ) ) {
// <div>, <p> etc.but not ol ul and not tables without caption
 
// The toggle-link will be the first child of the element
var $toggle = $that.find( '> .it-collapsible-toggle' );
 
// If a direct child .content-wrapper does not exists, create it
if ( !$that.find( '> .it-collapsible-content' ).length ) {
$that.wrapInner( '<div class="it-collapsible-content"></div>' );
}
 
// If theres no toggle link, add it
if ( !$toggle.length ) {
$that.prepend( $toggleLink );
} else {
$toggleLink = $toggle.unbind( 'click.it-collapse' ).bind( 'click.it-collapse', function( e ) {
toggleLinkPremade( $toggle, e );
} );
}
}
}
 
// Initial state (only for those that are not custom)
if ( $that.hasClass( 'it-collapsed' ) && ( $that.attr( 'id' ) || '' ).indexOf( 'it-customcollapsible-' ) !== 0 ) {
$that.removeClass( 'it-collapsed' );
// The collapsible element could have multiple togglers
// To toggle the initial state only click one of them (ie. the first one, eq(0))
// Else it would go like: hide, show, hide, show for each toggle link.
toggleElement( $that, 'collapse', $toggleLink.eq( 0 ), /* instantHide = */ true );
$toggleLink.eq( 0 ).click();
}
} );
};
 
var newAutoCollapse = function( $ ) {
// autocollaspe for "palettes"
var $navboxnew = $( '#content .navboxnew' );
if ( $navboxnew.length === 1 ) {
$navboxnew.filter( '.it-collapsed' ).not( '.uncollapsed, .collapsed' ).each( function() {
$( this ).find( 'span.it-collapsible-toggle a' ).first().click();
} );
}
};
 
var newCollapsibleKeyboard = function( $ ) {
$( '.it-collapsible-toggle, .it-collapsible-toggle-keyboard' ).attr( 'tabindex', 0 ).keypress( function( event ) {
if ( event.which == 13 ) {
$( this ).click()
}
} );
};
 
var newCollapsibleGroup = function( $ ) {
$( '.it-collapsible-group' ).each( function() {
var $that = $( this );
var text = expandtextAll;
var $tooglelink = $( '<a class="it-collapsible-toggle it-collapsible-toggle-collapsed it-collapsible-group-toogle-all" href="#">' + collapsetextAll + '</a>' );
$that.find( '.it-collapsible-group-toogle:first' ).append( $tooglelink ).click( function( event ) {
if( text === expandtextAll ) {
text = collapsetextAll;
$that.find( '.it-collapsible-toggle-collapsed:not(".it-collapsible-group-toogle-all")' ).click();
} else {
text = expandtextAll;
$that.find( '.it-collapsible-toggle-expanded:not(".it-collapsible-group-toogle-all")' ).click();
}
$tooglelink.text( text );
// Toggles collapsible and togglelink class and updates text label and group icon
$tooglelink.toggleClass( 'it-collapsible-toggle-collapsed' );
return false;
} );
} );
};
 
var newBeKindToIE = function( $ ) {
var ieVersion = $.client.profile().versionBase;
// gestion des listes horizontalisées
// remove bullet from last list items in IE 8 7 6
if ( ieVersion < 9 ) {
$( '#content .navboxnew_inline' ).find( 'li:last-child' ).addClass( 'navboxnew_last' );
}
// navbox for IE < 8
if ( ieVersion < 8 ) {
$( '#content .navboxnew' ).removeClass( 'navboxnew' ).addClass( 'navboxnew_oldie' );
}
};
 
if ( $.client.profile().name == 'msie' ) {
$( document ).ready( newBeKindToIE );
}
 
$( document ).ready( newCollapsible );
$( document ).ready( newAutoCollapse );
$( document ).ready( newCollapsibleKeyboard );
$( document ).ready( newCollapsibleGroup );
 
// Codice JavaScript: ...fine </no<nowiki></nowiki>wiki>
</pre>