Mudanças entre as edições de "MediaWiki:Common.js"
Ir para navegação
Ir para pesquisar
(teste de script 01) |
(teste 05) |
||
| (3 revisões intermediárias pelo mesmo usuário não estão sendo mostradas) | |||
| Linha 35: | Linha 35: | ||
// Script teste - slideshow trocar de imagem | // Script teste - slideshow trocar de imagem | ||
| − | mw. | + | 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 | ||
| + | }); | ||
}); | }); | ||
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
});
});