MediaWiki:Common.js: Difference between revisions

The most up-to-date image and information guide on Webkinz Classic items, events, and more!
Content added Content deleted
No edit summary
No edit summary
Line 17: Line 17:
'p-cactions',
'p-cactions',
mw.util.getUrl('Special:Log/' + conf.wgPageName),
mw.util.getUrl('Special:Log/' + conf.wgPageName),
'Logs',
'Logs');
'Logs for this page');


// add extension-enabled report for the latest revision
// add list of subpages for this page
mw.util.addPortletLink(
'p-cactions',
mw.util.getUrl('Special:Report/' + mw.config.get('wgCurRevisionId')),
'Report a problem',
'Report a problem');

// add list of subpages
mw.util.addPortletLink(
mw.util.addPortletLink(
'p-cactions',
'p-cactions',
mw.util.getUrl('Special:PrefixIndex/' + conf.wgPageName),
mw.util.getUrl('Special:PrefixIndex/' + conf.wgPageName),
'Subpages',
'Subpages');
'Subpages');


Line 37: Line 28:
if (conf.wgCanonicalNamespace == 'User') {
if (conf.wgCanonicalNamespace == 'User') {


// add user rights
// add user rights for this page
mw.util.addPortletLink(
mw.util.addPortletLink(
'p-cactions',
'p-cactions',
mw.util.getUrl('Special:UserRights/' + conf.wgPageName),
mw.util.getUrl('Special:UserRights/' + conf.wgPageName),
'User rights',
'User rights');
'User rights');
}
}

// 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');
});
});
}
}

Revision as of 20:23, 13 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');

        // add list of subpages for this page
        mw.util.addPortletLink(
            'p-cactions',
            mw.util.getUrl('Special:PrefixIndex/' + conf.wgPageName),
            'Subpages');

        // 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 extension-enabled report for the latest revision
        mw.util.addPortletLink(
            'p-cactions',
            mw.util.getUrl('Special:Report/' + mw.config.get('wgCurRevisionId')),
            'Report a problem');
    });
}