MediaWiki:Gadget-mySandbox.js: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
| (8 intermediate revisions 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. | ||
* | * | ||
* @source mediawiki.org/wiki/Snippets/MySandbox | * Required modules: mediawiki.util, mediawiki.Title, mediawiki.Uri | ||
* @version | * | ||
* @source https://www.mediawiki.org/wiki/Snippets/MySandbox | |||
* @version 2014-07-16 | |||
*/ | */ | ||
( function ( mw, $ ) { | ( function ( mw, $ ) { | ||
$( function () { | |||
$ | |||
var conf, title, url; | var conf, title, url; | ||
// | // Customize/Translate this to your needs | ||
conf = { | conf = { | ||
subpageName: ' | subpageName: 'sandbox', | ||
portletLabel: 'Sandbox', | portletLabel: 'Sandbox', | ||
portletTooltip: 'Go to your sandbox', | portletTooltip: 'Go to your sandbox', | ||
editintroPagename: 'Template: | editintroPagename: 'Template:User_sandbox', | ||
preloadPagename: 'Template: | preloadPagename: 'Template:User_sandbox/preload' | ||
}; | }; | ||
// Don't alter the code below | // Don't alter the code below | ||
| 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- | '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 ) );