MediaWiki:Common.js/Slideshows.js: различия между версиями
Перейти к навигации
Перейти к поиску
(Created page with "→Any JavaScript here will be loaded for all users on every page load.: $.fn.slideshow = ( function() { return this.each( function() { var $ss = $(this), $sl = $ss.children( '.slide' ), $actions; if ( $sl.length < 2 ) { return; } $sl.slice(1).hide(); $actions = $('<div class="slide-actions"><span class="slide-prev"></span><span class="slide-next"></span></div>'); $ss.data( 'slides', { 'at': 0, 'total': $sl.length }).append( $actions ).click( functio...") |
Нет описания правки |
||
Строка 1: | Строка 1: | ||
$.fn.slideshow = ( function() { | $.fn.slideshow = ( function() { | ||
return this.each( function() { | return this.each( function() { |
Текущая версия от 00:12, 16 февраля 2024
$.fn.slideshow = ( function() {
return this.each( function() {
var $ss = $(this), $sl = $ss.children( '.slide' ), $actions;
if ( $sl.length < 2 ) {
return;
}
$sl.slice(1).hide();
$actions = $('<div class="slide-actions"><span class="slide-prev"></span><span class="slide-next"></span></div>');
$ss.data( 'slides', { 'at': 0, 'total': $sl.length }).append( $actions ).click( function(e) {
var $where = $( e.target ), $ss, $sl, data;
if ( $where.is( '.slide-prev' ) ) {
e.stopPropagation();
$ss = $(this); $sl = $ss.children( '.slide' ); data = $ss.data( 'slides' );
if ( data.at > 0 ) {
--data.at;
$sl.eq( data.at + 1).fadeOut(1000).end().eq( data.at ).delay(1000).fadeIn(1000);
$ss.data( 'slides', data );
}
} else if ( $where.is( '.slide-next' ) ) {
e.stopPropagation();
$ss = $(this); $sl = $ss.children( '.slide' ); data = $ss.data( 'slides' );
if ( data.at < data.total - 1 ) {
++data.at;
$sl.eq( data.at - 1).fadeOut(1000).end().eq( data.at ).delay(1000).fadeIn(1000);
$ss.data( 'slides', data );
}
}
});
});
});
$(document).ready( function() { $( '.slides' ).slideshow(); } );