MediaWiki:Common.js
Jump to navigation
Jump to search
Note: After saving, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/* Função melhorada para a funcionalidade de cópia */ function initImageCopy() { // Adiciona a funcionalidade warp-copy para links de imagem $('.tile-top.tile-image a').each(function() { var $link = $(this); if (!$link.hasClass('warp-copy')) { var href = $link.attr('href') || ''; var npcId = href.replace('#',''); if (npcId) { $link.addClass('warp-copy') .attr('data-copy', '@warp ' + npcId) .css('cursor', 'pointer'); // Adiciona eventos de click específicos para garantir o feedback visual $link.off('click').on('click', function(e) { e.preventDefault(); e.stopPropagation(); var textToCopy = $(this).attr('data-copy'); // Cria elemento temporário para cópia var tempInput = document.createElement('textarea'); tempInput.value = textToCopy; document.body.appendChild(tempInput); tempInput.select(); document.execCommand('copy'); document.body.removeChild(tempInput); // Adiciona classe para feedback visual var $element = $(this); $element.addClass('copied'); console.log("Texto copiado da imagem: " + textToCopy); // Remove a classe após 2 segundos setTimeout(function() { $element.removeClass('copied'); }, 2000); return false; }); } } }); } // Remova o evento de click genérico para .warp-copy e use eventos específicos $(document).ready(function() { // Função para texto $(document).on('click', '.warp-copy:not(.tile-top.tile-image a)', function(e) { e.preventDefault(); var textToCopy = $(this).attr('data-copy'); // Cria elemento temporário para cópia var tempInput = document.createElement('textarea'); tempInput.value = textToCopy; document.body.appendChild(tempInput); tempInput.select(); document.execCommand('copy'); document.body.removeChild(tempInput); // Adiciona classe para feedback visual var $element = $(this); $element.addClass('copied'); console.log("Texto copiado do texto: " + textToCopy); setTimeout(function() { $element.removeClass('copied'); }, 2000); }); // Inicializa a funcionalidade para imagens setTimeout(function() { initImageCopy(); }, 300); // Reinicializa ao atualizar conteúdo wiki if (typeof mw !== 'undefined' && mw.hook) { mw.hook('wikipage.content').add(function() { setTimeout(function() { initImageCopy(); }, 300); }); } });