MediaWiki:Common.js: differenze tra le versioni

Jump to navigation Jump to search
rimuovo codice spostato in gadget
(Importo qui il codice per gli slideshow, per evitare di appesantire il caricamento della pagina con uno script caricato a runtime (MediaWiki:Common.js/Slideshow.js). Fonte: en:MediaWiki:Common.js/Slideshows.js)
(rimuovo codice spostato in gadget)
 
mw.loader.using( [ 'mediawiki.user', 'mediawiki.util', 'mediawiki.notify' ] ).then( function () {
// Slideshows
$.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 );
}
}
});
});
});
$.when($.ready).then( function() { $( '.slides' ).slideshow(); } );
 
 
//$.when( mw.loader.using( ['mediawiki.util']), $.ready ).then(function() {

Menu di navigazione