MediaWiki:Common.js: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
| Line 19: | Line 19: | ||
* Podes apagar esta linha do alert depois de veres que o botão apareceu | * Podes apagar esta linha do alert depois de veres que o botão apareceu | ||
*/ | */ | ||
/** | /** | ||
| Line 39: | Line 39: | ||
.css({ | .css({ | ||
'position': 'absolute', | 'position': 'absolute', | ||
'top': ' | 'top': '10px', // Mais espaço do topo | ||
'right': ' | 'right': '10px', // Mais espaço da direita | ||
'z-index': '100', | 'z-index': '100', | ||
'padding': ' | 'padding': '8px 16px', // Aumenta o tamanho (altura e largura) | ||
'background': '# | 'background': '#28a745', // COR: Verde (podes mudar para #000 para preto, etc) | ||
'color': '#fff', | 'color': '#fff', | ||
'border': 'none', | 'border': 'none', | ||
'border-radius': ' | 'border-radius': '8px', // CORNER RADIUS: Mais arredondado | ||
'cursor': 'pointer', | 'cursor': 'pointer', | ||
'font-size': ' | 'font-size': '14px', // FONTE: Maior | ||
'font-weight': 'bold' | 'font-weight': 'bold', | ||
'transition': '0.3s' // Suaviza a mudança de cor | |||
}); | }); | ||
Revision as of 09:33, 13 March 2026
/* Any JavaScript here will be loaded for all users on every page load. */
/**
* 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');
/**
* TESTE DE FUNCIONAMENTO
* Podes apagar esta linha do alert depois de veres que o botão apareceu
*/
/**
* BOTÃO DE COPIAR (Copy Button)
* Este script cria o botão de cópia em todos os blocos de código
*/
$(function() {
// Procura os blocos gerados pela extensão SyntaxHighlight
$('.mw-highlight').each(function() {
var $block = $(this);
// Evita botões duplicados
if ($block.find('.copy-btn').length > 0) return;
// Cria o botão com estilo azul
var $button = $('<button>')
.text('Copy')
.addClass('copy-btn')
.css({
'position': 'absolute',
'top': '10px', // Mais espaço do topo
'right': '10px', // Mais espaço da direita
'z-index': '100',
'padding': '8px 16px', // Aumenta o tamanho (altura e largura)
'background': '#28a745', // COR: Verde (podes mudar para #000 para preto, etc)
'color': '#fff',
'border': 'none',
'border-radius': '8px', // CORNER RADIUS: Mais arredondado
'cursor': 'pointer',
'font-size': '14px', // FONTE: Maior
'font-weight': 'bold',
'transition': '0.3s' // Suaviza a mudança de cor
});
// Função para copiar o texto
$button.on('click', function() {
var text = $block.find('pre').text();
navigator.clipboard.writeText(text).then(function() {
$button.text('Copied!').css('background', '#00af89');
setTimeout(function() {
$button.text('Copy').css('background', '#3366cc');
}, 2000);
}).catch(function(err) {
console.error('Erro ao copiar: ', err);
});
});
// Adiciona o botão ao bloco
$block.css('position', 'relative').prepend($button);
});
});