MediaWiki:Guidedtour-tour-attestation.js

Définition, traduction, prononciation, anagramme et synonyme sur le dictionnaire libre Wiktionnaire.

Remarque: après avoir sauvegardé, vous devez vider le cache de votre navigateur pour que les changements prennent effet. Mozilla, cliquez sur Actualiser (ou ctrl-r). Internet Explorer / Opera: ctrl-f5. Safari: cmd-r. Konqueror ctrl-r.

/*
* Tutoriel interactif : Les attestations
* Plan et textes sur [[Projet:Tutoriels#Ajouter une attestation d’usage]]
*
* Voir [[:mw:Extension:GuidedTour]] pour plus d'informations
*
* Auteur : [[User:Lepticed7]]
* [[Catégorie:Guided tour]]
*/

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

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

  // 1
  tour.firstStep( {
    name: 'bienvenue',
    title: 'Attestations ?',
    description: new mw.Title( 'Tutoriel:Attestation/1' ),
    overlay: true,
    closeOnClickOutside: false,
  } )
  .next( function() {
    window.location.href = mw.util.getUrl( 'tamanoir' );
  } )
  .transition( function() {
    if ( mw.config.get( 'wgPageName' ) == 'tamanoir' )
      return 'emplacement';
  } );
  
  // 2
  tour.step( {
    name: 'emplacement',
    title: 'Emplacement de l’attestation',
    description: new mw.Title( 'Tutoriel:Attestation/2' ),
    attachTo: '.mw-parser-output ol li:nth-child(1) a',
    position: 'top',
    autoFocus: true,
    closeOnClickOutside: false,
  } )
  .back( function() {
    gt.setTourCookie( 'attestation', 'bienvenue' );
    window.location.href = mw.util.getUrl( 'Tutoriel:Attestation' );
  } )
  .next( 'wikisource' );
  
  // 3
  tour.step( {
    name: 'wikisource',
    title: 'À la recherche d’une attestation : Wikisource',
    description: new mw.Title( 'Tutoriel:Attestation/3' ),
    attachTo: '.mw-parser-output ol li:nth-child(1) ul li:nth-child(1)',
    position: 'bottomLeft',
    buttons: [ {
      action: 'externalLink',
      url: 'https://fr.wikisource.org/wiki/Wikisource:Accueil',
      name: 'Accéder à Wikisource' 
    } ],
    autoFocus: true,
    closeOnClickOutside: false,
  } )
  .back( 'emplacement' )
  .next( 'googlebooks' );
  
  // 4
  tour.step( {
    name: 'googlebooks',
    title: 'À la recherche d’une attestation : Google Livres',
    description: new mw.Title( 'Tutoriel:Attestation/4' ),
    attachTo: '.mw-parser-output ol li:nth-child(1) ul li:nth-child(2)',
    position: 'bottomLeft',
    autoFocus: true,
    closeOnClickOutside: false,
  } )
  .back( 'wikisource' )
  .next( 'actualites' );
  
  // 5
  tour.step( {
    name: 'actualites',
    title: 'À la recherche d’une attestation : Actualités',
    description: new mw.Title( 'Tutoriel:Attestation/5' ),
    attachTo: '.mw-parser-output ol li:nth-child(1) ul li:nth-child(3)',
    position: 'bottomLeft',
    autoFocus: true,
    closeOnClickOutside: false,
  } )
  .back( 'googlebooks' )
  .next( 'exemple' );
  
  // 6
  tour.step( {
    name: 'exemple',
    title: 'Un bon exemple',
    description: new mw.Title( 'Tutoriel:Attestation/6' ),
    attachTo: '.mw-parser-output ol li:nth-child(1) ul li:nth-child(1)',
    position: 'top',
    autoFocus: true,
    closeOnClickOutside: false,
  } )
  .back( 'actualites' )
  .next( 'neutralite' );
  
  // 7
  tour.step( {
    name: 'neutralite',
    title: 'Neutralité',
    description: new mw.Title( 'Tutoriel:Attestation/7' ),
    attachTo: '.mw-parser-output ol li:nth-child(1) a',
    position: 'top',
    autoFocus: true,
    closeOnClickOutside: false,
  } )
  .back( 'exemple' )
  .next( 'nombre' );
  
  // 8
  tour.step( {
    name: 'nombre',
    title: 'Nombre d’attestations',
    description: new mw.Title( 'Tutoriel:Attestation/8' ),
    attachTo: '.mw-parser-output ol li:nth-child(1) a',
    position: 'top',
    autoFocus: true,
    closeOnClickOutside: false,
  } )
  .back( 'neutralite' )
  .next( 'plus_loin' );
  
  // 9
  tour.step( {
    name: 'plus_loin',
    title: 'Aller plus loin',
    description: new mw.Title( 'Tutoriel:Attestation/9' ),
    attachTo: '#searchInput',
    position: 'bottomRight',
    autoFocus: true,
    closeOnClickOutside: false,
  } )
  .back( 'nombre' )
  .next( function() {
    window.location.href = mw.util.getUrl( 'Tutoriel:Attestation' );
  } )
  .transition( function() {
    if ( mw.config.get( 'wgPageName' ) === 'Tutoriel:Attestation' )
      return 'fin';
  } );
  

  // 10  
  tour.step( {
    name: 'fin',
    title: 'Fin',
    description: new mw.Title( 'Tutoriel:Attestation/10' ),
    autoFocus: true,
    overlay: true,
    closeOnClickOutside: false,
    buttons: [ {
      action: 'end'
    } ],
    allowAutomaticOkay: false,
  } );

  window.tour = tour;
  
  //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',
      iconTitle: '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 ) );