MediaWiki:Guidedtour-tour-historique.js

Remarque: après avoir sauvegardé, vous devez vider le cache de votre navigateur pour que les changements prennent effet. Mozilla, cliquez sur Actualiser (ou ctrl-r). Internet Explorer / Opera: ctrl-f5. Safari: cmd-r. Konqueror ctrl-r.

/*
* Tutoriel interactif : L'historique
* Plan et textes sur [[Projet:Tutoriels#L’historique]]
*
* Voir [[:mw:Extension:GuidedTour]] pour plus d'informations
*
* Auteur : [[User:0x010C]]
* [[Catégorie:Guided tour]]
*/

( function ( window, document, $, mw, gt ) {
	var tour;

	tour = new gt.TourBuilder( {
		name: 'historique',
		shouldLog: false
	} );

	// 1
	tour.firstStep( {
		name: 'bienvenue',
		title: 'L’historique',
		description: new mw.Title( 'Tutoriel:Historique/1' ),
		overlay: true,
		closeOnClickOutside: false,
	} )
	.next( function() {
		window.location.href = mw.util.getUrl( 'Wiktionnaire:Bac à sable' );
	} )
	.transition( function() {
		if ( mw.config.get( 'wgPageName' ) === 'Wiktionnaire:Bac_à_sable' )
			return 'onglet';
	} );
	
	// 2
	tour.step( {
		name: 'onglet',
		title: 'Ouvrir l’historique d’une page',
		description: new mw.Title( 'Tutoriel:Historique/2' ),
		attachTo: '#ca-history',
		position: 'bottomRight',
		autoFocus: true,
		closeOnClickOutside: false,
	} )
	.back( function() {
		gt.setTourCookie( 'historique', 'bienvenue' );
		window.location.href = mw.util.getUrl( 'Tutoriel:Historique' );
	} )
	.transition( function() {
		if ( mw.config.get( 'wgAction' ) === 'history' )
			return 'presentation';
	} );
	
	// 3
	tour.step( {
		name: 'presentation',
		title: 'Qu’est-ce que l’historique ?',
		description: new mw.Title( 'Tutoriel:Historique/3' ),
		autoFocus: true,
		closeOnClickOutside: false,
	} )
	.back( function() {
		gt.setTourCookie( 'historique', 'onglet' );
		window.location.href = mw.util.getUrl( 'Wiktionnaire:Bac à sable' );
	} )
	.next( 'ligne' );
	
	// 4
	tour.step( {
		name: 'ligne',
		title: 'Une ligne d’historique',
		description: new mw.Title( 'Tutoriel:Historique/4' ),
		attachTo: '#pagehistory li:nth-child(2)',
		position: 'top',
		autoFocus: true,
		closeOnClickOutside: false,
	} )
	.back( 'presentation' )
	.next( 'lienversion' );
	
	// 5
	tour.step( {
		name: 'lienversion',
		title: 'Chaque version est consultable',
		description: new mw.Title( 'Tutoriel:Historique/5' ),
		attachTo: '#pagehistory li:nth-child(2) .mw-changeslist-date',
		position: 'topLeft',
		autoFocus: true,
		closeOnClickOutside: false,
	} )
	.back( 'ligne' )
	.next( 'liendiff' );
	
	// 6
	tour.step( {
		name: 'liendiff',
		title: 'Voir les différences entre deux versions',
		description: new mw.Title( 'Tutoriel:Historique/6' ),
		attachTo: '#pagehistory li:nth-child(2) .mw-history-histlinks a:nth-child(2)',
		position: 'right',
		autoFocus: true,
		closeOnClickOutside: false,
	} )
	.back( 'lienversion' )
	.transition( function() {
		if ( mw.config.get( 'wgAction' ) === 'view' && $( '.diff' ).length ) {
			return 'diff';
		}
	} );
	
	// 7
	tour.step( {
		name: 'diff',
		title: 'Historique : différence entre versions',
		description: new mw.Title( 'Tutoriel:Historique/7' ),
		autoFocus: true,
		closeOnClickOutside: false,
	} )
	.back( function() {
		gt.setTourCookie( 'historique', 'liendiff' );
		window.location.href = mw.util.getUrl( 'Wiktionnaire:Bac à sable', { action: 'history' } );
	} )
	.next( 'annuler' );
	
	// 8
	tour.step( {
		name: 'annuler',
		title: 'Annuler une modification',
		description: new mw.Title( 'Tutoriel:Historique/8' ),
		attachTo: '.mw-diff-undo',
		position: 'bottomRight',
		autoFocus: true,
		closeOnClickOutside: false,
	} )
	.back( 'diff' )
	.next( function() {
		window.location.href = mw.util.getUrl( 'Wiktionnaire:Bac à sable', { action: 'history' } );
	} )
	.transition( function() {
		if ( mw.config.get( 'wgAction' ) === 'history' )
			return 'blame';
	} );
	
	// 9
	tour.step( {
		name: 'blame',
		title: 'Rechercher l’auteur d’un passage de l’article',
		description: new mw.Title( 'Tutoriel:Historique/9' ),
		attachTo: '.mw-history-legend a:nth-child(2)',
		position: 'bottom',
		autoFocus: true,
		closeOnClickOutside: false,
	} )
	.back( 'liendiff' )
	.next( function() {
		window.location.href = mw.util.getUrl( 'Tutoriel:Historique' );
	} )
	.transition( function() {
		if ( mw.config.get( 'wgPageName' ) === 'Tutoriel:Historique' )
			return 'fin';
	} );
	

	// 10	
	tour.step( {
		name: 'fin',
		title: 'Fin',
		description: new mw.Title( 'Tutoriel:Historique/10' ),
		autoFocus: true,
		overlay: true,
		closeOnClickOutside: false,
		buttons: [ {
			action: 'end'
		} ],
		allowAutomaticOkay: false,
	} );

	window.tour = tour;
	
	//Ajout d'un bouton en bas à droite pour permettre de réafficher une étape accidentellement fermé
	mw.loader.using( [ 'oojs-ui' ], function () {
		var reloadButton = new OO.ui.ButtonWidget( {
			label: 'Réafficher l’étape courante',
			icon: 'redo',
			iconTitle: 'Réafficher'
		} );
		reloadButton.on( 'click', function() {
			gt.launchTourFromUserState();
		} );
		var container = $( '<div>' );
		container.append( reloadButton.$element[ 0 ] );
		container.css( 'position', 'fixed' ).css( 'bottom', '0px' ).css( 'right', '0px' ).css( 'z-index', '3000' ).appendTo( 'body' );
	} );

} ( window, document, jQuery, mediaWiki, mediaWiki.guidedTour ) );