Difference between revisions of "MediaWiki:Common.css"

From XilePK - Ragnarok Online Server
Jump to navigation Jump to search
 
(47 intermediate revisions by the same user not shown)
Line 1: Line 1:
/* Auto-expand sections when clicking anchored links */
+
/* CSS placed here will be applied to all skins */
$(function() {
 
  // Função principal para executar quando a página terminar de carregar
 
  function initializeAnchorExpansion() {
 
    // Se existir um hash na URL quando a página carrega
 
    if (window.location.hash) {
 
      var hash = window.location.hash;
 
      console.log("Página carregada com hash: " + hash);
 
      expandSectionForAnchor(hash);
 
    }
 
   
 
    // Lidar com cliques em links âncora dentro da página
 
    $(document).on('click', 'a[href^="#"]', function(event) {
 
      var hash = $(this).attr('href');
 
      console.log("Clique em link interno: " + hash);
 
      expandSectionForAnchor(hash);
 
    });
 
  }
 
 
 
  // Função para expandir seções contendo uma âncora específica
 
  function expandSectionForAnchor(hash) {
 
    // Remover qualquer caractere # do início do hash se existir
 
    if (hash.startsWith('#')) {
 
      hash = hash.substring(1);
 
    }
 
   
 
    console.log("Procurando elemento com ID: " + hash);
 
   
 
    // Tentar encontrar o elemento com o ID especificado
 
    var targetElement = $('#' + hash);
 
    if (targetElement.length) {
 
      console.log("Elemento encontrado!");
 
     
 
      // Encontrar todas as seções colapsáveis que contêm o elemento
 
      var collapsibleSections = targetElement.parents('.mw-collapsible.mw-collapsed');
 
      console.log("Seções colapsáveis encontradas: " + collapsibleSections.length);
 
     
 
      // Se o elemento estiver dentro de seções colapsáveis
 
      if (collapsibleSections.length > 0) {
 
        // Expandir cada seção de fora para dentro
 
        collapsibleSections.each(function() {
 
          var $section = $(this);
 
          console.log("Expandindo seção");
 
          $section.removeClass('mw-collapsed');
 
         
 
          // Clicar no botão de expansão ou mudar diretamente a classe
 
          var $toggle = $section.find('.mw-collapsible-toggle').first();
 
          if ($toggle.length) {
 
            $toggle.click();
 
          } else {
 
            // Tentar forçar a expansão manipulando classes diretamente
 
            $section.find('.mw-collapsible-content').show();
 
          }
 
        });
 
       
 
        // Também verificar se o próprio elemento está em um colapsível
 
        var directCollapsible = targetElement.closest('.mw-collapsible.mw-collapsed');
 
        if (directCollapsible.length) {
 
          console.log("Expandindo o contêiner direto");
 
          directCollapsible.removeClass('mw-collapsed');
 
          var $toggle = directCollapsible.find('.mw-collapsible-toggle').first();
 
          if ($toggle.length) {
 
            $toggle.click();
 
          } else {
 
            directCollapsible.find('.mw-collapsible-content').show();
 
          }
 
        }
 
      }
 
     
 
      // Rolar até o elemento imediatamente
 
      console.log("Rolando até o elemento");
 
      $('html, body').animate({
 
        scrollTop: targetElement.offset().top - 100
 
      }, 200);
 
    } else {
 
      console.log("Elemento com ID '" + hash + "' não encontrado");
 
    }
 
  }
 
  
  // Inicializar na carga da página
+
/* ========== ESTILOS GERAIS ========== */
  initializeAnchorExpansion();
+
a {
 
+
     text-underline-offset: 0px;
  // Também adicionar um observador para o evento mw.hook que é disparado quando o conteúdo é atualizado
+
}
  if (typeof mw !== 'undefined' && mw.hook) {
 
    mw.hook('wikipage.content').add(function() {
 
      console.log("Conteúdo da Wiki atualizado, reinicializando manipuladores de âncora");
 
      initializeAnchorExpansion();
 
     
 
      // Se houver um hash, tentar expandir após o conteúdo ter sido carregado
 
      if (window.location.hash) {
 
        expandSectionForAnchor(window.location.hash);
 
      }
 
     });
 
  }
 
});
 
  
/* JavaScript melhorado para funcionalidade de cópia */
+
.external {
$(document).ready(function() {
+
     background: none !important;
     // Adicionar CSS personalizado inline para forçar os tooltips
+
    padding-right: 0 !important;
    $('<style>')
+
}
        .text(`
 
            .warp-copy:hover::after,
 
            .warp-copy:hover::before {
 
                opacity: 1 !important;
 
                visibility: visible !important;
 
                display: block !important;
 
            }
 
            .warp-copy.copied::after {
 
                content: "Copiado!" !important;
 
                background-color: #4CAF50 !important;
 
                display: block !important;
 
            }
 
        `)
 
        .appendTo('head');
 
});
 
  
mw.hook('wikipage.content').add(function ($content) {
+
/* ========== WAR COPY (TEXTO E IMAGENS) ========== */
     // Função para inicializar todos os elementos .warp-copy
+
.warp-copy {
     function initWarpCopy() {
+
     color: #0066cc;
        console.log("Inicializando elementos .warp-copy");
+
    cursor: pointer;
       
+
    text-decoration: underline dotted #0066cc;
        // Remove manipuladores de eventos anteriores para evitar duplicações
+
    text-underline-offset: 2px;
        $content.find('.warp-copy').off('click');
+
    position: relative;
       
+
    display: inline-block;
        // Adiciona o manipulador de clique
+
}
        $content.find('.warp-copy').on('click', function (event) {
+
 
            event.preventDefault();
+
/* Tooltip padrão */
            event.stopPropagation();
+
.warp-copy::after {
           
+
    content: "Copy";
            var $this = $(this);
+
    position: absolute;
            var textToCopy = $this.attr('data-copy');
+
    left: 50%;
           
+
    background-color: #333;
            if (!textToCopy) {
+
     color: white;
                console.warn("Elemento .warp-copy sem atributo data-copy encontrado");
+
    padding: 2px 6px;
                return;
+
    border-radius: 3px;
            }
+
    font-size: 12px;
           
+
    white-space: nowrap;
            console.log("Copiando texto: " + textToCopy);
+
    z-index: 10;
           
+
    opacity: 0;
            // Usa a API Clipboard moderna quando disponível
+
    visibility: hidden;
            if (navigator.clipboard && navigator.clipboard.writeText) {
+
    pointer-events: none;
                navigator.clipboard.writeText(textToCopy)
+
    transform: translateX(-50%);
                    .then(function() {
+
}
                        console.log('Texto copiado com sucesso usando Clipboard API');
+
 
                        showCopiedFeedback($this);
+
/* Seta do tooltip */
                    })
+
.warp-copy::before {
                    .catch(function(err) {
+
    content: "";
                        console.error('Falha ao copiar texto: ', err);
+
    position: absolute;
                        // Tenta o método de fallback
+
    left: 50%;
                        fallbackCopyText(textToCopy, $this);
+
    border-width: 4px;
                    });
+
    border-style: solid;
            } else {
+
    z-index: 10;
                // Método de fallback para navegadores que não suportam a API Clipboard
+
    opacity: 0;
                fallbackCopyText(textToCopy, $this);
+
    visibility: hidden;
            }
+
    pointer-events: none;
        });
+
    transform: translateX(-50%);
     }
+
}
   
+
 
    // Função de fallback para copiar texto
+
/* Tooltip PARA TEXTO */
    function fallbackCopyText(text, $element) {
+
.warp-copy:not(img)::after {
        // Cria um elemento de texto temporário
+
    bottom: calc(100% + 5px);
        var tempInput = document.createElement('textarea');
+
}
        tempInput.value = text;
+
 
        tempInput.style.position = 'fixed';
+
.warp-copy:not(img)::before {
        tempInput.style.opacity = '0';
+
    bottom: calc(100% + 1px);
        document.body.appendChild(tempInput);
+
    border-color: #333 transparent transparent transparent;
       
+
}
        // Seleciona e copia
+
 
        tempInput.select();
+
/* Tooltip PARA IMAGENS */
        tempInput.setSelectionRange(0, 99999); // Para dispositivos móveis
+
.tile-top.tile-image .warp-copy::after {
       
+
    bottom: -25px;
        try {
+
    top: auto !important;
            var successful = document.execCommand('copy');
+
}
            if (successful) {
+
 
                console.log('Texto copiado com sucesso usando execCommand');
+
.tile-top.tile-image .warp-copy::before {
                showCopiedFeedback($element);
+
    bottom: -18px;
            } else {
+
    top: auto !important;
                console.error('Falha ao copiar texto com execCommand');
+
    border-color: #333 transparent transparent transparent !important;
            }
+
}
        } catch (err) {
+
 
            console.error('Erro ao copiar texto: ', err);
+
/* Estados de hover */
        }
+
.warp-copy:hover::after,
       
+
.warp-copy:hover::before {
        // Remove o elemento temporário
+
    opacity: 1;
        document.body.removeChild(tempInput);
+
     visibility: visible;
     }
+
}
      
+
 
     // Função para mostrar feedback visual de cópia
+
/* Feedback de copiado - APLICA-SE A TODOS OS WARP-COPY */
     function showCopiedFeedback($element) {
+
.warp-copy.copied::after {
        // Adiciona classe para feedback visual
+
    content: "Copied!" !important;
        $element.addClass('copied');
+
    background-color: #4CAF50 !important;
       
+
    opacity: 1 !important;
        // Remove a classe após um breve período
+
    visibility: visible !important;
        setTimeout(function() {
+
}
            $element.removeClass('copied');
+
 
        }, 1500);
+
.warp-copy.copied {
       
+
    color: #4CAF50 !important;
        // Opcional: mostrar um popup de notificação
+
    text-decoration: underline dotted #4CAF50 !important;
        $('<div class="copy-notification" style="position:fixed;bottom:20px;right:20px;background:#4CAF50;color:white;padding:10px;border-radius:5px;z-index:9999;">Copiado: ' + $element.attr('data-copy') + '</div>')
+
}
            .appendTo('body')
+
 
            .delay(1500)
+
/* ========== ESTILOS ESPECÍFICOS PARA NPCs ========== */
            .fadeOut(300, function() { $(this).remove(); });
+
.tile-row {
     }
+
    display: flex;
      
+
    flex-flow: row wrap;
     // Script para imagens dos NPCs
+
    margin-bottom: 1em;
    function initNPCImageCopy() {
+
}
        $content.find('.contents-equipment .tile-top.tile-image a').each(function() {
+
 
            var $link = $(this);
+
.tile-halves {
            var linkHref = $link.attr('href') || '';
+
    display: flex;
           
+
    flex-flow: row wrap;
            // Extrai o ID do NPC do link
+
    border: 1px solid #e4eaee;
            var npcId = linkHref.startsWith('#') ? linkHref.substring(1) : linkHref;
+
    background: #ffffff;
           
+
    box-shadow: 0 0.25rem 0.35rem -0.25rem rgba(0, 0, 0, 0.1);
            if (npcId) {
+
     position: relative;
                $link.off('mousedown').on('mousedown', function(e) {
+
}
                    // Texto a ser copiado
+
 
                    var textToCopy = "@warp " + npcId;
+
.tile-halves h2 {
                   
+
     font-size: 1.4em;
                    // Tenta usar a API Clipboard moderna
+
     font-weight: bold;
                    if (navigator.clipboard && navigator.clipboard.writeText) {
+
     border: none;
                        navigator.clipboard.writeText(textToCopy)
+
    margin: 0 0 0.4em;
                            .then(function() {
+
}
                                console.log('Comando @warp copiado com sucesso');
+
 
                                showCopiedNotification(textToCopy);
+
.tile-top {
                            })
+
    width: 100%;
                            .catch(function(err) {
+
    padding: 1.3rem 1.5rem 0.6rem;
                                console.error('Falha ao copiar comando @warp: ', err);
+
}
                                // Usa o método de fallback
+
 
                                fallbackCopyText(textToCopy, $link);
+
.tile-top.tile-image {
                            });
+
    display: flex;
                    } else {
+
    align-items: center;
                        // Método de fallback
+
    justify-content: center;
                        fallbackCopyNPCCommand(textToCopy);
+
    background-color: #949eaa;
                    }
+
    overflow: visible;
                   
+
    padding: 0;
                    // Permite que o evento continue
+
    height: auto;
                    return true;
+
    width: 100%;
                });
+
    box-sizing: border-box;
            }
+
}
        });
+
 
     }
+
.tile-top.tile-image a {
      
+
    width: 100%;
    // Função de fallback para copiar comando de NPC
+
    height: 100%;
    function fallbackCopyNPCCommand(text) {
+
     display: flex;
        var tempInput = document.createElement('textarea');
+
     justify-content: center;
        tempInput.value = text;
+
     align-items: center;
        tempInput.style.position = 'fixed';
+
}
        tempInput.style.opacity = '0';
+
 
        document.body.appendChild(tempInput);
+
.tile-top.tile-image img {
       
+
    display: block;
        tempInput.select();
+
    max-width: 100%;
        tempInput.setSelectionRange(0, 99999); // Para dispositivos móveis
+
    width: auto;
       
+
    height: auto;
        try {
+
    margin: 0;
            document.execCommand('copy');
+
    transition: 0.4s ease-out;
            showCopiedNotification(text);
+
    object-fit: contain;
        } catch (err) {
+
}
            console.error('Erro ao copiar comando @warp: ', err);
+
 
        }
+
/* Estilo para tamanhos personalizados */
       
+
.tile-top.tile-image img.custom-size {
        document.body.removeChild(tempInput);
+
    width: var(--custom-width, auto);
     }
+
    height: var(--custom-height, auto);
      
+
    max-width: var(--custom-width, 100%);
     // Função para mostrar notificação de cópia
+
    max-height: var(--custom-height, none);
     function showCopiedNotification(text) {
+
}
        $('<div class="copy-notification" style="position:fixed;bottom:20px;right:20px;background:#4CAF50;color:white;padding:10px;border-radius:5px;z-index:9999;">Copiado: ' + text + '</div>')
+
 
            .appendTo('body')
+
.tile-bottom {
            .delay(1500)
+
    background: #ffffff;
            .fadeOut(300, function() { $(this).remove(); });
+
    border-top: 1px solid #e4eaee;
     }
+
    width: 100%;
      
+
    padding: 1rem 1.5rem 0.6rem;
     // Inicializa todas as funções
+
}
     initWarpCopy();
+
 
    initNPCImageCopy();
+
.tile-bottom.link-button {
   
+
    align-self: center;
    // Forçar a atualização dos tooltips (hack)
+
    padding: 0;
    setTimeout(function() {
+
    width: auto;
        $content.find('.warp-copy').each(function() {
+
     margin: 0 auto;
            var $this = $(this);
+
     max-width: fit-content;
            $this.attr('title', 'Clique para Copiar');
+
}
        });
+
 
     }, 500);
+
.mainpage-contents .tile-halves {
      
+
    display: inline-block;
    // Observador para alterações no DOM
+
    flex: 0 0 auto;
    var observer = new MutationObserver(function(mutations) {
+
    margin-right: 0.9rem;
        var needsReinit = false;
+
    width: auto;
       
+
    max-width: max-content;
        mutations.forEach(function(mutation) {
+
}
            if (mutation.addedNodes && mutation.addedNodes.length > 0) {
+
 
                needsReinit = true;
+
.mainpage-contents .tile-halves:hover .tile-top img {
            }
+
    transform: scale(1.04);
        });
+
}
       
+
 
        if (needsReinit) {
+
.mainpage-contents .tile-halves:last-child {
            initWarpCopy();
+
    margin-right: 0;
            initNPCImageCopy();
+
}
        }
+
 
     });
+
.npc-subtitle {
   
+
    font-size: 0.8em;
    // Configura o observador
+
     color: #666;
     observer.observe($content[0], { childList: true, subtree: true });
+
     margin-top: -5px;
});
+
     text-align: center;
 +
     font-style: italic;
 +
    line-height: 1.2;
 +
}
 +
 
 +
