MediaWiki:Guidedtour-tour-wikiedbebold.js
Appearance
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// Guided Tour for learning wikicode by making a series of edits in a user sandbox, as an interactive interlude in https://dashboard.wikiedu.org/training/students/editing-basics
( function ( gt ) {
//automatic api:edit function to send yourself messages
mw.loader.using( 'mediawiki.Title', function() {
function sendMessage( targetPage, msgPage, linkTo ) {
var api = new mw.Api();
api.get( {
'action' : 'query',
'titles' : msgPage,
'prop' : 'revisions|info',
'meta' : 'tokens',
'rvprop' : 'content',
'rvslots' : 'main',
'indexpageids' : 1
} ).done( function (result) {
result = result.query;
var page = result.pages[result.pageids[0]];
var text = page.revisions[0].slots.main['*'];
api.post( {
'action' : 'edit',
'title' : targetPage,
'appendtext' : "\n" + text,
'summary' : 'automatic post as part of sandbox guided tour',
'token' : result.tokens.csrftoken
} ).done( function () {
window.location.href = linkTo;
} );
} );
}
var tour;
tour = new gt.TourBuilder( {
name: 'wikiedbebold'
} );
tour.firstStep( {
name: 'welcome',
title: 'Welcome to your sandbox!',
description: 'Project:Wiki_Ed/tour/be_bold1',
onShow: gt.getPageAsDescription,
buttons: [ {
name: '<small>←</small>',
action: 'externalLink',
url: 'https://dashboard.wikiedu.org/training/students/editing-basics/be-bold-tutorial'
}, {
name: 'Okay!',
onclick: function() { if(!mw.config.get('wgUserName')){ alert( "Please login." ); return; }
sendMessage( 'User:' + mw.config.get( 'wgUserName' ) + '/be_bold',
'Project:Training/tour/be_bold_preload',
mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=wikiedbebold&step=editButton&vehidebetadialog=1');
}
} ],
overlay: true,
closeOnClickOutside: false,
allowAutomaticOkay: false,
allowAutomaticNext: false
} )
.next( 'editButton' );
tour.step( {
name: 'editButton',
title: 'Edit button',
description: 'Project:Wiki_Ed/tour/be_bold2',
attachTo: '#ca-edit',
position: 'bottom',
onShow: gt.getPageAsDescription,
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
allowAutomaticNext: false,
} )
.listenForMwHooks( 've.activationComplete' )
.transition( function () { if ( gt.isEditing() ) { return 'anyEdit'; } } )
.next( 'anyEdit' );
tour.step( {
name: 'anyEdit',
title: 'Make an edit!',
description: 'Project:Wiki_Ed/tour/be_bold2-1',
onShow: gt.getPageAsDescription,
attachTo: '.ve-ui-toolbar-saveButton',
position: 'bottomLeft',
buttons: [ {
name: 'Onward!',
onclick: function() { mw.libs.guiders.hideAll(); }
} ],
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
allowAutomaticNext: false
} )
.listenForMwHooks( 've.toolbarSaveButton.stateChanged' )
.transition( function () { if ( gt.isEditing() ) { return 'saveAnyEdit'; } } )
.next( 'saveAnyEdit' );
tour.step( {
name: 'saveAnyEdit',
title: 'Explore a bit, make a change, then save the page.',
description: 'Project:Wiki_Ed/tour/be_bold2-2',
onShow: gt.getPageAsDescription,
attachTo: '.ve-ui-toolbar-saveButton',
position: 'bottomLeft',
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
allowAutomaticNext: false
} )
.listenForMwHooks( 've.deactivationComplete' )
.transition( function () { if ( gt.isPostEdit() ) { return 'afterFirstEdit'; } } )
.next( 'afterFirstEdit' );
tour.step( {
name: 'afterFirstEdit',
title: 'How was that?',
description: 'Project:Wiki_Ed/tour/be_bold2-3',
onShow: gt.getPageAsDescription,
buttons: [ {
name: 'Try again.',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=wikiedbebold&step=editButton&vehidebetadialog=1'
}, {
name: 'Move on.',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=wikiedbebold&step=editBoldness&vehidebetadialog=1'
} ],
overlay: true,
closeOnClickOutside: false,
allowAutomaticOkay: false,
allowAutomaticNext: false
} )
.next( 'editBoldness' );
tour.step( {
name: 'editBoldness',
title: 'Now try another edit.',
description: 'Project:Wiki_Ed/tour/be_bold2-4',
attachTo: '#ca-edit',
position: 'bottom',
onShow: gt.getPageAsDescription,
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
allowAutomaticNext: false,
} )
.listenForMwHooks( 've.activationComplete' )
.transition( function () { if ( gt.isEditing() ) { return 'boldness'; } } )
.next( 'boldness' );
tour.step( {
name: 'boldness',
title: 'Boldness',
description: 'Project:Wiki_Ed/tour/be_bold3',
onShow: gt.getPageAsDescription,
attachTo: '#content',
position: 'bottomLeft',
buttons: [ {
name: 'I bolded the text.',
onclick: function() { mw.libs.guiders.next(); }
} ],
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
allowAutomaticNext: false
} )
.listenForMwHooks( 've.deactivationComplete' )
.transition( function () { if ( gt.isPostEdit() ) { return 'looksGood'; } } )
.back( 'editBoldness' )
.next( 'editSummary' );
tour.step( {
name: 'editSummary',
title: 'Edit summary, and Publish',
onShow: gt.getPageAsDescription,
description: 'Project:Wiki_Ed/tour/be_bold4',
attachTo: '.ve-ui-toolbar-saveButton',
position: 'bottomLeft',
autoFocus: 'yes',
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
allowAutomaticNext: false
} )
.listenForMwHooks( 've.deactivationComplete' )
.transition( function () { if ( gt.isPostEdit() ) { return 'looksGood'; } } )
.next( 'looksGood' );
tour.step( {
name: 'looksGood',
title: 'How was that?',
description: 'Project:Wiki_Ed/tour/be_bold5',
onShow: gt.getPageAsDescription,
buttons: [ {
name: 'Try again.',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=wikiedbebold&step=editButton&vehidebetadialog=1'
}, {
name: 'Move on.',
onclick: function() { mw.libs.guiders.next(); }
} ],
overlay: true,
closeOnClickOutside: false,
allowAutomaticOkay: false,
allowAutomaticNext: false
} )
.next( 'editButtonCitation' );
tour.step( {
name: 'editButtonCitation',
title: 'Now let\'s add a citation!',
description: 'Project:Wiki_Ed/tour/be_bold6',
attachTo: '#ca-edit',
position: 'bottom',
onShow: gt.getPageAsDescription,
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
allowAutomaticNext: false,
} )
.listenForMwHooks( 've.activationComplete' )
.transition( function () { if ( gt.isEditing() ) { return 'positionCursor'; } } )
.next( 'positionCursor' );
tour.step( {
name: 'positionCursor',
title: 'First, click the end of the sentence',
description: 'Project:Wiki_Ed/tour/be_bold7',
onShow: gt.getPageAsDescription,
attachTo: '#content',
position: 'bottomLeft',
buttons: [ {
name: 'I positioned the cursor.',
onclick: function() { mw.libs.guiders.next(); }
} ],
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
allowAutomaticNext: false
} )
.next( 'citeButton' );
tour.step( {
name: 'citeButton',
title: 'Now click the "Cite" button',
description: '',
attachTo: '.oo-ui-tool-name-citoid',
position: 'right',
buttons: [ {
name: 'I clicked Cite.',
onclick: function() { mw.libs.guiders.next(); }
} ],
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
allowAutomaticNext: false
} )
.next( 'insertCitation' );
tour.step( {
name: 'insertCitation',
title: 'Insert a citation',
description: 'Project:Wiki_Ed/tour/be_bold8',
onShow: gt.getPageAsDescription,
attachTo: '.oo-ui-tool-name-citoid',
position: 'right',
buttons: [ {
name: 'I inserted the citation.',
onclick: function() { mw.libs.guiders.next(); }
} ],
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
allowAutomaticNext: false
} )
.next( 'saveCitation' );
tour.step( {
name: 'saveCitation',
title: 'Publish changes again.',
onShow: gt.getPageAsDescription,
description: 'Project:Wiki_Ed/tour/be_bold9',
attachTo: '.ve-ui-toolbar-saveButton',
position: 'bottomLeft',
autoFocus: 'yes',
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
allowAutomaticNext: false
} )
.listenForMwHooks( 've.deactivationComplete' )
.transition( function () { if ( gt.isPostEdit() ) { return 'returnToTraining'; } } )
.next( 'returnToTraining' );
tour.step( {
name: 'returnToTraining',
title: 'That\'s it!',
description: 'Project:Wiki_Ed/tour/be_bold10',
onShow: gt.getPageAsDescription,
buttons: [ {
name: 'Try it again.',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=wikiedbebold&step=editButton&vehidebetadialog=1'
}, {
name: 'Return to training.',
action: 'externalLink',
url: 'https://dashboard.wikiedu.org/training/students/editing-basics/be-bold-tutorial'
} ],
overlay: true,
closeOnClickOutside: false,
allowAutomaticOkay: false,
allowAutomaticNext: false
} );
} );
} ( mediaWiki.guidedTour ) );