MediaWiki:Guidedtour-tour-wikiedbebold.js

Z Wikipedie, otevřené encyklopedie

Poznámka: Po uložení musíte vyprázdnit mezipaměť vašeho prohlížeče, jinak změny neuvidíte.

// 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',
				'rvprop': 'content',
				'indexpageids': 1
			}).then(function(result) {
				result = result.query;
				var page = result.pages[result.pageids[0]];
				var text = page.revisions[0]['*'];
				return api.postWithEditToken({
					'action': 'edit',
					'title': targetPage,
					'appendtext': "\n" + text,
					'summary': 'automatický příspěvek jako součást interaktivního průvodce',
				});
			}).then(function() {
				window.location.href = linkTo;
			});
		}

		var tour;

		tour = new gt.TourBuilder({
			name: 'wikiedbebold'
		});

		tour.firstStep({
				name: 'welcome',
				title: 'Pojďte si vyzkoušet editování Wikipedie!',
				description: new mw.Title( 'Project:Průvodce/interaktivní1' ),
				buttons: [{
					name: '<small>zpátky</small>',
					action: 'wikiLink',
					page: ($.cookie("gtFrom") ? $.cookie("gtFrom") : mw.config.get('wgPageName'))
				}, {
					name: 'Přejít na pískoviště!',
					onclick: function() {
						if (!mw.config.get('wgUserName')) {
							alert("Prosím, přihlašte se.");
							return;
						}
						// set cookie with beginning and ending pages
						$.cookie("gtFrom", mw.config.get('wgPageName'), {
							expires: 1,
							path: '/'
						});
						$.cookie("gtTo", (mw.config.get('wgPageName') === 'Wikipedie:Průvodce/Pískoviště' ? 'Wikipedie:Průvodce/Vytvoření_nového_článku' : 'Nápověda:Úvod'), {
							expires: 1,
							path: '/'
						});
						sendMessage('User:' + mw.config.get('wgUserName') + '/Pískoviště',
							'Project:Průvodce/interaktivní_preload',
							mw.util.getUrl('Special:MyPage/Pískoviště') + '?tour=wikiedbebold&step=sandbox&vehidebetadialog=1');
					}
				}],
				overlay: true,
				closeOnClickOutside: false,
				allowAutomaticOkay: false,
				allowAutomaticNext: false
			})
			.next('sandbox');

		tour.step({
				name: 'sandbox',
				title: 'Vítejte na svém pískovišti!',
				description: new mw.Title( 'Project:Průvodce/interaktivní1-1' ),
				buttons: [{
					name: 'Jasně!',
					action: 'next',
					onclick: function() {
						mw.libs.guiders.next();
					}
				}],
				overlay: true,
				closeOnClickOutside: false,
				allowAutomaticOkay: false,
				allowAutomaticNext: false
			})
			.next('editButton');

		tour.step({
				name: 'editButton',
				title: 'Tlačítko Editovat',
				description: new mw.Title( 'Project:Průvodce/interaktivní2' ),
				attachTo: '#ca-ve-edit',
				position: 'bottom',
				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: 'Udělejte nějakou editaci!',
				description: new mw.Title( 'Project:Průvodce/interaktivní2-1' ),
				attachTo: '.ve-ui-toolbar-saveButton',
				position: 'bottomLeft',
				buttons: [{
					name: 'Dále!',
					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: 'Trochu to tu prozkoumejte, udělejte nějaké změny a uložte stránku.',
				description: new mw.Title( 'Project:Průvodce/interaktivní2-2' ),
				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: 'Jak to šlo?',
				description: new mw.Title( 'Project:Průvodce/interaktivní2-3' ),
				buttons: [{
					name: 'Zkusit znovu',
					action: 'externalLink',
					url: mw.util.getUrl('Special:MyPage/Pískoviště') + '?tour=wikiedbebold&step=editButton&vehidebetadialog=1'
				}, {
					name: 'Jít dál',
					action: 'externalLink',
					url: mw.util.getUrl('Special:MyPage/Pískoviště') + '?tour=wikiedbebold&step=editBoldness&vehidebetadialog=1',
					type: 'progressive'
				}],
				overlay: true,
				closeOnClickOutside: false,
				allowAutomaticOkay: false,
				allowAutomaticNext: false
			})
			.next('editBoldness');

		tour.step({
				name: 'editBoldness',
				title: 'Teď zkusme další editaci.',
				description: new mw.Title( 'Project:Průvodce/interaktivní2-4' ),
				attachTo: '#ca-ve-edit',
				position: 'bottom',
				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: 'Tučné písmo',
				description: new mw.Title( 'Project:Průvodce/interaktivní3' ),
				attachTo: '#content',
				position: 'bottomLeft',
				buttons: [{
					name: 'Přidal jsem tučné písmo',
					onclick: function() {
						mw.libs.guiders.next();
					}
				}],
				overlay: false,
				closeOnClickOutside: false,
				allowAutomaticOkay: false,
				allowAutomaticNext: false
			})
			.listenForMwHooks('ve.deactivationComplete')
			.transition(function() {
				if (gt.isPostEdit()) {
					return 'looksGood';
				}
			})
			.next('editSummary');

		tour.step({
				name: 'editSummary',
				title: 'Vyplňte shrnutí a uložte',
				description: new mw.Title( 'Project:Průvodce/interaktivní4' ),
				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: 'Jak šlo tohle?',
				description: new mw.Title( 'Project:Průvodce/interaktivní5' ),
				buttons: [{
					name: 'Zkusit znovu',
					action: 'externalLink',
					url: mw.util.getUrl('Special:MyPage/Pískoviště') + '?tour=wikiedbebold&step=editButton&vehidebetadialog=1'
				}, {
					name: 'Jít dál',
					onclick: function() {
						mw.libs.guiders.next();
					}
				}],
				overlay: true,
				closeOnClickOutside: false,
				allowAutomaticOkay: false,
				allowAutomaticNext: false
			})
			.next('editButtonCitation');

		tour.step({
				name: 'editButtonCitation',
				title: 'Teď přidejme citaci!',
				description: new mw.Title( 'Project:Průvodce/interaktivní6' ),
				attachTo: '#ca-ve-edit',
				position: 'bottom',
				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: 'Nejprve klikněte na konec věty',
				description: new mw.Title( 'Project:Průvodce/interaktivní7' ),
				attachTo: '#content',
				position: 'bottomLeft',
				buttons: [{
					name: 'Umístil jsem kurzor',
					onclick: function() {
						mw.libs.guiders.next();
					}
				}],
				overlay: false,
				closeOnClickOutside: false,
				allowAutomaticOkay: false,
				allowAutomaticNext: false
			})
			.next('citeButton');

		tour.step({
				name: 'citeButton',
				title: 'Teď klikněte na tlačítko „Citace“',
				description: '',
				attachTo: '.oo-ui-tool-name-citoid',
				position: 'right',
				buttons: [{
					name: 'Klikl jsem na citaci',
					onclick: function() {
						mw.libs.guiders.next();
					}
				}],
				overlay: false,
				closeOnClickOutside: false,
				allowAutomaticOkay: false,
				allowAutomaticNext: false
			})
			.next('insertCitation');

		tour.step({
				name: 'insertCitation',
				title: 'Vložte citaci',
				description: new mw.Title( 'Project:Průvodce/interaktivní8' ),
				attachTo: '.oo-ui-tool-name-citoid',
				position: 'right',
				buttons: [{
					name: 'Vložil jsem citaci',
					onclick: function() {
						mw.libs.guiders.next();
					}
				}],
				overlay: false,
				closeOnClickOutside: false,
				allowAutomaticOkay: false,
				allowAutomaticNext: false
			})
			.next('saveCitation');

		tour.step({
				name: 'saveCitation',
				title: 'Znovu uložte.',
				description: new mw.Title( 'Project:Průvodce/interaktivní9' ),
				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: 'A je to!',
				description: new mw.Title( 'Project:Průvodce/interaktivní10' ),
				buttons: [{
					name: 'Zkusit to znovu',
					action: 'externalLink',
					url: mw.util.getUrl('Special:MyPage/Pískoviště') + '?tour=wikiedbebold&step=editButton&vehidebetadialog=1'
				}, {
					name: 'Zpátky na původní stránku',
					action: 'wikiLink',
					page: ($.cookie("gtTo") ? $.cookie("gtTo") : 'Project:Průvodce/Vytvoření_nového_článku')
				}],
				overlay: true,
				closeOnClickOutside: false,
				allowAutomaticOkay: false,
				allowAutomaticNext: false,
			})
			.transition(function() {
				if (($.cookie("gtTo") ? $.cookie("gtTo") : 'Wikipedie:Průvodce/Vytvoření_nového_článku') === mw.config.get('wgPageName')) {
					$.removeCookie('gtFrom');
					$.removeCookie('gtTo');
					return gt.TransitionAction.END;
				}
			});

	});
}(mediaWiki.guidedTour));