MediaWiki:Guidedtour-tour-tuto9.js

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 9 de Aide:Wikipédia pas à pas
* Utiliser les pages de discussion d'articles
*
* Voir [[:mw:Extension:GuidedTour]] pour plus d'informations
*
* Auteur : [[User:0x010C]]
* Création : 25 octobre 2016
* Dernière révision : 16 janvier 2018
* [[Catégorie:Guided tour]]
*/
//<nowiki>

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

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

	// 1
	tour.firstStep( {
		name: 'bienvenue',
		title: 'Tutoriel #9',
		description: new mw.Title( 'Aide:Wikipédia pas à pas/Textes/T9E1' ),
		overlay: true,
		closeOnClickOutside: false,
		onShow: function() {
			var api = new mw.Api();
			api.postWithToken( 'csrf', {
			//	action: 'edit',
			//	title: 'Projet:MOOC/2017/Participation/3.1',
			//	summary: 'Émargement automatique pour le premier module de la semaine 3 du WikiMOOC',
			//	tags: 'wikimooc2017',
			//	appendtext: '\n{{u|' + mw.config.get( 'wgUserName' ) + '}}',
			//	format: 'json',
			} );
		},
	} )
	.next( function () {
		gt.setTourCookie( 'tuto9', 'indentation' );
		window.location.href = mw.util.getUrl( 'Discussion:Voie romaine' );
	} )
	.transition( function () {
		// Si l'apprenant n'est pas connecté
		if ( mw.user.getId() === 0 )
			return 'connectetoi';
	} );
	
	// 2
	tour.step( {
		name: 'indentation',
		title: 'Indenter une discussion',
		description: new mw.Title( 'Projet:WikiMOOC/2017/GT/3.1/C/2' ),
		overlay: false,
		attachTo: 'dl:nth-of-type(2)',
		position: 'top',
		closeOnClickOutside: false,
	} )
	.back( function () {
		gt.setTourCookie( 'tuto9', 'bienvenue' );
		window.location.href = mw.util.getUrl( 'Wikipédia:WikiMOOC/2017/Utiliser les pages de discussion d\'article' );
	} )
	.next( function () {
		gt.setTourCookie( 'tuto9', 'codeindentation' );
		window.location.href = mw.util.getUrl( 'Discussion:Voie romaine' ) + '?action=edit';
	} );
	
	// 3
	tour.step( {
		name: 'codeindentation',
		title: 'Une indentation en wikicode',
		description: new mw.Title( 'Projet:WikiMOOC/2017/GT/3.1/C/3' ),
		overlay: false,
		attachTo: '#wpTextbox1',
		position: 'top',
		closeOnClickOutside: false,
	} )
	.back( function () {
		gt.setTourCookie( 'tuto9', 'indentation' );
		window.location.href = mw.util.getUrl( 'Discussion:Voie romaine' );
	} )
	.next( function () {
		gt.setTourCookie( 'tuto9', 'notifs' );
		window.location.href = mw.util.getUrl( 'Discussion utilisateur:' + mw.config.get( 'wgUserName' ) );
	} );
	
	// 4
	tour.step( {
		name: 'notifs',
		title: 'Des notifications ?',
		description: new mw.Title( 'Projet:WikiMOOC/2017/GT/3.1/C/4' ),
		overlay: false,
		attachTo: '',
		position: '',
		closeOnClickOutside: false,
	} )
	.back( function () {
		gt.setTourCookie( 'tuto9', 'codeindentation' );
		window.location.href = mw.util.getUrl( 'Discussion:Voie romaine' ) + '?action=edit';
	} )
	.next( 'modifier' );
	
	// 5
	tour.step( {
		name: 'modifier',
		title: 'Modifier le wikicode',
		description: new mw.Title( 'Projet:WikiMOOC/2017/GT/3.1/C/5' ),
		overlay: false,
		attachTo: '#ca-edit',
		position: 'bottom',
		closeOnClickOutside: false,
	} )
	.back( 'notifs' )
	.transition( function() {
		if ( mw.config.get( 'wgRelevantUserName' ) === mw.config.get( 'wgUserName' ) && mw.config.get( 'wgNamespaceNumber' ) === 3 && gt.isEditingWithWikitext() ) {
			return 'notifier';
		}
	} );
	
	// 6
	tour.step( {
		name: 'notifier',
		title: 'Notifions un robot',
		description: new mw.Title( 'Projet:WikiMOOC/2017/GT/3.1/C/6' ),
		overlay: false,
		attachTo: '',
		position: '',
		closeOnClickOutside: false,
	} )
	.back( function () {
		gt.setTourCookie( 'tuto9', 'modifier' );
		window.location.href = mw.util.getUrl( 'Discussion utilisateur:' + mw.config.get( 'wgUserName' ) );
	} )
	.next( 'signer' )
	.transition( function() {
		if ( mw.config.get( 'wgRelevantUserName' ) !== mw.config.get( 'wgUserName' ) && mw.config.get( 'wgNamespaceNumber' ) !== 3 || !gt.isEditingWithWikitext() ) {
			return 'modifier';
		}
	} );
	
	// 6b
	tour.step( {
		name: 'signer',
		title: 'La signature',
		description: new mw.Title( 'Projet:WikiMOOC/2017/GT/3.1/C/6b' ),
		overlay: false,
		attachTo: '#wikiEditor-section-main .group-insert a',
		position: 'bottom',
		closeOnClickOutside: false,
	} )
	.back( 'notifier' )
	.next( 'enregistrer' )
	.transition( function() {
		if ( mw.config.get( 'wgRelevantUserName' ) !== mw.config.get( 'wgUserName' ) && mw.config.get( 'wgNamespaceNumber' ) !== 3 || !gt.isEditingWithWikitext() ) {
			return 'modifier';
		}
	} );
	
	// 7
	tour.step( {
		name: 'enregistrer',
		title: 'Et on enregistre',
		description: new mw.Title( 'Projet:WikiMOOC/2017/GT/3.1/C/7' ),
		overlay: false,
		attachTo: '#wpSave',
		position: 'top',
		closeOnClickOutside: false,
	} )
	.back( 'signer' )
	.transition( function() {
		if ( mw.config.get( 'wgRelevantUserName' ) === mw.config.get( 'wgUserName' ) && mw.config.get( 'wgNamespaceNumber' ) === 3 && gt.isPostEdit() ) {
			return 'cloche';
		}
		
		if ( mw.config.get( 'wgRelevantUserName' ) !== mw.config.get( 'wgUserName' ) && mw.config.get( 'wgNamespaceNumber' ) !== 3 || !gt.isEditingWithWikitext() ) {
			return 'modifier';
		}
	} );
	
	// 8
	tour.step( {
		name: 'cloche',
		title: 'Recevoir une notification',
		description: new mw.Title( 'Projet:WikiMOOC/2017/GT/3.1/C/8' ),
		overlay: false,
		attachTo: '#pt-notifications-alert',
		position: 'bottom',
		closeOnClickOutside: false,
	} )
	.back( 'modifier' )
	.next( function () {
		gt.setTourCookie( 'tuto9', 'fin' );
		window.location.href = mw.util.getUrl( 'Wikipédia:Émoticônes' );
	} );
	
	// 9
	tour.step( {
		name: 'fin',
		title: 'Les émoticônes',
		description: new mw.Title( 'Aide:Wikipédia pas à pas/Textes/T9E9' ),
		overlay: false,
		attachTo: 'table',
		position: 'bottom',
		closeOnClickOutside: false,
		buttons: [ {
			action: 'okay',
			onclick: function() {
				gt.endTour();
				setTimeout( function() {
					window.location.href = mw.util.getUrl( 'Aide:Wikipédia pas à pas/Tutoriel 9' );
				}, 2000 );
			},
		} ],
		allowAutomaticOkay: false,
	} )
	.back( function () {
		gt.setTourCookie( 'tuto9', 'cloche' );
		window.location.href = mw.util.getUrl( 'Discussion utilisateur:' + mw.config.get( 'wgUserName' ) );
	} );



	// 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>