Benutzer:WikiSysop/common.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
K |
K |
||
Zeile 1: | Zeile 1: | ||
// Check if we're editing a page. | // Check if we're editing a page. | ||
− | if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) { | + | if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) { |
// Add a hook handler. | // Add a hook handler. | ||
mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) { | mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) { |
Version vom 17. Dezember 2024, 23:44 Uhr
// 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: 'secondary', group: 'default', tools: { dothing: { type: 'element', element: function ( context ) { // Note that the `context` object contains various useful references. console.log( context ); var button = new OO.ui.ButtonInputWidget( { label: 'Do a thing', icon: 'hieroglyph' } ); button.connect( null, { click: function ( e ) { // Do whatever is required when the button is clicked. console.log( e ); OO.ui.alert( 'A thing is done.' ); } } ); return button.$element; } } } } ); } ); }