.mainpage-contents.tile-row {
 +
    display: flex;
 +
    flex-flow: row wrap;
 +
    gap: 15px;
 +
    justify-content: flex-start;
 +
}
 +
 
 +
.mainpage-contents .contents-equipment.tile-halves {
 +
     margin-right: 0;
 +
     flex: 0 0 auto;
 +
     min-width: 150px;
 +
     max-width: 200px;
 +
}
 +
 
 +
/* Título do NPC */
 +
.tile-bottom.link-button h2 .warp-copy {
 +
    color: #000080;
 +
    font-weight: bold;
 +
    display: block;
 +
     text-align: center;
 +
     text-decoration: none;
 +
}
 +
 
 +
.tile-bottom.link-button h2 {
 +
    position: relative;
 +
    overflow: visible;
 +
}
 +
 
 +
/* Classes para dimensionamento manual */
 +
.npc-image-small {
 +
    max-width: 150px !important;
 +
}
 +
.npc-image-medium {
 +
     max-width: 200px !important;
 +
}
 +
.npc-image-large {
 +
     max-width: 250px !important;
 +
}

Latest revision as of 12:47, 6 May 2025

/* CSS placed here will be applied to all skins */

/* ========== ESTILOS GERAIS ========== */
a {
    text-underline-offset: 0px;
}

