MediaWiki:Gadget-edittop.js

Origem: Wikipédia, a enciclopédia livre.

Nota: Depois de publicar, poderá ter de contornar a cache do seu navegador para ver as alterações.

  • Firefox / Safari: Pressione Shift enquanto clica Recarregar, ou pressione Ctrl-F5 ou Ctrl-R (⌘-R no Mac)
  • Google Chrome: Pressione Ctrl-Shift-R (⌘-Shift-R no Mac)
  • Internet Explorer / Edge: Pressione Ctrl enquanto clica Recarregar, ou pressione Ctrl-F5
  • Opera: Pressione Ctrl-F5.
/**
 * Adds a button to edit the first (section=0) section at the top of the page ([[bugzilla:156]]).
 *
 * @author: [[pt:User:!Silent]]
 */
/*jshint laxbreak: true */
/*global mediaWiki, jQuery */
( function ( mw, $ ) {
'use strict';

function editTop() {
	$( '#firstHeading' ).append(
		// FIXME: Deveria ser usado o mesmo formato do MediaWiki
		$( '<a>' ).attr( {
			'class': 'mw-editsection',
			'href': mw.util.getUrl() + '?action=edit&section=0',
			'title': 'Editar a se'
				+ ( mw.config.get( 'wgUserLanguage' ) === 'pt' ? 'c' : '' )
				+ 'ção superior'
		} ).text( '[Editar]' )
	);
}

// FIXME: Deveria funcionar também em links como estes:
// https://pt.wikipedia.org/w/index.php?diff=34734428
// https://pt.wikipedia.org/w/index.php?diff=prev&oldid=34734428
if ( !mw.util.getParamValue( 'diff' )
	&& $.inArray( mw.config.get( 'wgNamespaceNumber' ), [ -1, 8 ] ) === -1
) {
	// FIXME: Use mw.hook ([[phab:T53565]])
	$( editTop );
}

}( mediaWiki, jQuery ) );