mw.loader.using( [ 'mediawiki.util', 'oojs-ui' ], function () {
var messageDialog = new OO.ui.MessageDialog();
// Create and append a window manager.
var windowManager = new OO.ui.WindowManager();
$( 'body' ).append( windowManager.$element );
// Add the dialog to the window manager.
windowManager.addWindows( [ messageDialog ] );
// Add the portlet link to the toolbar.
var portletLink = mw.util.addPortletLink(
'p-tb',
'#',
'Click me!',
't-clickme', // the link ID
'Go on, you know you want to click me...', // tooltip text
null,
'#t-whatlinkshere' // put it before the what links here link
);
// Tell the portlet link what to do when we click it.
$( portletLink ).click( function ( event ) {
event.preventDefault();
// Configure the message dialog when it is opened with the window manager's openWindow() method.
windowManager.openWindow( messageDialog, {
title: 'Foo',
message: $('<a href="https://www.mediawiki.org/wiki/OOjs_UI/Windows/Message_Dialogs">Open</a>' )
} );
} );
} );