Mudanças entre as edições de "MediaWiki:Common.js"

De Micropedia
Ir para navegação Ir para pesquisar
(teste de resposta)
(teste 05)
 
(19 revisões intermediárias pelo mesmo usuário não estão sendo mostradas)
Linha 1: Linha 1:
 
/* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki */
 
/* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki */
  
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
$(function() {
/* FastCCI botão - PERSONALIZADO                                              */
+
    // Cria o botão scroll-to-top button
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
    var $botaoTopo = $('<div id="botaoTopo">⬆️ Topo</div>').css({
 +
        display: "none",
 +
        position: "fixed",
 +
        bottom: "85px", // <-- distância do roda pé (~85px)
 +
        right: "20px",
 +
        padding: "10px 15px",
 +
        background: "#9bbeab",
 +
        color: "#000",
 +
        "border-radius": "8px",
 +
        cursor: "pointer",
 +
        "box-shadow": "0 2px 6px rgba(0,0,0,0.3)",
 +
        "font-weight": "bold",
 +
        "z-index": "9999"
 +
    }).appendTo("body");
  
<script>
+
    // Mostrar/esconder com base no scroll
document.addEventListener("DOMContentLoaded", function () {
+
    $(window).scroll(function() {
  const title = document.querySelector("#firstHeading"); // pega o título da página
+
        if ($(this).scrollTop() > $(document).height() / 2) {
  const buttonset = document.querySelector(".fastcci-buttonset"); // seu bloco copiado
+
            $botaoTopo.fadeIn();
 +
        } else {
 +
            $botaoTopo.fadeOut();
 +
        }
 +
    });
  
  if (title && buttonset) {
+
     // Ação ao clicar
     buttonset.style.marginLeft = "10px"; // dá um espaçamento
+
     $botaoTopo.click(function() {
     buttonset.style.display = "inline-block";
+
        $("html, body").animate({scrollTop: 0}, 500);
    title.appendChild(buttonset); // coloca ao lado do título
+
        return false;
  }
+
    });
 
});
 
});
</script>
 
  
<script>
+
// Script teste - slideshow trocar de imagem
document.addEventListener("DOMContentLoaded", function () {
+
mw.hook('wikipage.content').add(function () {
  const toggleButton = document.querySelector(".ui-button-icon-only");
+
 
  const menu = document.querySelector(".fastcci-menu");
+
    document.querySelectorAll('.gallerycarousel').forEach(function (carousel) {
  
  if (toggleButton && menu) {
+
        if (carousel.dataset.autoplay) return;
    toggleButton.addEventListener("click", function (e) {
+
        carousel.dataset.autoplay = 'true';
      e.preventDefault();
+
 
      menu.style.display = (menu.style.display === "block") ? "none" : "block";
+
        const nextBtn = carousel.querySelector('.oo-ui-icon-next');
    });
+
 
 +
        if (!nextBtn) return;
 +
 
 +
        setInterval(function () {
 +
            // força foco no botão
 +
            nextBtn.closest('a')?.focus();
  
    // Fecha o menu se clicar fora
+
            // dispara clique REAL
    document.addEventListener("click", function (e) {
+
            nextBtn.closest('a').dispatchEvent(
      if (!menu.contains(e.target) && !toggleButton.contains(e.target)) {
+
                new MouseEvent('click', {
         menu.style.display = "none";
+
                    bubbles: true,
      }
+
                    cancelable: true,
 +
                    view: window
 +
                })
 +
            );
 +
         }, 4000); // tempo entre slides
 
     });
 
     });
  }
 
 
});
 
});
</script>
 

Edição atual tal como às 05h09min de 8 de janeiro de 2026

/* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki */

$(function() {
    // Cria o botão scroll-to-top button
    var $botaoTopo = $('<div id="botaoTopo">⬆️ Topo</div>').css({
        display: "none",
        position: "fixed",
        bottom: "85px", // <-- distância do roda pé (~85px)
        right: "20px",
        padding: "10px 15px",
        background: "#9bbeab",
        color: "#000",
        "border-radius": "8px",
        cursor: "pointer",
        "box-shadow": "0 2px 6px rgba(0,0,0,0.3)",
        "font-weight": "bold",
        "z-index": "9999"
    }).appendTo("body");

    // Mostrar/esconder com base no scroll
    $(window).scroll(function() {
        if ($(this).scrollTop() > $(document).height() / 2) {
            $botaoTopo.fadeIn();
        } else {
            $botaoTopo.fadeOut();
        }
    });

    // Ação ao clicar
    $botaoTopo.click(function() {
        $("html, body").animate({scrollTop: 0}, 500);
        return false;
    });
});

// Script teste - slideshow trocar de imagem
mw.hook('wikipage.content').add(function () {

    document.querySelectorAll('.gallerycarousel').forEach(function (carousel) {

        if (carousel.dataset.autoplay) return;
        carousel.dataset.autoplay = 'true';

        const nextBtn = carousel.querySelector('.oo-ui-icon-next');

        if (!nextBtn) return;

        setInterval(function () {
            // força foco no botão
            nextBtn.closest('a')?.focus();

            // dispara clique REAL
            nextBtn.closest('a').dispatchEvent(
                new MouseEvent('click', {
                    bubbles: true,
                    cancelable: true,
                    view: window
                })
            );
        }, 4000); // tempo entre slides
    });
});