MediaWiki:Gadget-ToolbarFixes.js

/* * Gadget to make some default changes to the editbox toolbar * * For example, change the "small" button from " " to "..." */

/* eslint-disable one-var */

( function {

'use strict';

var updateSizeButtons = function ( $wikieditor, $textbox ) {

var $group = $wikieditor.find( '.group-size' );

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

$textbox.wikiEditor( 'addToToolbar', {			section: 'advanced',			group: 'size',			tools: {				big: {					label: mw.msg('wikieditor-toolbar-tool-big'),					type: 'button',					oouiIcon: 'bigger',					action: {						type: 'encapsulate',						options: {							pre: ,							periMsg: 'wikieditor-toolbar-tool-big-example',							post: 						}					}				},				small: {					label: mw.msg('wikieditor-toolbar-tool-small'),					type: 'button',					oouiIcon: 'smaller',					action: {						type: 'encapsulate',						options: {							pre: ,							periMsg: 'wikieditor-toolbar-tool-big-example',							post: 						}					}				}			}		} );

// put them back at the start $group.find( '.tool[rel="small"]' ).prependTo( $group ); $group.find( '.tool[rel="big"]' ).prependTo( $group ); };

/*	 * Add new character groups */	var addCharGroups = function ( $textbox ) {

$textbox.wikiEditor( 'addToToolbar', {			section: 'characters',			pages: {				oldEnglish: {					layout: 'characters',					label: 'Old/Middle English',					characters: [						'Æ', 'æ', 'Ð', 'ð', 'Ᵹ', 'ᵹ', 'Ȝ', 'ȝ', 'Ꝛ', 'ꝛ',						'Þ', 'þ', 'Ꝥ', 'ꝥ', 'Ƿ', 'ƿ',						'⹒', '⁊', // et						'Ǣ', 'ǣ', 'Ā', 'ā', 'Ċ', 'ċ', 'Ē', 'ē', 'Ḡ', 'ḡ', 'Ġ', 'ġ',						'Ī', 'ī', 'Ō', 'ō', 'Ū', 'ū', 'Ȳ', 'ȳ',						{							label: '·',							titleMsg: 'special-characters-title-interpunct',							action: {								type: 'replace',								options: {									peri: '·',									selectPeri: false								}							}						}					]				}			}		} ); };

/* 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			// (T54542)			if ( mw.user.options.get( 'usebetatoolbar' ) === 1 ) {				$.when( mw.loader.using( 'ext.wikiEditor' ), $.ready ).then( function {

// eslint-disable-next-line no-jquery/no-global-selector var $wikieditor = $( '.wikiEditor-ui' ), $wptb1 = $wikieditor.find( '#wpTextbox1' );

updateSizeButtons( $wikieditor, $wptb1 ); addCharGroups( $wptb1 ); } );			}		} );	}

} );