MediaWiki:Common.js: Difference between revisions
Content added Content deleted
(stop cascading, maybe?) |
(subpages only appear in user ns) |
||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
// add a bunch of stuff to the default p-cactions dropdown. documentation at [[mw:ResourceLoader/Core modules]] and https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.util-method-addPortletLink |
|||
var conf = mw.config.get([ |
var conf = mw.config.get([ |
||
'wgCanonicalNamespace', |
'wgCanonicalNamespace', |
||
'wgPageName', |
'wgPageName', |
||
]); |
]); |
||
// Only do the following not in the Special: namespace. |
// Only do the following not in the Special: namespace. |
||
if ( |
if (conf.wgCanonicalNamespace !== 'Special') { |
||
// First wait for mediawiki.util to load, and the page to be ready. |
|||
⚫ | |||
// General usage pattern: mw.util.addPortletLink( portletId, href, text /* Optional: , id, tooltip, accesskey, nextnode */ ); |
|||
// add logs for this page |
|||
mw.util.addPortletLink( |
|||
'p-cactions', |
|||
⚫ | |||
'Logs'); |
|||
// only do the following if in user namespace |
|||
if (conf.wgCanonicalNamespace == 'User') { |
|||
// add user rights for this page |
|||
mw.util.addPortletLink( |
|||
'p-cactions', |
|||
mw.util.getUrl('Special:UserRights/' + conf.wgPageName), |
|||
'User rights'); |
|||
// add list of subpages for this page |
|||
mw.util.addPortletLink( |
|||
'p-cactions', |
|||
mw.util.getUrl('Special:PrefixIndex/' + conf.wgPageName), |
|||
'Subpages'); |
|||
} |
|||
// add extension-enabled report for the latest revision |
|||
// Add a link to the actions menu to Special:Log and Special:Report for this page. |
|||
mw.util.addPortletLink( |
|||
⚫ | |||
'p-cactions', |
|||
⚫ | |||
mw.util.getUrl('Special:Report/' + mw.config.get('wgCurRevisionId')), |
|||
'Report a problem'); |
|||
} |
|||
); |
}); |
||
} |
} |
Latest revision as of 05:22, 15 March 2023
// add a bunch of stuff to the default p-cactions dropdown. documentation at [[mw:ResourceLoader/Core modules]] and https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.util-method-addPortletLink
var conf = mw.config.get([
'wgCanonicalNamespace',
'wgPageName',
]);
// Only do the following not in the Special: namespace.
if (conf.wgCanonicalNamespace !== 'Special') {
// First wait for mediawiki.util to load, and the page to be ready.
mw.loader.using('mediawiki.util', function() {
// General usage pattern: mw.util.addPortletLink( portletId, href, text /* Optional: , id, tooltip, accesskey, nextnode */ );
// add logs for this page
mw.util.addPortletLink(
'p-cactions',
mw.util.getUrl('Special:Log/' + conf.wgPageName),
'Logs');
// only do the following if in user namespace
if (conf.wgCanonicalNamespace == 'User') {
// add user rights for this page
mw.util.addPortletLink(
'p-cactions',
mw.util.getUrl('Special:UserRights/' + conf.wgPageName),
'User rights');
// add list of subpages for this page
mw.util.addPortletLink(
'p-cactions',
mw.util.getUrl('Special:PrefixIndex/' + conf.wgPageName),
'Subpages');
}
// add extension-enabled report for the latest revision
mw.util.addPortletLink(
'p-cactions',
mw.util.getUrl('Special:Report/' + mw.config.get('wgCurRevisionId')),
'Report a problem');
});
}