MediaWiki:Guidedtour-tour-wikimooc51b.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.
/*
* Guidedtour #14 du WikiMOOC
* Chercher une image sur Commons
*
* Voir [[:mw:Extension:GuidedTour]] pour plus d'informations
*
* Auteur : [[User:0x010C]]
* Création : 30 mars 2017
* Dernière révision : 30 mars 2017
* [[Catégorie:Guided tour]]
*/
//<nowiki>

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

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

	// Switch the namespace depending on which wiki we are
	var namespace = 'Projet:';
	if ( mw.config.get( 'wgWikiID' ) === 'commonswiki' ) {
		namespace = 'Commons:';
	}

	// 1
	tour.firstStep( {
		name: 'bienvenue',
		title: 'Tutoriel #14',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/B/1' ),
		overlay: true,
		closeOnClickOutside: false,
	} )
	.next( function() {
		window.location.href = mw.util.getUrl( ':c:Accueil' ) + '?tour=wikimooc51b&step=commons';
	} )
	.transition( function() {
		// Si l'apprenant n'est pas connecté
		if ( mw.user.getId() === 0 )
			return 'connectetoi';
	} );
	
	// 1b
	tour.step( {
		name: 'commons',
		title: 'Bienvenue sur Commons !',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/B/1b' ),
		overlay: true,
		closeOnClickOutside: false,
	} )
	.back( function() {
		window.location.href = mw.util.getUrl( ':fr:Wikipédia:WikiMOOC/2017/Chercher une image sur Commons' ) + '?tour=wikimooc51b&step=bienvenue';
	} )
	.next( function() {
		// Si l'apprenant n'est pas connecté
		if ( mw.user.getId() === 0 ) {
			return 'connectetoi';
		}
		return 'boiterecherche';
	} );
	
	// 2
	tour.step( {
		name: 'boiterecherche',
		title: 'Barre de recherche',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/B/2' ),
		overlay: false,
		attachTo: '#searchInput',
		position: 'bottomRight',
		closeOnClickOutside: false,
	} )
	.back( 'commons' )
	.next( function() {
		$( '#searchInput' ).attr( 'value', 'Kilimanjaro' );
		$( '#searchInput' ).trigger( 'keypress' );
		return 'rechercheencours';
	} );
	
	// 3
	tour.step( {
		name: 'rechercheencours',
		title: 'Rechercher',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/B/3' ),
		overlay: false,
		attachTo: '.mw-searchSuggest-link .suggestions-special',
		position: 'left',
		closeOnClickOutside: false,
	} )
	.back( 'boiterecherche' )
	.next( function() {
		gt.setTourCookie( 'wikimooc51b', 'resultats' );
		window.location.href = 'https://commons.wikimedia.org/w/index.php?search=Kilimanjaro&title=Special%3ASearch&fulltext=1';
	} );
	
	// 4
	tour.step( {
		name: 'resultats',
		title: 'Page des résultats',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/B/4' ),
		overlay: false,
		attachTo: '.searchResultImage',
		position: 'right',
		closeOnClickOutside: false,
	} )
	.back( function() {
		gt.setTourCookie( 'wikimooc51b', 'boiterecherche' );
		window.location.href = mw.util.getUrl( 'Accueil' );
	} )
	.next( function() {
		gt.setTourCookie( 'wikimooc51b', 'image' );
		window.location.href = mw.util.getUrl( 'File:Kilimanjaro from Amboseli.jpg' );
	} );
	
	// 5
	tour.step( {
		name: 'image',
		title: 'Composition de la page d\'une image',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/B/5' ),
		overlay: false,
		closeOnClickOutside: false,
	} )
	.back( function() {
		gt.setTourCookie( 'wikimooc51b', 'resultats' );
		window.location.href = 'https://commons.wikimedia.org/w/index.php?search=Kilimanjaro&title=Special%3ASearch&fulltext=1';
	} )
	.next( 'description' );
	
	// 6
	tour.step( {
		name: 'description',
		title: 'Descriptif',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/B/6' ),
		overlay: false,
		attachTo: '.commons-file-information-table',
		position: 'bottomLeft',
		closeOnClickOutside: false,
	} )
	.back( 'image' )
	.next( 'licence' );
	
	// 7
	tour.step( {
		name: 'licence',
		title: 'Licence',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/B/7' ),
		overlay: false,
		attachTo: '.licensetpl_wrapper',
		position: 'bottomLeft',
		closeOnClickOutside: false,
	} )
	.back( 'description' )
	.next( function() {
		gt.setTourCookie( 'wikimooc51b', 'recherchebis' );
		window.location.href = 'https://commons.wikimedia.org/w/index.php?search=Kilimanjaro&title=Special%3ASearch&fulltext=1';
	} );
	
	// 8
	tour.step( {
		name: 'recherchebis',
		title: 'Des images, mais aussi des pages...',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/B/8' ),
		overlay: false,
		attachTo: '.mw-search-result-heading',
		position: 'right',
		closeOnClickOutside: false,
	} )
	.back( function() {
		gt.setTourCookie( 'wikimooc51b', 'licence' );
		window.location.href = mw.util.getUrl( 'File:Kilimanjaro from Amboseli.jpg' );
	} )
	.next( function() {
		gt.setTourCookie( 'wikimooc51b', 'page' );
		window.location.href = mw.util.getUrl( 'Kilimanjaro' );
	} );
	
	// 9
	tour.step( {
		name: 'page',
		title: 'Voici une page',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/B/9' ),
		overlay: false,
		attachTo: '.gallery mw-gallery-traditional',
		position: 'top',
		closeOnClickOutside: false,
	} )
	.back( function() {
		gt.setTourCookie( 'wikimooc51b', 'recherchebis' );
		window.location.href = 'https://commons.wikimedia.org/w/index.php?search=Kilimanjaro&title=Special%3ASearch&fulltext=1';
	} )
	.next( function() {
		gt.setTourCookie( 'wikimooc51b', 'rechercheter' );
		window.location.href = 'https://commons.wikimedia.org/w/index.php?search=Kilimanjaro&title=Special%3ASearch&fulltext=1';
	} );
	
	
	// prepare step 10
	if ( mw.config.get( 'wgPageName' ) === 'Special:Search' ) {
		$( 'a:contains("Category:Kilimanjaro")' ).attr( 'id', 'gt-mooc-51b-10' );
	}
	// 10
	tour.step( {
		name: 'rechercheter',
		title: 'Des images, mais aussi des catégories !',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/B/10' ),
		overlay: false,
		attachTo: '#gt-mooc-51b-10',
		position: 'right',
		closeOnClickOutside: false,
	} )
	.back( function() {
		gt.setTourCookie( 'wikimooc51b', 'page' );
		window.location.href = mw.util.getUrl( 'Kilimanjaro' );
	} )
	.next( function() {
		gt.setTourCookie( 'wikimooc51b', 'category' );
		window.location.href = mw.util.getUrl( 'Category:Kilimanjaro' );
	} );
	
	// 11
	tour.step( {
		name: 'category',
		title: 'Et voici la catégorie',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/B/11' ),
		overlay: false,
		attachTo: '#mw-category-media',
		position: 'top',
		closeOnClickOutside: false,
	} )
	.back( function() {
		gt.setTourCookie( 'wikimooc51b', 'rechercheter' );
		window.location.href = 'https://commons.wikimedia.org/w/index.php?search=Kilimanjaro&title=Special%3ASearch&fulltext=1';
	} )
	.next( function() {
		gt.endTour();
		window.location.href = mw.util.getUrl( ':fr:Wikipédia:WikiMOOC/2017/Chercher une image sur Commons' ) + '?tour=wikimooc51b&step=fin';
	} );
	
	// 12
	tour.step( {
		name: 'fin',
		title: 'Fin du tutoriel',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/B/12' ),
		overlay: true,
		closeOnClickOutside: false,
		buttons: [ {
			action: 'okay',
			onclick: function() {
				gt.endTour();
			},
		} ],
		allowAutomaticOkay: false,
	} );


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