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

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

	tour = new gt.TourBuilder( {
		name: 'wikimooc51d',
		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 #16',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/D/1' ),
		overlay: true,
		closeOnClickOutside: false,
	} )
	.next( function() {
		window.location.href = mw.util.getUrl( ':c:Accueil' ) + '?tour=wikimooc51d&step=lienimporter';
	} )
	.transition( function() {
		// Si l'apprenant n'est pas connecté
		if ( mw.user.getId() === 0 )
			return 'connectetoi';
	} );
	
	// 2
	tour.step( {
		name: 'lienimporter',
		title: 'Lien importer',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/D/2' ),
		overlay: false,
		attachTo: '#n-uploadbtn',
		position: 'right',
		closeOnClickOutside: false,
	} )
	.back( function() {
		window.location.href = mw.util.getUrl( ':fr:Wikipédia:WikiMOOC/2017/Importer une image sur Commons' ) + '?tour=wikimooc51d&step=bienvenue';
	} )
	.transition(function() {
		// Si l'apprenant n'est pas connecté
		if ( mw.user.getId() === 0 ) {
			return 'connectetoi';
		}
		if ( mw.config.get( 'wgPageName' ) === 'Special:UploadWizard' ) {
			return 'topoownwork';
		}
	} );
	
	// 3
	tour.step( {
		name: 'topoownwork',
		title: 'Quelles images sont importables sur Wikimedia Commons ?',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/D/3' ),
		overlay: false,
		attachTo: '',
		position: '',
		closeOnClickOutside: false,
	} )
	.next( function() {
		if ( $( '#mwe-upwiz-tutorial-html' ).is( ':visible' ) ) {
			return 'next';
		}
		else {
			return 'selectionnerphotos';
		}
	} )
	.back( function() {
		gt.setTourCookie( 'wikimooc51d', 'lien importer' );
		window.location.href = mw.util.getUrl( 'Accueil' );
	} );
	
	// 4
	tour.step( {
		name: 'next',
		title: 'Passons à la seconde étape',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/D/4' ),
		overlay: false,
		attachTo: '.mwe-upwiz-button-next',
		position: 'right',
		closeOnClickOutside: false,
		onShow: function() {
			$( '.mwe-upwiz-button-next a' ).click( function() {
				gt.setTourCookie( 'wikimooc51d', 'selectionnerphotos' );
			 	gt.launchTourFromUserState();
			} );
		},
	} )
	.back( 'topoownwork' );
	
	// 5
	tour.step( {
		name: 'selectionnerphotos',
		title: 'Sélection des fichiers',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/D/5' ),
		overlay: false,
		attachTo: '#mwe-upwiz-add-file',
		position: 'right',
		closeOnClickOutside: false,
		onShow: function() {
			var fireTransition = true;
			$.ajaxSetup( {
				complete: function() {
					if ( $( '.mwe-upwiz-file-next-all-ok' ).is( ':visible' ) && fireTransition ) {
						fireTransition = false;
						gt.setTourCookie( 'wikimooc51d', 'continue' );
					 	gt.launchTourFromUserState();
					}
				}
			} );
		},
	} );
	
	
	
	// 6
	tour.step( {
		name: 'continue',
		title: 'Passons à la troisième étape',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/D/6' ),
		overlay: false,
		attachTo: '.mwe-upwiz-file-next-all-ok',
		position: 'right',
		closeOnClickOutside: false,
		onShow: function() {
			$( '.mwe-upwiz-file-next-all-ok a' ).click( function() {
				gt.setTourCookie( 'wikimooc51d', 'topolicences' );
			 	gt.launchTourFromUserState();
			} );
		},
	} );
	
	// 7
	tour.step( {
		name: 'topolicences',
		title: 'Quelques explications concernant les licences',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/D/7' ),
		overlay: true,
		attachTo: '',
		position: '',
		closeOnClickOutside: false,
	} )
	.next( 'radio' );
	
	// 8
	tour.step( {
		name: 'radio',
		title: '',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/D/8' ),
		overlay: false,
		attachTo: '#mwe-upwiz-deeds',
		position: 'rightTop',
		closeOnClickOutside: false,
		onShow: function() {
			$( '#mwe-upwiz-deeds input' ).click( function() {
				gt.setTourCookie( 'wikimooc51d', 'autreslicences' );
			 	gt.launchTourFromUserState();
			} );
		},
	} )
	.back( 'topolicences' );
	
	// 9
	tour.step( {
		name: 'autreslicences',
		title: 'Choix de la licence',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/D/9' ),
		overlay: false,
		attachTo: '.mwe-more-options',
		position: 'right',
		closeOnClickOutside: false,
	} )
	.next( 'next3' );
	
	// 10
	tour.step( {
		name: 'next3',
		title: 'Passons à la quatrième étape',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/D/10' ),
		overlay: false,
		attachTo: '.mwe-upwiz-button-next',
		position: 'right',
		closeOnClickOutside: false,
		onShow: function() {
			$( '.mwe-upwiz-button-next a' ).click( function() {
				gt.setTourCookie( 'wikimooc51d', 'titre' );
			 	gt.launchTourFromUserState();
			} );
		},
	} )
	.back( 'autreslicences' );
	
	// 11
	tour.step( {
		name: 'titre',
		title: 'Nom de l\'image',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/D/11' ),
		overlay: false,
		attachTo: '#mwe-upwiz-detailsform0 .mwe-upwiz-titleDetailsWidget-title',
		position: 'right',
		closeOnClickOutside: false,
	} )
	.next( 'description' );
	
	// 12
	tour.step( {
		name: 'description',
		title: 'Description de l\'image',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/D/12' ),
		overlay: false,
		attachTo: '#mwe-upwiz-detailsform0 .mwe-upwiz-desc-lang-text',
		position: 'right',
		closeOnClickOutside: false,
	} )
	.next( 'categories' )
	.back( 'titre' );
	
	// 13
	tour.step( {
		name: 'categories',
		title: 'Et des catégories',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/D/13' ),
		overlay: false,
		attachTo: '#mwe-upwiz-detailsform0 .mwe-upwiz-categoriesDetailsWidget',
		position: 'right',
		closeOnClickOutside: false,
	} )
	.next( 'next4' )
	.back( 'description' );
	
	// 14
	tour.step( {
		name: 'next4',
		title: 'Et enfin, la dernière étape',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/D/14' ),
		overlay: false,
		attachTo: '.mwe-upwiz-file-next-all-ok',
		position: 'right',
		closeOnClickOutside: false,
		onShow: function() {
			$( '.mwe-upwiz-file-next-all-ok a' ).click( function() {
				waitForStep15();
			} );
		},
	} )
	.back( 'categories' );
	
	
	// Temporisation en attendant l'affichage du message de remerciement de l'étape 15
	function waitForStep15() {
		if ( $( '#mwe-upwiz-stepdiv-thanks' ).is( ':visible' ) ) {
			gt.setTourCookie( 'wikimooc51d', 'dispo' );
		 	gt.launchTourFromUserState();
		}
		else {
			window.setTimeout(waitForStep15, 250);
		}
	}
	// 15
	tour.step( {
		name: 'dispo',
		title: 'Félicitations !',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/D/15' ),
		overlay: true,
		attachTo: '',
		position: '',
		closeOnClickOutside: false,
	} )
	.next( 'listeimports' );
	
	// 16
	tour.step( {
		name: 'listeimports',
		title: 'Retrouvez vos fichiers',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/D/16' ),
		overlay: false,
		attachTo: '#pt-uploads',
		position: 'bottomLeft',
		closeOnClickOutside: false,
		buttons: [ {
			action: 'okay',
			onclick: function() {
				gt.endTour();
				setTimeout(function() {
					window.location.href = mw.util.getUrl( ':fr:Wikipédia:WikiMOOC/2017/Insérer une image sur Wikipédia' );
				}, 1750 );
			},
		} ],
		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 'lienimporter';
			}
			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>