User:Romaine/vector.js

From Meta, a Wikimedia project coordination wiki

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.
mw.loader.load('//nl.wikipedia.org/w/index.php?title=User:Romaine/insertvector.js&action=raw&ctype=text/javascript');

$(function() {
// Add link to navigation page in right top corner
 mw.util.addPortletLink('p-personal', '//meta.wikimedia.org/wiki/User:Romaine/Navigation', 'navi', 'pt-navi', 'persoonlijke navigatie'); 
});

var customizeToolbar = function () {
	$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
		'sections': {
			'extrabarforme': {
				'type': 'toolbar', // Can also be 'booklet'
				'label': 'Extra'
				// or 'labelMsg': 'section-emoticons-label' for a localized label
			}
		}
	} );

	$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	'section': 'extrabarforme',
	'groups': {
		'rorow1': {
			'label': '' // or use labelMsg for a localized label, see above
		}
	}
} );

	$('#wpTextbox1').wikiEditor('addToToolbar', {
		section: 'main',
		group: 'insert',
		tools: {
			"Ro-welcome": {
				label: 'Welcome user',
				type: 'button',
				icon: '//upload.wikimedia.org/wikipedia/commons/f/f2/Button_prononciation.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '\{\{subst:Welcome\}\}\n\nWelcome! ~~\~~',
						peri: '',
						post: ''
					}
				}
			},
			"Ro-metadone": {
				label: 'Done',
				type: 'button',
				icon: '//upload.wikimedia.org/wikipedia/commons/e/e9/Button_done.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '\[\[File:Crystal Clear action apply.png\|17px\|Done\]\] \'\'\'',
						peri: 'Done',
						post: '\'\'\''
					}
				}
			}
		}
	});
	$('#wpTextbox1').wikiEditor('addToToolbar', {
		section: 'extrabarforme',
		group: 'rorow1',
		tools: {
			"Ro-internelink": {
				label: 'Interne link',
				type: 'button',
				icon: '//upload.wikimedia.org/wikipedia/commons/4/45/BoutonsDefaut03.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '\[\[',
						peri: '',
						post: '\]\]'
					}
				}
			},
			"coords-pluslandmark2": {
				label: '+|type:landmark',
				type: 'button',
				icon: '//upload.wikimedia.org/wikipedia/commons/b/bc/Button_guillemet.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '\|type:',
						peri: 'landmark',
						post: ''
					}
				}
			}
		}
	});
};

/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -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 );
		}
	} );
}