MediaWiki:Guidedtour-tour-wikimooc32b.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 #12 du WikiMOOC
* Naviguer dans les catégories
*
* Voir [[:mw:Extension:GuidedTour]] pour plus d'informations
*
* Auteur : [[User:0x010C]]
* Création : 7 février 2017
* Dernière révision : 14 février 2017
* [[Catégorie:Guided tour]]
*/
//<nowiki>
( function ( window, document, $, mw, gt ) {
var tour;
tour = new gt.TourBuilder( {
name: 'wikimooc32b',
shouldLog: false
} );
// 1
tour.firstStep( {
name: 'bienvenue',
title: 'Tutoriel #12 (1/9)',
description: new mw.Title( 'Projet:WikiMOOC/2017/GT/3.2/B/1' ),
overlay: true,
closeOnClickOutside: false,
onShow: function() {
var api = new mw.Api();
api.postWithToken( 'csrf', {
action: 'edit',
title: 'Projet:MOOC/2017/Participation/3.2',
summary: 'Émargement automatique pour le second module de la semaine 3 du WikiMOOC',
tags: 'wikimooc2017',
appendtext: '\n{{u|' + mw.config.get( 'wgUserName' ) + '}}',
format: 'json',
} );
},
} )
.next( function () {
gt.setTourCookie( 'wikimooc32b', 'listecats' );
window.location.href = mw.util.getUrl( 'Douglas Adams' );
} )
.transition( function () {
// Si l'apprenant n'est pas connecté
if ( mw.user.getId() === 0 )
return 'connectetoi';
} );
// 2
tour.step( {
name: 'listecats',
title: 'Catégories de l\'article (2/9)',
description: new mw.Title( 'Projet:WikiMOOC/2017/GT/3.2/B/2' ),
overlay: false,
attachTo: '#catlinks',
position: 'top',
closeOnClickOutside: false,
} )
.back( function () {
gt.setTourCookie( 'wikimooc32b', 'bienvenue' );
window.location.href = mw.util.getUrl( 'Wikipédia:WikiMOOC/2017/Naviguer dans les catégories' );
} )
.next( 'gocat' )
.transition( function() {
if ( mw.config.get( 'wgPageName' ) !== 'Douglas_Adams' ) {
window.location.href = mw.util.getUrl( 'Douglas Adams' );
}
} );
// Hack pour positionner l'étape 3
if ( mw.config.get( 'wgPageName' ) === 'Douglas_Adams' ) {
$( '#mw-normal-catlinks a' ).each( function() {
if ( $( this ).attr( 'title' ) === 'Catégorie:Naissance en mars 1952' ) {
$( this ).attr( 'id', 'gt-wikimooc-32b-3' );
}
} );
}
// 3
tour.step( {
name: 'gocat',
title: 'Zoom sur une catégorie (3/9)',
description: new mw.Title( 'Projet:WikiMOOC/2017/GT/3.2/B/3' ),
overlay: false,
attachTo: '#gt-wikimooc-32b-3',
position: 'top',
closeOnClickOutside: false,
} )
.back( 'listecats' )
.transition( function() {
if ( mw.config.get( 'wgPageName' ) === 'Catégorie:Naissance_en_mars_1952' ) {
return 'interrieur';
}
else if ( mw.config.get( 'wgPageName' ) !== 'Douglas_Adams' ) {
window.location.href = mw.util.getUrl( 'Douglas Adams' );
}
} );
// 4
tour.step( {
name: 'interrieur',
title: 'Page d\'une catégorie (4/9)',
description: new mw.Title( 'Projet:WikiMOOC/2017/GT/3.2/B/4' ),
overlay: true,
attachTo: '',
position: '',
closeOnClickOutside: false,
} )
.back( function () {
gt.setTourCookie( 'wikimooc32b', 'gocat' );
window.location.href = mw.util.getUrl( 'Douglas Adams' );
} )
.next( 'retour' )
.transition( function() {
if ( mw.config.get( 'wgPageName' ) !== 'Catégorie:Naissance_en_mars_1952' ) {
window.location.href = mw.util.getUrl( 'Catégorie:Naissance en mars 1952' );
}
} );
// Hack pour positionner l'étape 5
if ( mw.config.get( 'wgPageName' ) === 'Catégorie:Naissance_en_mars_1952' ) {
$( '.mw-category-group:nth-of-type(1) a' ).each( function() {
if ( $( this ).attr( 'title' ) === 'Douglas Adams' ) {
$( this ).attr( 'id', 'gt-wikimooc-32b-5' );
}
} );
}
// 5
tour.step( {
name: 'retour',
title: 'Retour sur l\'article Douglas Adams (5/9)',
description: new mw.Title( 'Projet:WikiMOOC/2017/GT/3.2/B/5' ),
overlay: false,
attachTo: '#gt-wikimooc-32b-5',
position: 'right',
closeOnClickOutside: false,
} )
.back( 'interrieur' )
.transition( function() {
if ( mw.config.get( 'wgPageName' ) === 'Douglas_Adams' ) {
return 'gocatbis';
}
else if ( mw.config.get( 'wgPageName' ) !== 'Catégorie:Naissance_en_mars_1952' ) {
window.location.href = mw.util.getUrl( 'Catégorie:Naissance en mars 1952' );
}
} );
// Hack pour positionner l'étape 6
if ( mw.config.get( 'wgPageName' ) === 'Douglas_Adams' ) {
$( '#mw-normal-catlinks a' ).each( function() {
if ( $( this ).attr( 'title' ) === 'Catégorie:Écrivain britannique de science-fiction' ) {
$( this ).attr( 'id', 'gt-wikimooc-32b-6' );
}
} );
}
// 6
tour.step( {
name: 'gocatbis',
title: 'Autre exemple de catégorie (6/9)',
description: new mw.Title( 'Projet:WikiMOOC/2017/GT/3.2/B/6' ),
overlay: false,
attachTo: '#gt-wikimooc-32b-6',
position: 'top',
closeOnClickOutside: false,
} )
.back( function () {
gt.setTourCookie( 'wikimooc32b', 'retour' );
window.location.href = mw.util.getUrl( 'Catégorie:Naissance en mars 1952' );
} )
.transition( function() {
if ( mw.config.get( 'wgPageName' ) === 'Catégorie:Écrivain_britannique_de_science-fiction' ) {
return 'catincat';
}
else if ( mw.config.get( 'wgPageName' ) !== 'Douglas_Adams' ) {
window.location.href = mw.util.getUrl( 'Douglas Adams' );
}
} );
// 7
tour.step( {
name: 'catincat',
title: 'Des catégories imbriquées (7/9)',
description: new mw.Title( 'Projet:WikiMOOC/2017/GT/3.2/B/7' ),
overlay: false,
attachTo: '',
position: '',
closeOnClickOutside: false,
} )
.back( function () {
gt.setTourCookie( 'wikimooc32b', 'gocatbis' );
window.location.href = mw.util.getUrl( 'Douglas Adams' );
} )
.next( 'gocatter' )
.transition( function() {
if ( mw.config.get( 'wgPageName' ) !== 'Catégorie:Écrivain_britannique_de_science-fiction' ) {
window.location.href = mw.util.getUrl( 'Catégorie:Écrivain britannique de science-fiction' );
}
} );
// Hack pour positionner l'étape 8
if ( mw.config.get( 'wgPageName' ) === 'Catégorie:Écrivain_britannique_de_science-fiction' ) {
$( '#mw-normal-catlinks a' ).each( function() {
if ( $( this ).attr( 'title' ) === 'Catégorie:Écrivain de science-fiction par nationalité' ) {
$( this ).attr( 'id', 'gt-wikimooc-32b-8' );
}
} );
}
// 8
tour.step( {
name: 'gocatter',
title: 'Exemple de catégorie mère (8/9)',
description: new mw.Title( 'Projet:WikiMOOC/2017/GT/3.2/B/8' ),
overlay: false,
attachTo: '#gt-wikimooc-32b-8',
position: 'top',
closeOnClickOutside: false,
} )
.back( 'catincat' )
.transition( function() {
if ( mw.config.get( 'wgPageName' ) === 'Catégorie:Écrivain_de_science-fiction_par_nationalité' ) {
return 'fin';
}
else if ( mw.config.get( 'wgPageName' ) !== 'Catégorie:Écrivain_britannique_de_science-fiction' ) {
window.location.href = mw.util.getUrl( 'Catégorie:Écrivain britannique de science-fiction' );
}
} );
// 9
tour.step( {
name: 'fin',
title: 'Catégorie mère et sous-catégories (9/9)',
description: new mw.Title( 'Projet:WikiMOOC/2017/GT/3.2/B/9' ),
overlay: false,
attachTo: '',
position: '',
closeOnClickOutside: false,
buttons: [ {
action: 'okay',
onclick: function() {
gt.endTour();
setTimeout( function() {
window.location.href = mw.util.getUrl( 'Wikipédia:WikiMOOC/2017/Naviguer dans les catégories' );
}, 1600 );
},
} ],
allowAutomaticOkay: false,
} )
.back( function () {
gt.setTourCookie( 'wikimooc32b', 'gocatter' );
window.location.href = mw.util.getUrl( 'Catégorie:Écrivain britannique de science-fiction' );
} );
// 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>