MediaWiki:Common.js
Nota: Após salvar, você pode ter que limpar o "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: PressioneCtrl enquanto clica Recarregar, ou Pressione Ctrl-F5
- Opera: Vá para Menu → Configurações (Opera → Preferencias no Mac) e depois para Privacidade e Segurança → Limpar dados de navegação → Imagens e arquivos em cache.
/* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki */
/* =====================================================1. BOTÃO "VOLTAR AO TOPO" ===================================================== */
$(function() {
// Cria o botão scroll-to-top button
var $botaoTopo = $('<div id="botaoTopo">⬆️ Topo</div>').css({
display: "none",
position: "fixed",
bottom: "85px", // <-- distância do roda pé (~85px)
right: "20px",
padding: "10px 15px",
background: "#9bbeab",
color: "#000",
"border-radius": "8px",
cursor: "pointer",
"box-shadow": "0 2px 6px rgba(0,0,0,0.3)",
"font-weight": "bold",
"z-index": "9999"
}).appendTo("body");
// Mostrar/esconder com base no scroll
$(window).scroll(function() {
if ($(this).scrollTop() > $(document).height() / 2) {
$botaoTopo.fadeIn();
} else {
$botaoTopo.fadeOut();
}
});
// Ação ao clicar
$botaoTopo.click(function() {
$("html, body").animate({scrollTop: 0}, 500);
return false;
});
});
/* =========================================================2. ANTI-SPAM (CAPTCHA SIMPLES)========================================================= */
mw.hook('wikipage.editform').add(function () {
const form = document.getElementById('editform');
if (!form) return;
const answer = prompt("Digite 7 + 3 para confirmar:");
if (answer !== "10") {
alert("Erro na verificação.");
form.addEventListener('submit', e => e.preventDefault());
}
});
/* =====================================================3. APLICAÇÕES VISUAIS (APENAS NA PÁGINA PRINCIPAL)===================================================== */
jQuery(document).ready(function ($) {
/* Sai imediatamente se não for a Página principal */
if (!$('body').hasClass('page-Página_principal')) return;
/* ── 1. CARDS: aplica border-collapse separate via JS
(fallback para navegadores que ignoram em <table>) ── */
$('table.mph-card').css({
'border-radius': '10px',
'border-collapse': 'separate',
'overflow': 'hidden'
});
/* ── 3. LINKS EXTERNOS nos cards: nova aba ── */
$('.mph-card a[href^="http"]')
.not('a[href*="micropedia.com.br"]')
.not('a[href*="' + window.location.hostname + '"]')
.attr({ target: '_blank', rel: 'noopener noreferrer' });
/* ── 4. HOVER suave nas imagens dos Acontecimentos Recentes ── */
$('.mph-card li img').css({
'vertical-align': 'middle',
'transition': 'transform 0.15s ease'
}).on('mouseenter', function () {
$(this).css('transform', 'scale(1.06)');
}).on('mouseleave', function () {
$(this).css('transform', 'scale(1)');
});
/* ── 5. OCULTAR o título "Página principal" (redundante com o logo) ── */
$('#firstHeading').hide();
});