MediaWiki:InterProject.js

Da Wikiquote, aforismi e citazioni in libertà.

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 menu Strumenti → Preferenze; per Internet Explorer: mantenere premuto il tasto Ctrl mentre si preme il pulsante Aggiorna o premere Ctrl-F5.

/**
 * 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ù
 */
/*global mediaWiki, jQuery */

( function ( mw, $ ) {
	'use strict';

	function updateOtherProjectsFromTemplate() {
		// Aggiorna i link dei progetti presenti su Wikidata
		$( '.wb-otherproject-wikibooks a' ).attr( 'href', $( "#interProject ul li:contains('Wikibooks') a" ).attr( 'href' ) );
		$( '.wb-otherproject-wikisource a' ).attr( 'href', $( "#interProject ul li:contains('Wikisource') a" ).attr( 'href' ) );
		$( '.wb-otherproject-wikiquote a' ).attr( 'href', $( "#interProject ul li:contains('Wikiquote') a" ).attr( 'href' ) );
		$( '.wb-otherproject-wikinews a' ).attr( 'href', $( "#interProject ul li:contains('Wikinotizie') a" ).attr( 'href' ) );
		$( '.wb-otherproject-commons a' ).attr( 'href', $( "#interProject ul li:contains('Commons') a" ).attr( 'href' ) );
		$( '.wb-otherproject-wikivoyage a' ).attr( 'href', $( "#interProject ul li:contains('Wikivoyage') a" ).attr( 'href' ) );
		$( '.wb-otherproject-species a' ).attr( 'href', $( "#interProject ul li:contains('Wikispecies') a" ).attr( 'href' ) );
		$( '.wb-otherproject-meta a' ).attr( 'href', $( "#interProject ul li:contains('Meta-Wiki') a" ).attr( 'href' ) );
		$( '.wb-otherproject-mediawiki a' ).attr( 'href', $( "#interProject ul li:contains('Mediawiki') a" ).attr( 'href' ) );
		$( '.wb-otherproject-wikiversity a' ).attr( 'href', $( "#interProject ul li:contains('Wikiversità') a" ).attr( 'href' ) );
		$( '.wb-otherproject-wiktionary a' ).attr( 'href', $( "#interProject ul li:contains('Wikizionario') a" ).attr( 'href' ) );
	}

	function buildOtherProjectsFromTemplate() {
		var $span = $( '<span>' )
			.addClass( 'vector-menu-heading-label' )
			.text( mw.msg( 'wikibase-otherprojects' ) );
		var $label = $( '<label>' )
			.attr( 'id', 'p-wikibase-otherprojects-label' )
			.addClass( 'vector-menu-heading' )
			.append( $span );
		var $ul = $( '<ul>' )
			.addClass( 'vector-menu-content-list' )
			.html( $( '#interProject > ul' ).html() );
		var $div = $( '<div>' )
			.addClass( 'vector-menu-content' )
			.append( $ul );

		$( '<nav>' )
			.attr( 'id', 'p-wikibase-otherprojects' )
			.addClass( 'mw-portlet mw-portlet-wikibase-otherprojects vector-menu vector-menu-portal portal' )
			.append( $label, $div )
			.insertAfter( $( '#p-tb, #p-coll-print_export' ).last() );
	}
 
	$( function () {
		if ( window.disableInterProjectJS || !document.getElementById( 'interProject' ) ) {
			return;
		}
		if ( document.getElementById( 'p-wikibase-otherprojects' ) ) {
			updateOtherProjectsFromTemplate();
		} else {
			mw.loader.using( 'mediawiki.api' )
				.then( function () {
					return new mw.Api().loadMessagesIfMissing( [ 'wikibase-otherprojects' ] );
				} )
				.done( buildOtherProjectsFromTemplate )
				.fail( function () {
					console.error( 'Impossibile avviare l\'accessorio InterProject.' );
				} );
		}
	} );
}( mediaWiki, jQuery ) );