Jump to content

User:Edgars2007/OOjs-UI example.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
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>' )
		  
		  
		} );
	} );
} );