MediaWiki:Gadget-InterProject-core.js: differenze tra le versioni

Da Wikipedia, l'enciclopedia libera.
Vai alla navigazione Vai alla ricerca
Contenuto cancellato Contenuto aggiunto
compatibilità solo con vector, vedi talk
rimuovo aggiornamento link, poco utile e comunque non funzionante dal 2018
Riga 1: Riga 1:
/**
/**
* Legge gli interlink generati dal modulo:Interprogetto e li aggiunge alla sidebar se mancanti
* Workaround for [[bugzilla:708]] via [[Template:InterProject]].
* Originally based on code from [[wikt:de:MediaWiki:Common.js]] by [[wikt:de:User:Melancholie]],
* Basato sul codice in [[wikt:de:MediaWiki:Common.js]] di [[wikt:de:User:Melancholie]]
* Altri contributori: [[User:Krinkle]], [[User:Ilmari Karonen]], [[User:Andyrom75]]
* 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 */
/* global mediaWiki, jQuery */
Riga 11: Riga 8:
( function ( mw, $ ) {
( function ( mw, $ ) {
'use strict';
'use strict';

function updateOtherProjectsFromTemplate() {
// Aggiorna i link dei progetti presenti su Wikidata
$( '.wb-otherproject-wikibooks a' ).attr( 'href', $( "#interProject div ul li:contains('Wikibooks') a" ).attr( 'href' ) );
$( '.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' ) );
$( '.wb-otherproject-species a' ).attr( 'href', $( "#interProject div ul li:contains('Wikispecies') a" ).attr( 'href' ) );
$( '.wb-otherproject-meta a' ).attr( 'href', $( "#interProject div ul li:contains('Meta-Wiki') a" ).attr( 'href' ) );
$( '.wb-otherproject-mediawiki a' ).attr( 'href', $( "#interProject div ul li:contains('Mediawiki') a" ).attr( 'href' ) );
$( '.wb-otherproject-wikiversity a' ).attr( 'href', $( "#interProject div ul li:contains('Wikiversità') a" ).attr( 'href' ) );
$( '.wb-otherproject-wiktionary a' ).attr( 'href', $( "#interProject div ul li:contains('Wikizionario') a" ).attr( 'href' ) );
}


function buildOtherProjectsFromTemplate() {
function buildOtherProjectsFromTemplate() {
Riga 53: Riga 35:


if ( $( '#p-wikibase-otherprojects' ).length ) {
if ( $( '#p-wikibase-otherprojects' ).length ) {
// da integrare i link principali mancanti senza creare la sezione nella sidebar
updateOtherProjectsFromTemplate();
} else {
} else {
mw.loader.using( 'mediawiki.api' )
mw.loader.using( 'mediawiki.api' )
Riga 61: Riga 43:
.done( buildOtherProjectsFromTemplate )
.done( buildOtherProjectsFromTemplate )
.fail( function () {
.fail( function () {
console.error( 'Impossibile avviare l\'accessorio InterProject.' );
console.error( 'Impossibile avviare l\'accessorio InterProject.' );
} );
} );
}
}

Versione delle 18:30, 4 gen 2021

/**
 * Legge gli interlink generati dal modulo:Interprogetto e li aggiunge alla sidebar se mancanti
 * Basato sul codice in [[wikt:de:MediaWiki:Common.js]] di [[wikt:de:User:Melancholie]]
 * Altri contributori: [[User:Krinkle]], [[User:Ilmari Karonen]], [[User:Andyrom75]]
 */
/* global mediaWiki, jQuery */

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

	function buildOtherProjectsFromTemplate() {
		var $span = $( '<span>' )
			.text( mw.msg( 'wikibase-otherprojects' ) );
		var $h3 = $( '<h3>' )
			.attr( 'id', 'p-wikibase-otherprojects-label' )
			.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( $h3, $div )
			.insertAfter( $( '#p-tb, #p-coll-print_export' ).last() );
	}

	$( function () {
		if ( !$( '#interProject' ).length || mw.config.get( 'skin' ) !== 'vector' ) {
			return;
		}

		if ( $( '#p-wikibase-otherprojects' ).length ) {
			// da integrare i link principali mancanti senza creare la sezione nella sidebar
		} 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 ) );