MediaWiki:Common.js

From IFWiki

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.
/* Any JavaScript here will be loaded for all users on every page load. */

/* Dark mode exception */
$("#mw-navbar").addClass("mw-no-invert");

// See https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization
// Check if we're editing a page.
if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) {
	// Add a hook handler.
	mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) {
		// Configure a new toolbar entry on the given $textarea jQuery object.


		/* Remove button for <big> */
		$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
			'section': 'advanced',
			'group': 'size',
			'tool': 'big'
		});
		/* Remove button for <small> */

		$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
			'section': 'advanced',
			'group': 'size',
			'tool': 'small'
		});

		/* Remove <ref> button as we don't use the Cite extension */
		$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
			'section': 'main',
			'group': 'insert',
			'tool': 'reference'
		});

		/* Remove link button as we'll include it in the dropdown */
		$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
			'section': 'main',
			'group': 'insert',
			'tool': 'link'
		});

		/ * Add "Insert link" dropdown list */
		$textarea.wikiEditor( 'addToToolbar', {
			section: 'main',
			groups: {
				'insert': {
					tools: {
						'links': {
							label: 'Insert link',
							type: 'select',
							list: {
								'live-link': {
									label: 'Live link - using IFWiki\'s link template',
									action: {
										type: 'encapsulate',
										options: {
											pre: '{{link | url=',
											post: ' | archive= | text= }}'
										}
									}
								},
								'dead-link': {
									label: 'Dead link - using IFWiki\'s link template',
									action: {
										type: 'encapsulate',
										options: {
											pre: '{{link | deadurl=',
											post: ' | archive= | text= }}'
										}
									}
								},

								'standard-link': {
									label: 'Standard link - using wiki markup',
									labelMsg: 'wikieditor-toolbar-tool-link',
									action: {
										type: 'dialog',
										module: 'insert-link'
									}
								}



							}
						}
					}
				}
			}
		} );




	} );
}