.external {
    background: none !important;
    padding-right: 0 !important;
}

/* ========== WAR COPY (TEXTO E IMAGENS) ========== */
.warp-copy {
    color: #0066cc;
    cursor: pointer;
    text-decoration: underline dotted #0066cc;
    text-underline-offset: 2px;
    position: relative;
    display: inline-block;
}

/* Tooltip padrão */
.warp-copy::after {
    content: "Copy";
    position: absolute;
    left: 50%;
    background-color: #333;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-50%);
}

/* Seta do tooltip */
.warp-copy::before {
    content: "";
    position: absolute;
    left: 50%;
    border-width: 4px;
    border-style: solid;
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-50%);
}

/* Tooltip PARA TEXTO */
.warp-copy:not(img)::after {
    bottom: calc(100% + 5px);
}

.warp-copy:not(img)::before {
    bottom: calc(100% + 1px);
    border-color: #333 transparent transparent transparent;
}

/* Tooltip PARA IMAGENS */
.tile-top.tile-image .warp-copy::after {
    bottom: -25px;
    top: auto !important;
}

.tile-top.tile-image .warp-copy::before {
    bottom: -18px;
    top: auto !important;
    border-color: #333 transparent transparent transparent !important;
}

/* Estados de hover */
.warp-copy:hover::after,
.warp-copy:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Feedback de copiado - APLICA-SE A TODOS OS WARP-COPY */
.warp-copy.copied::after {
    content: "Copied!" !important;
    background-color: #4CAF50 !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.warp-copy.copied {
    color: #4CAF50 !important;
    text-decoration: underline dotted #4CAF50 !important;
}

