Benutzer:WikiSysop/common.js: Unterschied zwischen den Versionen

Aus Mediawiki Ferdinand Gruber
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 ) {
 
// Configure a new toolbar entry on the given $textarea jQuery object.
 
// Configure a new toolbar entry on the given $textarea jQuery object.
 
$textarea.wikiEditor( 'addToToolbar', {
 
$textarea.wikiEditor( 'addToToolbar', {
section: 'secondary',
+
group: 'default',
+
section: 'advanced',
 +
group: 'format',
 
tools: {
 
tools: {
dothing: {
+
math: {
type: 'element',
+
label: 'Math',
element: function ( context ) {
+
type: 'button',
// Note that the `context` object contains various useful references.
+
oouiIcon: 'mathematics',
console.log( context );
+
action: {
var button = new OO.ui.ButtonInputWidget( {
+
type: 'encapsulate',
label: 'Do a thing',
+
options: {
icon: 'hieroglyph'
+
pre: '<math>',
} );
+
post: '</math>'
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;
 
 
}
 
}
 
}
 
}
 
}
 
}
 +
 
} );
 
} );
 
} );
 
} );
 
}
 
}

Version vom 17. Dezember 2024, 23:56 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: 'advanced',
			group: 'format',
			tools: {
				math: {
					label: 'Math',
					type: 'button',
					oouiIcon: 'mathematics',
					action: {
						type: 'encapsulate',
						options: {
							pre: '<math>',
							post: '</math>'
						}
					}
				}
			}
			
		} );
	} );
}