MediaWiki:Gadget-SysopSuggestions.js: diferenças entre revisões

Origem: Wikipédia, a enciclopédia livre.
Conteúdo apagado Conteúdo adicionado
correção de ligação vermelha
 
Linha 29: Linha 29:
reasons.push( $(this).val() );
reasons.push( $(this).val() );
});
});
$( 'input[name="mwProtect-reason"], #wpReason, input[name="wpReason-other"]' ).suggestions( {
$( 'input[name="mwProtect-reason"], input[name="wpReason "], input[name="wpReason-other"]' ).suggestions( {
fetch: function ( query ) {
fetch: function ( query ) {
var $this = $(this), relevantSuggestions;
var $this = $(this), relevantSuggestions;

Edição atual tal como às 02h17min de 25 de setembro de 2023

// [[File:User:He7d3r/Tools/SysopSuggestions.js]] (workaround for [[phab:T35355]])
/**
 * @see: [[phab:T34950]]
 * @see: [[Usuário_Discussão:Francisco_Leandro/Arquivo/22#Re:]]
 * @see: [[Usuário:Yanguas/Arquivo_56#MediaWiki:Protect-dropdown]]
 * @author: Helder (https://github.com/he7d3r)
 * @license: CC BY-SA 3.0 <https://creativecommons.org/licenses/by-sa/3.0/>
 */
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'protect', 'unprotect', 'delete' ] ) > -1
	|| mw.util.getParamValue('revisiondelete')
	|| mw.config.get( 'wgCanonicalSpecialPageName' ) == 'Revisiondelete'
		&& mw.util.getParamValue( 'type' ) == 'revision'
		&& mw.util.getParamValue( 'ids' ) > 0
	|| mw.config.get( 'wgCanonicalSpecialPageName' ) == 'Block'
) {
	$(function () {
		var	reasons = [];
		/*
		 * Fill in the array with the reasons defined on these pages:
		 * [[MediaWiki:Protect-dropdown]]
		 * [[MediaWiki:Revdelete-reason-dropdown]]
		 * [[MediaWiki:Filedelete-reason-dropdown]]
		 * [[MediaWiki:Ipbreason-dropdown]]
		 * [[MediaWiki:Deletereason-dropdown]]
		 */
		$('#wpProtectReasonSelection, #wpRevDeleteReasonList, #wpDeleteReasonList, #mw-input-wpReason')
			.find('optgroup option')
			.each(function () {
				reasons.push( $(this).val() );
			});
		$( 'input[name="mwProtect-reason"], input[name="wpReason"], input[name="wpReason-other"]' ).suggestions( {
			fetch: function ( query ) {
				var $this = $(this), relevantSuggestions;
				relevantSuggestions = $.grep(reasons, function (reason, i) {
					return ( reason.toLowerCase().indexOf( $this.val().toLowerCase() ) > -1 );
				});
				$this.suggestions( 'suggestions', relevantSuggestions );
			},
			delay: 120,
			highlightInput: true
		} );
	});
}