MediaWiki:Common.js: diferenças entre revisões
Aspeto
Conteúdo apagado Conteúdo adicionado
Réplica de mw:Special:Diff/3341639: WARNING: DO NOT REMOVE THIS "IF" - REQUIRED FOR SECURITY (against XSS/CSRF attacks) |
m Conforme solicitado https://pt.wikipedia.org/w/index.php?oldid=58678653 |
||
Linha 76: | Linha 76: | ||
} ); |
} ); |
||
/** |
|||
⚫ | |||
* Editnotices mágicos **************************************************** |
|||
* |
|||
* Descrição: Adiciona editnotices nas páginas de desambiguação e biografias de pessoas vivas. |
|||
* Mantenedores: [[:en:User:RockMFR]] |
|||
* |
|||
* @param {string} name |
|||
*/ |
|||
function addEditIntro( name ) { |
|||
$( '.mw-editsection, #ca-edit, #ca-ve-edit' ).find( 'a' ).each( function ( i, el ) { |
|||
el.href = $( this ).attr( 'href' ) + '&editintro=' + name; |
|||
} ); |
|||
} |
|||
if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) { |
|||
$( function () { |
|||
if ( document.getElementById( 'disambig' ) ) { |
|||
addEditIntro( 'MediaWiki:Editnotice-0-Desambiguação' ); |
|||
} |
|||
} ); |
|||
$( function () { |
|||
var cats = mw.config.get( 'wgCategories' ); |
|||
if ( !cats ) { |
|||
return; |
|||
} |
|||
if ( $.inArray( 'Pessoas vivas', cats ) !== -1 ) { |
|||
addEditIntro( 'MediaWiki:Editnotice-0-BPV' ); |
|||
} |
|||
} ); |
|||
} |
|||
⚫ | |||
}( mediaWiki, jQuery ) ); |
}( mediaWiki, jQuery ) ); |
Revisão das 00h31min de 12 de julho de 2020
/* Qualquer código JavaScript presente aqui será carregado por todos os usuários em cada página carregada. */
/*jshint camelcase: true, curly: true, eqeqeq: true, immed: true, latedef: true, newcap: true, noarg: true, noempty: true, nonew: true, quotmark: single, trailing: true, undef: true, unused: true, bitwise: true, forin: true, regexp: true, strict: true, onevar: true, laxbreak: true */
/*global mediaWiki, jQuery */
( function ( mw, $ ) {
'use strict';
/**
* Oculta botão editar da [[Wikipédia:Esplanada/propostas]] e da [[Wikipédia:Esplanada/geral]]
*
* @author: Helder (https://github.com/he7d3r)
* @license: CC BY-SA 3.0 <https://creativecommons.org/licenses/by-sa/3.0/>
*/
/* Desativado por causar erro: $.collapsibleTabs.getSettings(...) is undefined ([[phab:T177108]])
mw.loader.using( 'mediawiki.util', function () {
function hideEditButton() {
var temp = 'Template:Esplanada2/Preload';
if ( mw.config.get( 'wgUserLanguage' ) !== 'pt' ) {
temp += '/en';
}
$( '#ca-addsection' ).find( 'a' ).attr(
'href',
mw.util.getUrl( mw.config.get( 'wgPageName' ), {
action: 'edit',
section: 'new',
preload: temp
} )
);
if ( mw.config.get( 'skin' ) === 'vector' ) {
// Move o botão "editar" para o menu de ações
$( '#p-cactions' ).removeClass( 'emptyPortlet' ).find( 'ul' ).append( $( '#ca-edit' ) );
}
}
if ( $.inArray( mw.config.get( 'wgPageName' ), [ 'Wikipédia:Esplanada/propostas', 'Wikipédia:Esplanada/geral' ] ) !== -1 ) {
$( hideEditButton );
}
});*/
/**
* Parâmetros &withCSS= e &withJS= para a URL
*
* Permite que sejam testados scripts e folhas de estilos do domínio MediaWiki
* sem precisar editar páginas ".css" ou ".js" pessoais
* @source https://www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
* @revision 2020-04-04
*/
mw.loader.using( ['mediawiki.util'], function () {
var extraCSS = mw.util.getParamValue( 'withCSS' ),
extraJS = mw.util.getParamValue( 'withJS' );
if ( extraCSS ) {
// WARNING: DO NOT REMOVE THIS "IF" - REQUIRED FOR SECURITY (against XSS/CSRF attacks)
if ( /^MediaWiki:[^&<>=%#]*\.css$/.test( extraCSS ) ) {
mw.loader.load( '/w/index.php?title=' + extraCSS + '&action=raw&ctype=text/css', 'text/css' );
} else {
mw.notify( 'Só são permitidas páginas do domínio MediaWiki.', { title: 'Valor withCSS inválido' } );
}
}
if ( extraJS ) {
// WARNING: DO NOT REMOVE THIS "IF" - REQUIRED FOR SECURITY (against XSS/CSRF attacks)
if ( /^MediaWiki:[^&<>=%#]*\.js$/.test( extraJS ) ) {
mw.loader.load( '/w/index.php?title=' + extraJS + '&action=raw&ctype=text/javascript' );
} else {
mw.notify( 'Só são permitidas páginas do domínio MediaWiki.', { title: 'Valor withJS inválido' } );
}
}
} );
// Ocultar a barra de sumário das páginas de pedidos
mw.loader.using( 'mediawiki.util', function () {
if ( /Wikipédia:Pedidos\/(?!Outros|Revisão_de_ações_administrativas$)/.test( mw.config.get( 'wgPageName' ) ) && mw.util.getParamValue( 'section' ) === 'new' ) {
$( '.mw-summary' ).hide();
}
} );
/**
* Editnotices mágicos ****************************************************
*
* Descrição: Adiciona editnotices nas páginas de desambiguação e biografias de pessoas vivas.
* Mantenedores: [[:en:User:RockMFR]]
*
* @param {string} name
*/
function addEditIntro( name ) {
$( '.mw-editsection, #ca-edit, #ca-ve-edit' ).find( 'a' ).each( function ( i, el ) {
el.href = $( this ).attr( 'href' ) + '&editintro=' + name;
} );
}
if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
$( function () {
if ( document.getElementById( 'disambig' ) ) {
addEditIntro( 'MediaWiki:Editnotice-0-Desambiguação' );
}
} );
$( function () {
var cats = mw.config.get( 'wgCategories' );
if ( !cats ) {
return;
}
if ( $.inArray( 'Pessoas vivas', cats ) !== -1 ) {
addEditIntro( 'MediaWiki:Editnotice-0-BPV' );
}
} );
}
// Scripts para páginas específicas
}( mediaWiki, jQuery ) );