MediaWiki:Common.js: Difference between revisions
No edit summary |
No edit summary |
||
| (4 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
$(function () { | /* Script para copiar navegação */ | ||
// | $(function() { | ||
// Usa 'body' para garantir que funcione mesmo em elementos carregados dinamicamente | |||
$('body').on('click', '.navi-link', function(e) { | |||
e.preventDefault(); | |||
var $this = $(this); | |||
var map = $this.data('map'); | |||
var x = $this.data('x'); | |||
var y = $this.data('y'); | |||
// Remove espaços extras caso existam | |||
if(map) map = map.trim(); | |||
var command = '/navi ' + map + ' ' + x + '/' + y; | |||
// Cria elemento invisível para copiar | |||
var $temp = $("<input>"); | |||
$("body").append($temp); | |||
$temp.val(command).select(); | |||
document.execCommand("copy"); | |||
$temp.remove(); | |||
// Feedback visual | |||
var $msg = $this.find('.navi-msg'); | |||
$msg.show().fadeOut(2000); | |||
}); | }); | ||
}); | }); | ||
Latest revision as of 23:09, 26 January 2026
/* Script para copiar navegação */
$(function() {
// Usa 'body' para garantir que funcione mesmo em elementos carregados dinamicamente
$('body').on('click', '.navi-link', function(e) {
e.preventDefault();
var $this = $(this);
var map = $this.data('map');
var x = $this.data('x');
var y = $this.data('y');
// Remove espaços extras caso existam
if(map) map = map.trim();
var command = '/navi ' + map + ' ' + x + '/' + y;
// Cria elemento invisível para copiar
var $temp = $("<input>");
$("body").append($temp);
$temp.val(command).select();
document.execCommand("copy");
$temp.remove();
// Feedback visual
var $msg = $this.find('.navi-msg');
$msg.show().fadeOut(2000);
});
});