MediaWiki:Guidedtour-tour-tuto15.js

Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
( function ( window, document, $, mw, gt ) {
	var tour;

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

	// Switch the namespace depending on which wiki we are
	var namespace = 'Projet:';
	if( mw.config.get( 'wgDBname' ) === '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=tuto15&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=tuto15&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: 'Quels images sont importables sur Wikimedia Commons ?',
		description: new mw.Title( namespace + 'WikiMOOC/2017/GT/5.1/D/3' ),
		overlay: false,
		attachTo: '',
		position: '',
		closeOnClickOutside: false,
		onShow: function() {
		},
	} )
	.next( function() {
		if ( $('#mwe-upwiz-tutorial-html').is(':visible') ) {
			return 'next';
		}
		else {
			return 'selectionnerphotos';
		}
	} )
	.back( function() {
		gt.setTourCookie( 'tuto15', '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( 'tuto15', '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( 'tuto15', '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( 'tuto15', 'topolicences' );
			 	gt.launchTourFromUserState();
			} );
		},
	} );
	
	// 7
	tour.step( {
		name: 'topolicences',
		title: 'Quelsues 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( 'tuto15', '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( 'tuto15', '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( 'tuto15', '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:Aide:Wikipédia_pas_à_pas/Tutoriel_15' );
				}, 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( 'wgDBname' ) === 'commonswiki' ) {
				return 'lienimporter';
			}
			else {
				return 'bienvenue';
			}
		}
	} );

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