MediaWiki:Common.js: Difference between revisions
Appearance
No edit summary Tag: Manual revert |
No edit summary |
||
| (43 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
</ | /* Forçar links de "Buy Now" a abrir em novo separador */ | ||
$(document).ready(function() { | |||
$('.button-buy-now a').attr('target', '_blank').attr('rel', 'noopener'); | |||
}); | |||
$(document).ready(function() { | |||
var footerLinks = document.getElementById('footer-places'); | |||
if (footerLinks && !document.getElementById('footer-custom-buttons-container')) { | |||
var container = document.createElement('li'); | |||
container.id = 'footer-custom-buttons-container'; | |||
container.style.display = 'flex'; | |||
container.style.gap = '10px'; | |||
container.style.alignItems = 'center'; | |||
// Botão de Topo (Seta) | |||
var topBtn = '<a href="#" class="footer-top-button" title="Voltar ao topo">' + | |||
'<span class="material-symbols-outlined">arrow_upward</span></a>'; | |||
// Teu botão atual da Atronia | |||
var siteBtn = '<a href="https://atronia.eu" class="footer-button-atronia-real" target="_blank" rel="noopener">atronia.eu</a>'; | |||
container.innerHTML = topBtn + siteBtn; | |||
footerLinks.appendChild(container); | |||
// Função para scroll suave ao clicar na seta | |||
$('.footer-top-button').click(function(e) { | |||
e.preventDefault(); | |||
$('html, body').animate({scrollTop: 0}, 'slow'); | |||
}); | |||
} | |||
}); | |||
/*** GOOGLE ANALYTICS Injeção correta de script externo para evitar o erro de "Parse error" ***/ | |||
var gaScript = document.createElement('script'); | |||
gaScript.src = "https://www.googletagmanager.com/gtag/js?id=G-MX174P23PW"; | |||
gaScript.async = true; | |||
document.head.appendChild(gaScript); | |||
window.dataLayer = window.dataLayer || []; | |||
function gtag(){dataLayer.push(arguments);} | |||
gtag('js', new Date()); | |||
gtag('config', 'G-MX174P23PW'); | |||
/* Botão de Copiar Moderno com Ícone */ | |||
$(function() { | |||
$('.mw-highlight').each(function() { | |||
var $block = $(this); | |||
if ($block.find('.copy-btn').length > 0) return; | |||
// Ícone SVG de dois quadrados (estilo moderno) | |||
var copyIcon = '<svg fill="none" stroke-width="2.5" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" height="1.2em" width="1.2em" xmlns="http://www.w3.org/2000/svg" style="margin-right: 8px; vertical-align: middle; stroke: white !important;">' + | |||
'<rect x="9" y="9" width="13" height="13" rx="2" ry="2" style="stroke: white !important;"></rect>' + | |||
'<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" style="stroke: white !important;"></path>' + | |||
'</svg>'; | |||
var $button = $('<button>') | |||
.html(copyIcon + '<span>Copy</span>') | |||
.addClass('copy-btn') | |||
.css({ | |||
'position': 'absolute', | |||
'top': '10px', | |||
'right': '10px', | |||
'z-index': '100', | |||
'display': 'flex', | |||
'align-items': 'center', | |||
'padding': '6px 12px', | |||
'background': '#343a40', // Cor cinza escuro moderna | |||
'color': '#f8f9fa', // Texto quase branco | |||
'border': '1px solid #495057', | |||
'border-radius': '6px', // Cantos ligeiramente arredondados | |||
'cursor': 'pointer', | |||
'font-size': '12px', | |||
'font-family': 'sans-serif', | |||
'transition': 'all 0.2s ease' | |||
}); | |||
// Efeito Hover (passar o rato) | |||
$button.hover( | |||
function() { $(this).css({'background': '#495057', 'border-color': '#6c757d'}); }, | |||
function() { $(this).css({'background': '#343a40', 'border-color': '#495057'}); } | |||
); | |||
$button.on('click', function(e) { | |||
e.preventDefault(); | |||
var text = $block.find('pre').text(); | |||
navigator.clipboard.writeText(text).then(function() { | |||
// Muda o ícone e texto para "Copiado!" | |||
$button.find('span').text('Copied!'); | |||
$button.css({'background': '#28a745', 'border-color': '#28a745'}); | |||
setTimeout(function() { | |||
$button.find('span').text('Copy'); | |||
$button.css({'background': '#343a40', 'border-color': '#495057'}); | |||
}, 2000); | |||
}); | |||
}); | |||
$block.css('position', 'relative').prepend($button); | |||
}); | |||
}); | |||
/* Variations toggle arrow rotation */ | |||
$(function () { | |||
$('.variations-toggle').on('click', function () { | |||
var $arrow = $(this).find('.arrow-icon'); | |||
// small delay to let MediaWiki toggle first | |||
setTimeout(() => { | |||
var targetId = this.className.match(/mw-customtoggle-(\d+)/); | |||
if (!targetId) return; | |||
var collapsibleId = '#mw-customcollapsible-' + targetId[1]; | |||
var $collapsible = $(collapsibleId); | |||
if ($collapsible.hasClass('mw-collapsed')) { | |||
$arrow.removeClass('rotated'); | |||
} else { | |||
$arrow.addClass('rotated'); | |||
} | |||
}, 50); | |||
}); | |||
}); | |||