MediaWiki:Common.js: mudanças entre as edições

De Farmland
Ir para navegação Ir para pesquisar
Sem resumo de edição
Sem resumo de edição
Etiqueta: Revertido
Linha 132: Linha 132:
   ======================================================= */
   ======================================================= */


 
document.querySelectorAll('.ragnarok-tree td').forEach(cell => {
 
    cell.addEventListener('mouseenter', function() {
 
        // Pega a classe de evolução (evo-sw, evo-ar, etc)
 
        const family = Array.from(this.classList).find(c => c.startsWith('evo-'));
 
        if (family && family !== 'evo-all') {
document.addEventListener("DOMContentLoaded", function () {
             document.querySelectorAll('.' + family).forEach(el => {
    const items = document.querySelectorAll(".class-main");
                 el.classList.add('evo-active');
 
    items.forEach(item => {
        item.addEventListener("click", function () {
            const sub = this.nextElementSibling;
 
             document.querySelectorAll(".class-sub").forEach(el => {
                 if (el !== sub) el.style.display = "none";
             });
             });
        }
    });


            sub.style.display = (sub.style.display === "block") ? "none" : "block";
    cell.addEventListener('mouseleave', function() {
        document.querySelectorAll('.evo-active').forEach(el => {
            el.classList.remove('evo-active');
         });
         });
     });
     });
});
});

Edição das 19h37min de 23 de abril de 2026

/* =======================================================
   CARROSSEL UNIFICADO - WIKI EVERLIGHT
   ======================================================= */
mw.loader.using(['jquery', 'mediawiki.util'], function () {
    $(function() {
        const $wrapper = $('.carousel-wrapper');
        const $items = $('.carousel-item');
        const $next = $('.right-btn');
        const $prev = $('.left-btn');
        
        if (!$wrapper.length) return; // Só executa se o carrossel existir na página

        let current = 0;
        let autoPlayTimer;

        function updateCarousel() {
            // Atualiza a classe ativa para o efeito visual de destaque
            $items.removeClass('active').eq(current).addClass('active');

            const activeItem = $items.get(current);
            const scrollPosition = 
                activeItem.offsetLeft - 
                ($wrapper.width() / 2) + 
                ($(activeItem).outerWidth() / 2);

            $wrapper.stop().animate({
                scrollLeft: scrollPosition
            }, 500);
        }

        // Funções de Navegação
        function moveNext() {
            current = (current + 1) % $items.length;
            updateCarousel();
        }

        function movePrev() {
            current = (current - 1 + $items.length) % $items.length;
            updateCarousel();
        }

        // Eventos de Clique
        $next.on('click', function() {
            stopAutoPlay();
            moveNext();
        });

        $prev.on('click', function() {
            stopAutoPlay();
            movePrev();
        });

        // Auto-Play (4 segundos)
        function startAutoPlay() {
            autoPlayTimer = setInterval(moveNext, 4000);
        }

        function stopAutoPlay() {
            clearInterval(autoPlayTimer);
        }

        // Inicialização
        updateCarousel();
        startAutoPlay();

        // Pausa o carrossel se o mouse estiver em cima
        $wrapper.hover(stopAutoPlay, startAutoPlay);
    });
});


/* =======================================================
   ARVORE HABILIDADE - WIKI EVERLIGHT
   ======================================================= */


document.addEventListener('DOMContentLoaded', () => {
    const cards = document.querySelectorAll('.skill-card');

    cards.forEach(card => {
        card.addEventListener('click', () => {
            const skillName = card.querySelector('.skill-name').innerText;
            console.log(`Habilidade clicada: ${skillName}`);
            
            // Exemplo de efeito visual simples
            card.style.filter = "brightness(1.2)";
            setTimeout(() => {
                card.style.filter = "brightness(1)";
            }, 150);
        });
    });
});

document.querySelectorAll('.carousel-track').forEach(track => {
  track.addEventListener('mouseenter', () => {
    track.querySelectorAll('.carousel-item').forEach(item => {
      item.style.animationPlayState = 'paused';
    });
  });
  track.addEventListener('mouseleave', () => {
    track.querySelectorAll('.carousel-item').forEach(item => {
      item.style.animationPlayState = 'running';
    });
  });
});

/* =======================================================
   BOTAO SUBIR TOPO DA PAGINA
   ======================================================= */
$(function() {
    var $button = $('<button id="back-to-top" title="Voltar ao Topo">↑ Topo</button>');
    $('body').append($button);

    $(window).scroll(function() {
        // Verifica se a posição atual + altura da janela é maior que o tamanho total - 100px
        if ($(window).scrollTop() + $(window).height() > $(document).height() - 100) {
            $button.fadeIn();
        } else {
            $button.fadeOut();
        }
    });

    $button.click(function() {
        $('html, body').animate({scrollTop: 0}, 'slow');
        return false;
    });
});


/* =======================================================
   clases testee
   ======================================================= */

document.querySelectorAll('.ragnarok-tree td').forEach(cell => {
    cell.addEventListener('mouseenter', function() {
        // Pega a classe de evolução (evo-sw, evo-ar, etc)
        const family = Array.from(this.classList).find(c => c.startsWith('evo-'));
        if (family && family !== 'evo-all') {
            document.querySelectorAll('.' + family).forEach(el => {
                el.classList.add('evo-active');
            });
        }
    });

    cell.addEventListener('mouseleave', function() {
        document.querySelectorAll('.evo-active').forEach(el => {
            el.classList.remove('evo-active');
        });
    });
});