MediaWiki:Common.js

From Fintech Lab Wiki
Revision as of 09:45, 20 May 2022 by Superuser (talk | contribs) (Created page with "→‎Any JavaScript here will be loaded for all users on every page load.: // WikiEditor Toolbar customization. // refs https://www.mediawiki.org/wiki/Extension:WikiEditor/To...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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. */

// WikiEditor Toolbar customization.
// refs https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization#Basic_setup
// 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.
        $textarea.wikiEditor( 'addToToolbar', {
            section: 'advanced',
            group: 'format',
            tools: {
                math: {
                    label: 'Math',
                    type: 'button',
                    oouiIcon: 'mathematics',
                    action: {
                        type: 'encapsulate',
                        options: {
                            pre: '<math>',
                            post: '</math>'
                        }
                    }
                }
            }
        } );
        
        $textarea.wikiEditor( 'addToToolbar', {
            section: 'advanced',
            group: 'format',
            tools: {
                "strikethrough": {
                    label: 'Strike',
                    type: 'button',
                    oouiIcon: 'strikethrough',
                    action: {
                        type: 'encapsulate',
                        options: {
                            pre: "<s>",
                            post: "</s>"
                        }
                    }
                }
            }
        } );
	} );
}