MediaWiki:Gadget-gallery.js

Z Wikisłownika – wolnego słownika wielojęzycznego

Uwaga: aby zobaczyć zmiany po opublikowaniu, może zajść potrzeba wyczyszczenia pamięci podręcznej przeglądarki.

  • Firefox / Safari: Przytrzymaj Shift podczas klikania Odśwież bieżącą stronę, lub naciśnij klawisze Ctrl+F5, lub Ctrl+R (⌘-R na komputerze Mac)
  • Google Chrome: Naciśnij Ctrl-Shift-R (⌘-Shift-R na komputerze Mac)
  • Internet Explorer / Edge: Przytrzymaj Ctrl, jednocześnie klikając Odśwież, lub naciśnij klawisze Ctrl+F5
  • Opera: Naciśnij klawisze Ctrl+F5.
/**
 * Skrypt dla Szablon:Galeria
 */

function toggleImage( dir ) {
	this.hide();
	this[ dir ]().show();
	return false;
}

function ImageGroup() {
	$( '.ImageGroup > .ImageGroupUnits' ).each( function () {
		var $units = $( this ).children();
		
		$units.each( function ( index ) {
			var $imgHead, $currentImage = $( this );
			
			if ( index !== 0 ) {
				$currentImage.hide();
			}
			
			if ( $units.length > 1 ) {
				$imgHead = $( '<div>' ).css( {
					fontSize: '110%',
					fontWeight: 'bold'
				} );
				
				if ( index !== 0 ) {
					$( '<a>' )
						.attr( 'href', '#' )
						.text( '◀' )
						.on( 'click', $.proxy( toggleImage, $currentImage, 'prev' ) )
						.appendTo( $imgHead );
				}
				
				$( '<tt>' )
					.text( mw.format( '($1/$2)', index + 1, $units.length ) )
					.appendTo( $imgHead );
				
				if ( index !== $units.length - 1 ) {
					$( '<a>' )
						.attr( 'href', '#' )
						.text( '▶' )
						.on( 'click', $.proxy( toggleImage, $currentImage, 'next' ) )
						.appendTo( $imgHead );
				}
				
				$imgHead.prependTo( $currentImage );
			}
		} );
	} );
}

if ( !mw.util.getParamValue( 'printable' ) ) {
	$( ImageGroup );
}