Difference between revisions of "MediaWiki:Common.js"

From Mechanics
Line 14: Line 14:
label: 'Math',
label: 'Math',
type: 'button',
type: 'button',
icon: '//latex.codecogs.com/png.image?\dpi{110}&space;\sqrt{x}&space;',
icon: '//latex.codecogs.com/png.image?%5Cdpi%7B200%7D%20%5Csqrt%7Bx%7D%20',
//icon: '//upload.wikimedia.org/wikipedia/commons/2/2e/Button_math.png',
//icon: '//upload.wikimedia.org/wikipedia/commons/2/2e/Button_math.png',
action: {
action: {

Revision as of 13:40, 16 February 2022

/* Any JavaScript here will be loaded for all users on every page load. */

// 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 ) {
		
		// Add Math button
		$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
			section: 'advanced',
			group: 'format',
			tools: {
				"math": {
					label: 'Math',
					type: 'button',
					icon: '//latex.codecogs.com/png.image?%5Cdpi%7B200%7D%20%5Csqrt%7Bx%7D%20',
					//icon: '//upload.wikimedia.org/wikipedia/commons/2/2e/Button_math.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "<math>",
							post: "</math>"
						}
					}
				}
			}
		} );
	} );
}