MediaWiki:Guidedtour-tour-wbimages.js

From Wikidata
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/*
 * @see [[Wikidata:Tours/Images]]
 * 
 * @author NavinoEvans
 */
( function( $, mw, gt, wb ) {
 
	$.ajax( {
		async: false,
		url: mw.util.wikiScript() + '?title=MediaWiki:Guidedtour-lib.js&action=raw&ctype=text/javascript',
		dataType: 'script'
	} );

	var tourName = 'wbimages',
		tourEntityId = 'Q85409163', // 'Q211911'
		newData = {
			"labels": {
                "en": {
                    "language": "en",
                    "value": "National Museum of Anthropology"
                },
                 "es": {
                    "language": "es",
                    "value": "Museo Nacional de Antropología"
                },
			},
			"descriptions": {
                "en": {
                    "language": "en",
                    "value": "Test item for Images tour only"
                },
                 "es": {
                    "language": "es",
                    "value": "Test item for Images tour only"
                },
			},
			"claims": [{
				"mainsnak": {
					"snaktype": "value",
					"property": "P31", // "P39"
					"datavalue": {
						"value": {
							"entity-type": "item",
							"id": "Q24699794", // "Q497"
						},
						"type": "wikibase-entityid"
					},
					"datatype": "wikibase-item"
				},
				"type": "statement",
				"rank": "normal"
			}, {
				"mainsnak": {
					"snaktype": "value",
					"property": "P1705", // "P246"
					"datavalue": {
						"value": {
							"text": "Museo Nacional de Antropolog\u00eda",
							"language": "es"
						},
						"type": "monolingualtext"
					},
					"datatype": "monolingualtext"
				},
				"type": "statement",
				"rank": "normal"
			}, {
				"mainsnak": {
					"snaktype": "value",
					"property": "P131", // "P82"
					"datavalue": {
						"value": {
							"entity-type": "item",
							"id": "Q1489" // "Q497"
						},
						"type": "wikibase-entityid"
					},
					"datatype": "wikibase-item"
				},
				"type": "statement",
				"rank": "normal"
			}]};

	gt.init( tourName, tourEntityId, newData, {

		/**
		 * The page from where the tour texts should be loaded.
		 */
		pageName: 'Wikidata:Tours/Images',

		/**
		 * The steps of the tour.
		 */
		
		steps: [ {
			// 1. Welcome to the Add An Image Tour
		}, {
			// 2. Find an image for the item
		}, {
			// 3. Adding an image to Wikidata
			
		}, {
			// 4. Add a statement
			attachTo: '.wikibase-statementgrouplistview > .wikibase-addtoolbar-container .wikibase-toolbar-button-add',
			actionBtn2: '.wikibase-statementgrouplistview > .wikibase-addtoolbar-container .wikibase-toolbar-button-add a',
		}, {
			// 5. Add the Image property
			position: 'top',
			attachTo: '.wb-edit',
		}, {
			// 6. Add the filename of the image
			position: 'top',
			attachTo: '.wb-new .valueview-value'
		}, {
			// 7. Publish
			position: 'top',
			attachTo: '.wb-new .wikibase-toolbar-button-save',
			actionBtn2: '.wb-new .wikibase-toolbar-button-save a',			
		}, {
			// 8. Other kinds of image
		
		}, {
			// Congratulations!
			onShow: function() {
				// Quick hack to redirect to Tours page.
				// Todo: should be the default action for clicking the "end tour" button on any Wikidata 
				$('.guidedtour-end-button').off('click').on('click', function() {
					window.location = window.location.origin + '/wiki/Wikidata:tours';
				})
			}
		} ]
	} );

} )( jQuery, mediaWiki, mediaWiki.guidedTour, wikibase );