MediaWiki:Common.js: mudanças entre as edições
Aparência
Sem resumo de edição |
Sem resumo de edição |
||
| Linha 17: | Linha 17: | ||
} ); | } ); | ||
} )( jQuery ); | } )( jQuery ); | ||
//Js para autoplay e mostrar preview | |||
$(function() { | |||
$('.video-preview').each(function() { | |||
var $container = $(this); | |||
var videoId = $container.data('video-id'); | |||
var $img = $container.find('img'); | |||
var player; | |||
$container.mouseenter(function() { | |||
// Cria o iframe do YouTube dinamicamente | |||
var iframe = $('<iframe>', { | |||
src: 'https://www.youtube.com/embed/' + videoId + '?autoplay=1&mute=1&controls=0&modestbranding=1', | |||
width: $img.attr('width'), | |||
height: $img.attr('height'), | |||
frameborder: 0, | |||
allow: 'autoplay; encrypted-media' | |||
}); | |||
$img.hide(); | |||
$container.append(iframe); | |||
}); | |||
$container.mouseleave(function() { | |||
// Remove o iframe e volta a imagem original | |||
$container.find('iframe').remove(); | |||
$img.show(); | |||
}); | |||
// Opcional: Clique para ir ao vídeo real no YouTube | |||
$container.click(function() { | |||
window.open('https://www.youtube.com/watch?v=' + videoId, '_blank'); | |||
}); | |||
}); | |||
}); | |||
Edição das 12h32min de 1 de abril de 2026
/* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki */
( function ( $ ) {
// Carrega o script do Slick.js de um CDN
mw.loader.load( 'https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.js', 'text/javascript' );
// Código que inicializa o carrossel com a sua configuração personalizada
$( function () {
$( '.autoplay' ).slick( {
slidesToShow: 1,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed: 3000,
pauseOnHover: false,
pauseOnFocus: false,
} );
} );
} )( jQuery );
//Js para autoplay e mostrar preview
$(function() {
$('.video-preview').each(function() {
var $container = $(this);
var videoId = $container.data('video-id');
var $img = $container.find('img');
var player;
$container.mouseenter(function() {
// Cria o iframe do YouTube dinamicamente
var iframe = $('<iframe>', {
src: 'https://www.youtube.com/embed/' + videoId + '?autoplay=1&mute=1&controls=0&modestbranding=1',
width: $img.attr('width'),
height: $img.attr('height'),
frameborder: 0,
allow: 'autoplay; encrypted-media'
});
$img.hide();
$container.append(iframe);
});
$container.mouseleave(function() {
// Remove o iframe e volta a imagem original
$container.find('iframe').remove();
$img.show();
});
// Opcional: Clique para ir ao vídeo real no YouTube
$container.click(function() {
window.open('https://www.youtube.com/watch?v=' + videoId, '_blank');
});
});
});