/* ========== ESTILOS ESPECÍFICOS PARA NPCs ========== */
.tile-row {
    display: flex;
    flex-flow: row wrap;
    margin-bottom: 1em;
}

.tile-halves {
    display: flex;
    flex-flow: row wrap;
    border: 1px solid #e4eaee;
    background: #ffffff;
    box-shadow: 0 0.25rem 0.35rem -0.25rem rgba(0, 0, 0, 0.1);
    position: relative;
}

.tile-halves h2 {
    font-size: 1.4em;
    font-weight: bold;
    border: none;
    margin: 0 0 0.4em;
}

.tile-top {
    width: 100%;
    padding: 1.3rem 1.5rem 0.6rem;
}

.tile-top.tile-image {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #949eaa;
    overflow: visible;
    padding: 0;
    height: auto;
    width: 100%;
    box-sizing: border-box;
}

.tile-top.tile-image a {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.tile-top.tile-image img {
    display: block;
    max-width: 100%;
    width: auto;
    height: auto;
    margin: 0;
    transition: 0.4s ease-out;
    object-fit: contain;
}

/* Estilo para tamanhos personalizados */
.tile-top.tile-image img.custom-size {
    width: var(--custom-width, auto);
    height: var(--custom-height, auto);
    max-width: var(--custom-width, 100%);
    max-height: var(--custom-height, none);
}

.tile-bottom {
    background: #ffffff;
    border-top: 1px solid #e4eaee;
    width: 100%;
    padding: 1rem 1.5rem 0.6rem;
}

.tile-bottom.link-button {
    align-self: center;
    padding: 0;
    width: auto;
    margin: 0 auto;
    max-width: fit-content;
}

.mainpage-contents .tile-halves {
    display: inline-block;
    flex: 0 0 auto;
    margin-right: 0.9rem;
    width: auto;
    max-width: max-content;
}

.mainpage-contents .tile-halves:hover .tile-top img {
    transform: scale(1.04);
}

.mainpage-contents .tile-halves:last-child {
    margin-right: 0;
}

.npc-subtitle {
    font-size: 0.8em;
    color: #666;
    margin-top: -5px;
    text-align: center;
    font-style: italic;
    line-height: 1.2;
}

.mainpage-contents.tile-row {
    display: flex;
    flex-flow: row wrap;
    gap: 15px;
    justify-content: flex-start;
}

.mainpage-contents .contents-equipment.tile-halves {
    margin-right: 0;
    flex: 0 0 auto;
    min-width: 150px;
    max-width: 200px;
}

/* Título do NPC */
.tile-bottom.link-button h2 .warp-copy {
    color: #000080;
    font-weight: bold;
    display: block;
    text-align: center;
    text-decoration: none;
}

.tile-bottom.link-button h2 {
    position: relative;
    overflow: visible;
}

/* Classes para dimensionamento manual */
.npc-image-small {
    max-width: 150px !important;
}
.npc-image-medium {
    max-width: 200px !important;
}
.npc-image-large {
    max-width: 250px !important;
}