Wikipedista:YjM/common.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.

mw.loader.load("//www.wikidata.org/w/index.php?title=User:Yair_rand/HighlightUncreated.js&action=raw&ctype=text/javascript");

mw.loader.load("//meta.wikimedia.org/w/index.php?title=User:Jon_Harald_Søby/diffedit.js&action=raw&ctype=text/javascript");

// Custom toolbar buttons via https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization
var tools = {
	'rozdelovnik': {
		label: 'Rozdělovník', // or use labelMsg for a localized label, see above
		type: 'button',
		icon: '//upload.wikimedia.org/wikipedia/commons/4/49/Toolbaricon_en_dash.png',
		action: {
			type: 'encapsulate',
			options: {
				pre: '–' // text to be inserted
			}
		}
	},
	'tvrdamez': {
		label: 'Tvrdá mezera',
		type: 'button',
    	icon: '//upload.wikimedia.org/wikipedia/commons/e/ed/Toolbaricon_nbsp.png',
    	action: {
			type: 'encapsulate',
			options: {
				pre: ' ' // text to be inserted
			}
		}
	},
	'zdroj': {
		label: 'Chybí zdroj',
		type: 'button',
    	icon: '//upload.wikimedia.org/wikipedia/commons/3/33/Button_unreferenced.png',
    	action: {
			type: 'encapsulate',
			options: {
				pre: '\x7b\x7bsubst:Fakt', // text to be inserted
				post: '\x7d\x7d'
			}
		}
	}
};

var customizeToolbar = function () {
	/* Your code goes here */
	$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	'section': 'main',
	'group': 'insert',
	'tools': tools
} );
};

/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) {
	mw.loader.using( 'user.options' ).then( function () {
		// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
		if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
			$.when(
				mw.loader.using( 'ext.wikiEditor' ), $.ready
			).then( customizeToolbar );
		}
	});
}