MediaWiki:Guidedtour-tour-tuto2.js

Une page de Wikipédia, l'encyclopédie libre.
Note : après avoir enregistré la page, vous devrez forcer le rechargement complet du cache de votre navigateur pour voir les changements.

Mozilla / Firefox / Konqueror / Safari : maintenez la touche Majuscule (Shift) en cliquant sur le bouton Actualiser (Reload) ou pressez Maj-Ctrl-R (Cmd-R sur Apple Mac) ;

Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5.
/*
* Tutoriel 2 de Aide:Wikipédia pas à pas
* Historiques et liste de suivi
*
* Voir [[:mw:Extension:GuidedTour]] pour plus d'informations
*
* Auteur : [[User:0x010C]]
* Création : 25 octobre 2016
* Dernière révision : 17 janvier 2018 / fonctionne (Chrome Windows 7) au 2 avril 2019
* [[Catégorie:Guided tour]]
*/
//<nowiki>

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

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

	// 1
	tour.firstStep( {
		name: 'bienvenue',
		title: 'Bienvenue ! (1/11)',
		description: new mw.Title( 'Projet:WikiMOOC/2017/GT/2.1/A/1' ),
		overlay: true,
		closeOnClickOutside: false,
		} )
	.next( function() {
		window.location.href = mw.util.getUrl( 'Framboise' );
	} )
	.transition( function() {
		// Si l'apprenant n'est pas connecté
		if ( mw.user.getId() === 0 ) {
			return 'connectetoi';
		}
		if (mw.config.get( 'wgPageName' ) === 'Framboise' ) {
			return 'onglethisto';
		}
	} );
	
	// 2
	tour.step( {
		name: 'onglethisto',
		title: 'Accéder à l\'historique (2/11)',
		description: new mw.Title( 'Projet:WikiMOOC/2017/GT/2.1/A/2' ),
		attachTo: '#ca-history',
		position: 'bottom',
		autoFocus: true,
		closeOnClickOutside: false,
	} )
	.back( 'bienvenue' )
	.transition( function() {
		//Si l'apprenant est allé dans l'historique
		if ( mw.config.get( 'wgPageName' ) === 'Framboise' && mw.config.get( 'wgAction' ) === 'history' ) {
			return 'historique';
		}
		//Si l'apprenant n'est plus sur l'article Framboise
		if ( mw.config.get( 'wgPageName' ) !== 'Framboise' ) {
			return 'bienvenue';
		}
	} );
	
	// 3
	tour.step( {
		name: 'historique',
		title: 'L\'interface de l\'historique (3/11)',
		description: new mw.Title( 'Projet:WikiMOOC/2017/GT/2.1/A/3' ),
		autoFocus: true,
		overlay: true,
		closeOnClickOutside: false,
	} )
	.back( function() {
		gt.setTourCookie( 'tuto2', 'onglethisto' );
		window.location.href = mw.util.getUrl( 'Framboise' );
	} )
	.next( 'detailhisto' );
	
	// 4
	tour.step( {
		name: 'detailhisto',
		title: 'Détail d\'une ligne d\'historique (4/11)',
		description: new mw.Title( 'Projet:WikiMOOC/2017/GT/2.1/A/4' ),
		attachTo: '#pagehistory .selected.after',
		position: 'bottomLeft',
		autoFocus: true,
		closeOnClickOutside: false,
	} )
	.back( 'historique' )
	.next( 'archive' );
	
	// 5
	tour.step( {
		name: 'archive',
		title: 'Consulter la version archivée d\'un article (5/11)',
		description: new mw.Title( 'Projet:WikiMOOC/2017/GT/2.1/A/5' ),
		attachTo: '#pagehistory .selected.after .mw-changeslist-date',
		position: 'bottom',
		autoFocus: true,
		closeOnClickOutside: false,
	} )
	.back( 'detailhisto' )
	.next( 'liendiff' );
	
	// 6
	tour.step( {
		name: 'liendiff',
		title: 'Accéder à un diff (6/11)',
		description: new mw.Title( 'Projet:WikiMOOC/2017/GT/2.1/A/6' ),
		attachTo: '#pagehistory .selected.after .mw-history-histlinks',
		position: 'bottomLeft',
		autoFocus: true,
		closeOnClickOutside: false,
	} )
	.back( 'archive' )
	.transition( function() {
		//Si l'apprenant est allé sur le diff
		if ( mw.config.get( 'wgPageName' ) === 'Framboise' && mw.config.get( 'wgAction' ) === 'view' && $( '.diff' ).length ) {
			return 'diff';
		}
		//Si l'apprenant n'est plus dans l'historique de l'article framboise
		if ( mw.config.get( 'wgPageName' ) === 'Framboise' && mw.config.get( 'wgAction' ) !== 'history' ) {
			return 'onglethisto';
		}
		//Si l'apprenant n'est plus sur l'article Framboise
		if ( mw.config.get( 'wgPageName' ) !== 'Framboise' ) {
			return 'bienvenue';
		}
	} );
	
	// 7
	tour.step( {
		name: 'diff',
		title: 'Voici un diff (7/11)',
		description: new mw.Title( 'Projet:WikiMOOC/2017/GT/2.1/A/7' ),
		autoFocus: true,
		overlay: true,
		closeOnClickOutside: false,
	} )
	.back( function() {
		gt.setTourCookie( 'tuto2', 'liendiff' );
		window.location.href = mw.util.getUrl( 'Framboise' ) + '?action=history';
	} )
	.next( function() {
		gt.setTourCookie( 'tuto2', 'etoile' );
		window.location.href = mw.util.getUrl( 'Framboise' );
	} );
	
	// 8
	tour.step( {
		name: 'etoile',
		title: 'Suivre une page (8/11)',
		description: new mw.Title( 'Projet:WikiMOOC/2017/GT/2.1/A/8' ),
		attachTo: '#ca-watch',
		position: 'bottomRight',
		autoFocus: true,
		closeOnClickOutside: false,
	} )
	.back( function() {
		gt.setTourCookie( 'tuto2', 'liendiff' );
		window.location.href = mw.util.getUrl( 'Framboise' ) + '?action=history';
	} );
	//Hack to perform a transition when the watch-star is clicked
	$( '.icon.mw-watchlink' ).on( 'watchpage.mw', function(){
		gt.setTourCookie( 'tuto2', 'pagesuivi' );
		gt.launchTourFromUserState();
	} );
	
	// 9
	tour.step( {
		name: 'pagesuivi',
		title: 'Page suivie (9/11)',
		description: new mw.Title( 'Projet:WikiMOOC/2017/GT/2.1/A/9' ),
		autoFocus: true,
		closeOnClickOutside: false,
	} )
	.back( 'etoile' )
	.transition( function() {
		if ( mw.config.get( 'wgPageName' ) == 'Spécial:Liste_de_suivi' ) {
			return 'listesuivi';
		}
	} );

	// 10	
	tour.step( {
		name: 'listesuivi',
		title: 'Votre liste de suivi (10/11)',
		description: new mw.Title( 'Projet:WikiMOOC/2017/GT/2.1/A/10' ),
		autoFocus: true,
		overlay: true,
		closeOnClickOutside: false,
	} )
	.back( function() {
		gt.setTourCookie( 'tuto2', 'pagesuivi' );
		window.location.href = mw.util.getUrl( 'Framboise' );
	} )
	.next( function() {
		gt.setTourCookie( 'tuto2', 'fin' );
		window.location.href = mw.util.getUrl( 'Aide:Wikipédia pas à pas/Tutoriel 2' );
	} );

	// 11
	tour.step( {
		name: 'fin',
		title: 'Fin du tutoriel (11/11)',
		description: new mw.Title( 'Aide:Wikipédia pas à pas/Textes/T2E11' ),
		autoFocus: true,
		overlay: true,
		closeOnClickOutside: false,
		buttons: [ {
			action: 'end'
		} ],
		allowAutomaticOkay: false,
	} )
	.back( function() {
		gt.setTourCookie( 'tuto2', 'listesuivi' );
		window.location.href = mw.util.getUrl( 'Spécial:Liste_de_suivi' );
	} );



	// 0
	tour.step( {
		name: 'connectetoi',
		title: 'Connectez-vous',
		description: new mw.Title( 'Projet:WikiMOOC/2017/GT/0' ),
		autoFocus: true,
		overlay: true,
		closeOnClickOutside: false,
	} )
	.transition( function() {
		// Si l'apprenant s'est connecté
		if ( mw.user.getId() !== 0 )
			return 'bienvenue';
	} );
	
	//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',
			title: '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 ) );

//</nowiki>