MediaWiki:Gadget-mySandbox.js: Difference between revisions

From [N8]
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
/**
/**
  * Add a "My sandbox" link to the personal portlet menu.
  * Add a "My sandbox" link to the personal portlet menu.
* Dependencies: mediawiki.util, mediawiki.Title, mediawiki.Uri
  *
  *
  * @source mediawiki.org/wiki/Snippets/MySandbox
* Required modules: mediawiki.util, mediawiki.Title, mediawiki.Uri
  * @version 2
*
  * @source https://www.mediawiki.org/wiki/Snippets/MySandbox
  * @version 2014-07-16
  */
  */
( function ( mw, $ ) {
( function ( mw, $ ) {
 
$( function () {
$( document ).ready( function () {
var conf, title, url;
var conf, title, url;


// Costomize/Translate this to your needs
// Customize/Translate this to your needs
conf = {
conf = {
subpageName: 'sandbox',
subpageName: 'sandbox',
Line 26: Line 26:


url = new mw.Uri( title.getUrl() );
url = new mw.Uri( title.getUrl() );
url.extend({
url.extend( {
action: 'edit',
action: 'edit',
redlink: 1,
redlink: 1,
editintro: new mw.Title( conf.editintroPagename ),
editintro: new mw.Title( conf.editintroPagename ),
preload: new mw.Title( conf.preloadPagename )
preload: new mw.Title( conf.preloadPagename )
});
} );


mw.util.addPortletLink(
mw.util.addPortletLink(
Line 37: Line 37:
url,
url,
conf.portletLabel,
conf.portletLabel,
'pt-mysandbox',
'pt-sandbox',
conf.portletTooltip,
conf.portletTooltip,
null,
null,
'#pt-preferences'
'#pt-preferences'
);
);
});
} );
}( mediaWiki, jQuery ) );
}( mediaWiki, jQuery ) );

Latest revision as of 19:06, 7 March 2020

/**
 * Add a "My sandbox" link to the personal portlet menu.
 *
 * Required modules: mediawiki.util, mediawiki.Title, mediawiki.Uri
 *
 * @source https://www.mediawiki.org/wiki/Snippets/MySandbox
 * @version 2014-07-16
 */
( function ( mw, $ ) {
	$( function () {
		var conf, title, url;

		// Customize/Translate this to your needs
		conf = {
			subpageName: 'sandbox',
			portletLabel: 'Sandbox',
			portletTooltip: 'Go to your sandbox',
			editintroPagename: 'Template:User_sandbox',
			preloadPagename: 'Template:User_sandbox/preload'
		};
		// Don't alter the code below

		// Use Special:MyPage (as opposed to mw.user.getName()) so that it
		// works for logged-out users as well.
		title = new mw.Title( 'Special:MyPage/' + conf.subpageName );

		url = new mw.Uri( title.getUrl() );
		url.extend( {
			action: 'edit',
			redlink: 1,
			editintro: new mw.Title( conf.editintroPagename ),
			preload: new mw.Title( conf.preloadPagename )
		} );

		mw.util.addPortletLink(
			'p-personal',
			url,
			conf.portletLabel,
			'pt-sandbox',
			conf.portletTooltip,
			null,
			'#pt-preferences'
		);
	} );
}( mediaWiki, jQuery ) );