Skip to content

Github mirror of MediaWiki extension BlueSpiceContextMenu - our actual code is hosted with Gerrit (please see https://www.mediawiki.org/wiki/Developer_access for contributing)

License

Notifications You must be signed in to change notification settings

wikimedia/mediawiki-extensions-BlueSpiceContextMenu

Repository files navigation

BlueSpiceContextMenu

Adding items to the context menu

Server-side

Register a new item in extension attribute BlueSpiceContextMenuItemFactories or using the BsContextMenuGetItems hook. Resulting objects must implement the BlueSpice\ContextMenu\IMenuItem interface.

Client-side

Use the event on document

$( document ).on( 'BSContextMenuGetItems', function( e, $element, items, forTitle ) {
	var title = new mw.Title( forTitle );
	items.push( {
		id: 'my-item',
		href: title.getUrl( { action: 'fancy-action' } ),
		label: 'MyItem',
		icon: 'oojs-icon',
		primary: false, // if true, will be put to the top of the menu
		overrides: 'some-item', //ID of the item this item should replace
		flags: [ 'progressive' ], // OOJS flags
        callback: function(  ) {
            // do something when button is clicked, do not combine with `href`
            // Called in the context of the context menu
        }
	} );
} );

About

Github mirror of MediaWiki extension BlueSpiceContextMenu - our actual code is hosted with Gerrit (please see https://www.mediawiki.org/wiki/Developer_access for contributing)

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published