MediaWiki:Gadget-TurnBackAnchors.js: differenze tra le versioni

Da Semi del Verbo, l'enciclopedia dell'influenza del Vangelo sulla cultura
(Dependency già gestita da gadgets-definition)
 
m (una versione importata)
 
(Nessuna differenza)

Versione attuale delle 22:40, 30 ago 2020

/**
 * For people without access to the home key :)
 *
 * @license [[WFTPL]] COMING WITH ABSOLUTELY NO WARRANTY
 * @author [[Utente:Valerio Bozzolan]] and history contributors
 */
window.turnBackAnchors = {};
window.turnBackAnchors.opts = {
	prependMsg: '[Vai giù ↓]',
	appendMsg: '[Torna su ↑]',
	append:  true,
	prepend: true
};
window.turnBackAnchors.init = function () {
	var ns = mw.config.get('wgNamespaceNumber');
	if(ns === -1 || ns % 2 === 0) {
		return; // Discussions are even
	}

	function $anchor( href, msg ) {
		return $('<div>').css('text-align', 'right').append(
			$('<a>').attr('href', href)
			        .html( msg )
		);
	}

	var $content = $('#bodyContent');
	var opts = window.turnBackAnchors.opts;

	opts.append && $content.append(
		$anchor('#', opts.appendMsg)
	);
	opts.prepend && $content.prepend(
		$anchor('#footer', opts.prependMsg)
	);
};
window.turnBackAnchors.init();