MediaWiki:Gadget-InterProject-core.js

Da Wikipedia, l'enciclopedia libera.
Versione del 29 nov 2014 alle 19:35 di Andyrom75 (discussione | contributi) (Aggiunge i progetti non presenti su wikidata, se specificati nella chiamata del template interprogetto)
Vai alla navigazione Vai alla ricerca

Questa pagina definisce alcuni parametri di aspetto e comportamento generale di tutte le pagine. Per personalizzarli vedi Aiuto:Stile utente.


Nota: dopo aver salvato è necessario pulire la cache del proprio browser per vedere i cambiamenti (per le pagine globali è comunque necessario attendere qualche minuto). Per Mozilla / Firefox / Safari: fare clic su Ricarica tenendo premuto il tasto delle maiuscole, oppure premere Ctrl-F5 o Ctrl-R (Command-R su Mac); per Chrome: premere Ctrl-Shift-R (Command-Shift-R su un Mac); per Konqueror: premere il pulsante Ricarica o il tasto F5; per Opera può essere necessario svuotare completamente la cache dal menù Strumenti → Preferenze; per Internet Explorer: mantenere premuto il tasto Ctrl mentre si preme il pulsante Aggiorna o premere Ctrl-F5.

// <nowiki>
 
/**
 * Workaround for [[bugzilla:708]] via [[Template:InterProject]].
 * Originally based on code from [[wikt:de:MediaWiki:Common.js]] by [[wikt:de:User:Melancholie]],
 * cleaned up and modified for compatibility with the Vector skin.
 *
 * Maintainers: [[User:Krinkle]], [[User:Ilmari Karonen]]
 * Modified by: [[User:Andyrom75]]: modifica i link di quello beta, aggiunge i progetti mancanti, se spcificati nell'interprogetto, senza crearne il menù
 */
$( function () {
	var interPr = document.getElementById('interProject');
	var sisterPr = document.getElementById('sisterProjects');
	if (!interPr) return;
	if ( document.getElementById('p-wikibase-otherprojects') ){
		//Ai progetti già presenti su wikidata mi limito ad aggiornare il link
		$('.wb-otherproject-wikisource a'    ).attr("href", $("#interProject div ul li:contains('Wikisource') a"  ).attr("href"));
		$('.wb-otherproject-wikiquote a'     ).attr("href", $("#interProject div ul li:contains('Wikiquote') a"   ).attr("href"));
		$('.wb-otherproject-wikinews a'      ).attr("href", $("#interProject div ul li:contains('Wikinotizie') a" ).attr("href"));
		$('.wb-otherproject-commons a'       ).attr("href", $("#interProject div ul li:contains('Commons') a"     ).attr("href"));
		$('.wb-otherproject-wikivoyage a'    ).attr("href", $("#interProject div ul li:contains('Wikivoyage') a"  ).attr("href"));

		//Aggiungo i progetti mancanti su wikidata gestiti come link interno
		$('#p-wikibase-otherprojects div ul' ).append($("#interProject div ul li:contains('Wikibooks') a"    ).parent());
		$('#p-wikibase-otherprojects div ul' ).append($("#interProject div ul li:contains('Wikizionario') a" ).parent());
		$('#p-wikibase-otherprojects div ul' ).append($("#interProject div ul li:contains('Wikiversità') a"  ).parent());

		//Aggiungo i progetti mancanti su wikidata gestiti come link esterno
		$('#p-wikibase-otherprojects div ul' ).append($("#interProject div ul li:contains('Meta-Wiki') a"    ).parent().parent());
		$('#p-wikibase-otherprojects div ul' ).append($("#interProject div ul li:contains('Wikispecies') a"  ).parent().parent());
		return;
	}

	var toolBox = document.getElementById('p-coll-print_export');
	var panel;
	if (toolBox) {
		panel = toolBox.parentNode;
	} else {
		// stupid incompatible skins...
		var panelIds = ['mw-panel', 'panel', 'column-one', 'mw_portlets'];
		for (var i = 0; !panel && i < panelIds.length; i++) {
			 panel = document.getElementById(panelIds[i]);
		}
		// can't find a place for the portlet, try to undo hiding
		if (!panel) {
			mw.util.addCSS('#interProject, #sisterProjects { display: block; }');
			return;
		}
	}
 
	mw.util.addCSS('#interProject, #sisterProjects { display: none; }');
 
	var interProject = document.createElement("div");
	interProject.id = "p-wikibase-otherprojects";
 
	interProject.className = (mw.config.get('skin') == 'vector' ? 'portal' : 'portlet');
 
	interProject.innerHTML =
		'<h3>' +
		(sisterPr && sisterPr.firstChild ? sisterPr.firstChild.innerHTML : "Sister Projects") +
		'<\/h3><div class="' + (mw.config.get('skin') == "vector" ? "body" : "pBody") +'">' +
		interPr.innerHTML + '<\/div>';
 
	if (toolBox && toolBox.nextSibling) {
		panel.insertBefore(interProject, toolBox.nextSibling);
	} else {
		panel.appendChild(interProject);
	}
	var state = $.cookie('vector-nav-' + interProject.id);
	if (state === 'true') {
		$(interProject).addClass('expanded').find('.body, .pBody').show();
	} else {
		$(interProject).addClass('collapsed');
	}
} );