Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

twinkle.js: group all portlet code in a class #1836

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/friendlyshared.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Twinkle.shared = function friendlyshared() {
if (mw.config.get('wgNamespaceNumber') === 3 && mw.util.isIPAddress(mw.config.get('wgTitle'))) {
var username = mw.config.get('wgRelevantUserName');
Twinkle.addPortletLink(function() {
Twinkle.MenuBuilder.addPortletLink(function() {
Twinkle.shared.callback(username);
}, 'Shared IP', 'friendly-shared', 'Shared IP tagging');
}
Expand Down
6 changes: 3 additions & 3 deletions modules/friendlytag.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ Twinkle.tag = function friendlytag() {
// redirect tagging
if (Morebits.isPageRedirect()) {
Twinkle.tag.mode = 'redirect';
Twinkle.addPortletLink(Twinkle.tag.callback, 'Tag', 'friendly-tag', 'Tag redirect');
Twinkle.MenuBuilder.addPortletLink(Twinkle.tag.callback, 'Tag', 'friendly-tag', 'Tag redirect');
// file tagging
} else if (mw.config.get('wgNamespaceNumber') === 6 && !document.getElementById('mw-sharedupload') && document.getElementById('mw-imagepage-section-filehistory')) {
Twinkle.tag.mode = 'file';
Twinkle.addPortletLink(Twinkle.tag.callback, 'Tag', 'friendly-tag', 'Add maintenance tags to file');
Twinkle.MenuBuilder.addPortletLink(Twinkle.tag.callback, 'Tag', 'friendly-tag', 'Add maintenance tags to file');
// article/draft article tagging
} else if ([0, 118].indexOf(mw.config.get('wgNamespaceNumber')) !== -1 && mw.config.get('wgCurRevisionId')) {
Twinkle.tag.mode = 'article';
Expand All @@ -29,7 +29,7 @@ Twinkle.tag = function friendlytag() {
// Disabled on latest diff because the diff slider could be used to slide
// away from the latest diff without causing the script to reload
!mw.config.get('wgDiffNewId');
Twinkle.addPortletLink(Twinkle.tag.callback, 'Tag', 'friendly-tag', 'Add or remove article maintenance tags');
Twinkle.MenuBuilder.addPortletLink(Twinkle.tag.callback, 'Tag', 'friendly-tag', 'Add or remove article maintenance tags');
}
};

Expand Down
2 changes: 1 addition & 1 deletion modules/friendlytalkback.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Twinkle.talkback = function() {
if (!mw.config.exists('wgRelevantUserName') || Morebits.ip.isRange(mw.config.get('wgRelevantUserName'))) {
return;
}
Twinkle.addPortletLink(Twinkle.talkback.callback, 'TB', 'friendly-talkback', 'Easy talkback');
Twinkle.MenuBuilder.addPortletLink(Twinkle.talkback.callback, 'TB', 'friendly-talkback', 'Easy talkback');
};

Twinkle.talkback.callback = function() {
Expand Down
2 changes: 1 addition & 1 deletion modules/friendlywelcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Twinkle.welcome.normal = function() {
}
// Users and IPs but not IP ranges
if (mw.config.exists('wgRelevantUserName') && !Morebits.ip.isRange(mw.config.get('wgRelevantUserName'))) {
Twinkle.addPortletLink(function() {
Twinkle.MenuBuilder.addPortletLink(function() {
Twinkle.welcome.callback(mw.config.get('wgRelevantUserName'));
}, 'Wel', 'friendly-welcome', 'Welcome user');
}
Expand Down
2 changes: 1 addition & 1 deletion modules/twinklearv.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Twinkle.arv = function twinklearv() {
}
var userType = isIP ? 'IP' + (Morebits.ip.isRange(username) ? ' range' : '') : 'user';

Twinkle.addPortletLink(function() {
Twinkle.MenuBuilder.addPortletLink(function() {
Twinkle.arv.callback(username, isIP);
}, 'ARV', 'tw-arv', 'Report ' + userType + ' to administrators');
};
Expand Down
2 changes: 1 addition & 1 deletion modules/twinklebatchdelete.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Twinkle.batchdelete = function twinklebatchdelete() {
mw.config.get('wgCanonicalSpecialPageName') === 'Prefixindex'
)
) {
Twinkle.addPortletLink(Twinkle.batchdelete.callback, 'D-batch', 'tw-batch', 'Delete pages found in this category/on this page');
Twinkle.MenuBuilder.addPortletLink(Twinkle.batchdelete.callback, 'D-batch', 'tw-batch', 'Delete pages found in this category/on this page');
}
};

Expand Down
2 changes: 1 addition & 1 deletion modules/twinklebatchprotect.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Twinkle.batchprotect = function twinklebatchprotect() {
if (Morebits.userIsSysop && ((mw.config.get('wgArticleId') > 0 && (mw.config.get('wgNamespaceNumber') === 2 ||
mw.config.get('wgNamespaceNumber') === 4)) || mw.config.get('wgNamespaceNumber') === 14 ||
mw.config.get('wgCanonicalSpecialPageName') === 'Prefixindex')) {
Twinkle.addPortletLink(Twinkle.batchprotect.callback, 'P-batch', 'tw-pbatch', 'Protect pages linked from this page');
Twinkle.MenuBuilder.addPortletLink(Twinkle.batchprotect.callback, 'P-batch', 'tw-pbatch', 'Protect pages linked from this page');
}
};

Expand Down
2 changes: 1 addition & 1 deletion modules/twinklebatchundelete.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Twinkle.batchundelete = function twinklebatchundelete() {
mw.config.get('wgNamespaceNumber') !== mw.config.get('wgNamespaceIds').project)) {
return;
}
Twinkle.addPortletLink(Twinkle.batchundelete.callback, 'Und-batch', 'tw-batch-undel', "Undelete 'em all");
Twinkle.MenuBuilder.addPortletLink(Twinkle.batchundelete.callback, 'Und-batch', 'tw-batch-undel', "Undelete 'em all");
};

Twinkle.batchundelete.callback = function twinklebatchundeleteCallback() {
Expand Down
2 changes: 1 addition & 1 deletion modules/twinkleblock.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Twinkle.block = function twinkleblock() {
// should show on Contributions or Block pages, anywhere there's a relevant user
// Ignore ranges wider than the CIDR limit
if (Morebits.userIsSysop && relevantUserName && (!Morebits.ip.isRange(relevantUserName) || Morebits.ip.validCIDR(relevantUserName))) {
Twinkle.addPortletLink(Twinkle.block.callback, 'Block', 'tw-block', 'Block relevant user');
Twinkle.MenuBuilder.addPortletLink(Twinkle.block.callback, 'Block', 'tw-block', 'Block relevant user');
}
};

Expand Down
21 changes: 0 additions & 21 deletions modules/twinkleconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -931,27 +931,6 @@ Twinkle.config.sections = [
title: 'Hidden',
hidden: true,
preferences: [
// twinkle.js: portlet setup
{
name: 'portletArea',
type: 'string'
},
{
name: 'portletId',
type: 'string'
},
{
name: 'portletName',
type: 'string'
},
{
name: 'portletType',
type: 'string'
},
{
name: 'portletNext',
type: 'string'
},
// twinklefluff.js: defines how many revision to query maximum, maximum possible is 50, default is 50
{
name: 'revertMaxRevisions',
Expand Down
2 changes: 1 addition & 1 deletion modules/twinkledeprod.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Twinkle.deprod = function() {
) {
return;
}
Twinkle.addPortletLink(Twinkle.deprod.callback, 'Deprod', 'tw-deprod', 'Delete prod pages found in this category');
Twinkle.MenuBuilder.addPortletLink(Twinkle.deprod.callback, 'Deprod', 'tw-deprod', 'Delete prod pages found in this category');
};

var concerns = {};
Expand Down
8 changes: 4 additions & 4 deletions modules/twinklediff.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ Twinkle.diff = function twinklediff() {
if (mw.config.get('wgNamespaceNumber') < 0 || !mw.config.get('wgArticleId')) {
return;
}
Twinkle.addPortletLink(mw.util.getUrl(mw.config.get('wgPageName'), {diff: 'cur', oldid: 'prev'}), 'Last', 'tw-lastdiff', 'Show most recent diff');
Twinkle.MenuBuilder.addPortletLink(mw.util.getUrl(mw.config.get('wgPageName'), {diff: 'cur', oldid: 'prev'}), 'Last', 'tw-lastdiff', 'Show most recent diff');

// Show additional tabs only on diff pages
if (mw.config.get('wgDiffNewId')) {
Twinkle.addPortletLink(function() {
Twinkle.MenuBuilder.addPortletLink(function() {
Twinkle.diff.evaluate(false);
}, 'Since', 'tw-since', 'Show difference between last diff and the revision made by previous user');
Twinkle.addPortletLink(function() {
Twinkle.MenuBuilder.addPortletLink(function() {
Twinkle.diff.evaluate(true);
}, 'Since mine', 'tw-sincemine', 'Show difference between last diff and my last revision');

Twinkle.addPortletLink(mw.util.getUrl(mw.config.get('wgPageName'), {diff: 'cur', oldid: mw.config.get('wgDiffNewId')}), 'Current', 'tw-curdiff', 'Show difference to current revision');
Twinkle.MenuBuilder.addPortletLink(mw.util.getUrl(mw.config.get('wgPageName'), {diff: 'cur', oldid: mw.config.get('wgDiffNewId')}), 'Current', 'tw-curdiff', 'Show difference to current revision');
}
};

Expand Down
2 changes: 1 addition & 1 deletion modules/twinkleimage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

Twinkle.image = function twinkleimage() {
if (mw.config.get('wgNamespaceNumber') === 6 && mw.config.get('wgArticleId') && !document.getElementById('mw-sharedupload') && !Morebits.isPageRedirect()) {
Twinkle.addPortletLink(Twinkle.image.callback, 'DI', 'tw-di', 'Nominate file for delayed speedy deletion');
Twinkle.MenuBuilder.addPortletLink(Twinkle.image.callback, 'DI', 'tw-di', 'Nominate file for delayed speedy deletion');
}
};

Expand Down
2 changes: 1 addition & 1 deletion modules/twinkleprod.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Twinkle.prod = function twinkleprod() {
return;
}

Twinkle.addPortletLink(Twinkle.prod.callback, 'PROD', 'tw-prod', 'Propose deletion via WP:PROD');
Twinkle.MenuBuilder.addPortletLink(Twinkle.prod.callback, 'PROD', 'tw-prod', 'Propose deletion via WP:PROD');
};

// Used in edit summaries, for comparisons, etc.
Expand Down
2 changes: 1 addition & 1 deletion modules/twinkleprotect.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Twinkle.protect = function twinkleprotect() {
return;
}

Twinkle.addPortletLink(Twinkle.protect.callback, Morebits.userIsSysop ? 'PP' : 'RPP', 'tw-rpp',
Twinkle.MenuBuilder.addPortletLink(Twinkle.protect.callback, Morebits.userIsSysop ? 'PP' : 'RPP', 'tw-rpp',
Morebits.userIsSysop ? 'Protect page' : 'Request page protection');
};

Expand Down
2 changes: 1 addition & 1 deletion modules/twinklespeedy.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Twinkle.speedy = function twinklespeedy() {
return;
}

Twinkle.addPortletLink(Twinkle.speedy.callback, 'CSD', 'tw-csd', Morebits.userIsSysop ? 'Delete page according to WP:CSD' : 'Request speedy deletion according to WP:CSD');
Twinkle.MenuBuilder.addPortletLink(Twinkle.speedy.callback, 'CSD', 'tw-csd', Morebits.userIsSysop ? 'Delete page according to WP:CSD' : 'Request speedy deletion according to WP:CSD');
};

// This function is run when the CSD tab/header link is clicked
Expand Down
2 changes: 1 addition & 1 deletion modules/twinkleunlink.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Twinkle.unlink = function twinkleunlink() {
(!Morebits.userIsInGroup('extendedconfirmed') && !Morebits.userIsSysop)) {
return;
}
Twinkle.addPortletLink(Twinkle.unlink.callback, 'Unlink', 'tw-unlink', 'Unlink backlinks');
Twinkle.MenuBuilder.addPortletLink(Twinkle.unlink.callback, 'Unlink', 'tw-unlink', 'Unlink backlinks');
};

// the parameter is used when invoking unlink from admin speedy
Expand Down
2 changes: 1 addition & 1 deletion modules/twinklewarn.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Twinkle.warn = function twinklewarn() {

// Users and IPs but not IP ranges
if (mw.config.exists('wgRelevantUserName') && !Morebits.ip.isRange(mw.config.get('wgRelevantUserName'))) {
Twinkle.addPortletLink(Twinkle.warn.callback, 'Warn', 'tw-warn', 'Warn/notify user');
Twinkle.MenuBuilder.addPortletLink(Twinkle.warn.callback, 'Warn', 'tw-warn', 'Warn/notify user');
if (Twinkle.getPref('autoMenuAfterRollback') &&
mw.config.get('wgNamespaceNumber') === 3 &&
Twinkle.getPrefill('vanarticle') &&
Expand Down
2 changes: 1 addition & 1 deletion modules/twinklexfd.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Twinkle.xfd = function twinklexfd() {
break;
}
}
Twinkle.addPortletLink(Twinkle.xfd.callback, 'XFD', 'tw-xfd', tooltip);
Twinkle.MenuBuilder.addPortletLink(Twinkle.xfd.callback, 'XFD', 'tw-xfd', tooltip);
};


Expand Down
2 changes: 1 addition & 1 deletion scripts/morebits-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ mw.loader.using('jquery.ui', function() {

Twinkle.morebitsTestInit = function () {
if (mw.config.get('wgAction') === 'view' && mw.config.get('skin') === 'vector' && mw.config.get('wgNamespaceNumber') >= 0) {
Twinkle.addPortlet('javascript:Twinkle.morebitsTest.launchDialog(Twinkle.morebitsTest.$runTests)', 'Test', 'tw-test', 'Test morebits.js', '');
Twinkle.MenuBuilder.addPortlet('javascript:Twinkle.morebitsTest.launchDialog(Twinkle.morebitsTest.$runTests)', 'Test', 'tw-test', 'Test morebits.js', '');
}
};

Expand Down
Loading