MediaWiki:Gadget-morebits.js: Difference between revisions
Content deleted Content added
Amorymeltzer (talk | contribs) Repo at 3fd646e: Fix constructor order for firefox |
Amorymeltzer (talk | contribs) Repo at ed1b903: Add basic watchlist expiry support, do away with setWatchlistFromPreferences |
||
Line 2,272:
followCrossNsRedirect: true,
watchlistOption: 'nochange',
watchlistExpiry: null,
creator: null,
timestamp: null,
Line 2,458 ⟶ 2,459:
watchlist: ctx.watchlistOption
};
if (ctx.changeTags) {
query.tags = ctx.changeTags;
}
if (ctx.watchlistExpiry) {
query.watchlistexpiry = ctx.watchlistExpiry;
}
Line 2,714 ⟶ 2,718:
/**
* @param {boolean|string} [watchlistOption=false] -
* Basically a mix of MW API and Twinkley options available pre-expiry:
* - `
* - `false`|`'no'`: watchlist status of the page will not be changed.
* - `'default'`|`'preferences'`: watchlist status of the page will
* be set based on the user's preference settings when the action is
* called. Ignores ability of default + expiry.
* - `'unwatch'`: explicitly unwatch the page
* - {string|number}: watch page until the specified time (relative or absolute datestring)
*/
this.setWatchlist = function(watchlistOption) {
if (!watchlistOption || watchlistOption === 'no') {
ctx.watchlistOption = 'watch';▼
} else {▼
ctx.watchlistOption = 'nochange';
} else if (watchlistOption === 'default' || watchlistOption === 'preferences') {
ctx.watchlistOption = 'preferences';
} else if (watchlistOption === 'unwatch') {
ctx.watchlistOption = 'unwatch';
▲ } else {
▲ ctx.watchlistOption = 'watch';
if (typeof watchlistOption === 'number' || (typeof watchlistOption === 'string' && watchlistOption !== 'yes')) {
ctx.watchlistExpiry = watchlistOption;
}
}
};
/**
* Set an expiry. setWatchlist can handle this by itself if passed a
* string, so this is here largely for completeness and compatibility.
*
* @param {string} watchlistExpiry
* */
this.setWatchlistExpiry = function(watchlistExpiry) {
ctx.watchlistExpiry = watchlistExpiry;
};
/**
* @deprecated Use setWatchlist.
* @param {boolean} [watchlistOption=false] -
* - `True`: page watchlist status will be set based on the user's
Line 2,743 ⟶ 2,771:
*/
this.setWatchlistFromPreferences = function(watchlistOption) {
console.warn('NOTE: Morebits.wiki.page.setWatchlistFromPreferences was deprecated December 2020, please use setWatchlist'); // eslint-disable-line no-console
if (watchlistOption) {
ctx.watchlistOption = 'preferences';
Line 3,707 ⟶ 3,736:
}
if (ctx.watchlistExpiry) {
query.watchlistexpiry = ctx.watchlistExpiry;
}
if (ctx.moveTalkPage) {
query.movetalk = 'true';
Line 3,844 ⟶ 3,876:
}
if (ctx.watchlistExpiry) {
query.watchlistexpiry = ctx.watchlistExpiry;
}
ctx.deleteProcessApi = new Morebits.wiki.api('deleting page...', query, ctx.onDeleteSuccess, ctx.statusElement, fnProcessDeleteError);
Line 3,903 ⟶ 3,938:
}
if (ctx.watchlistExpiry) {
query.watchlistexpiry = ctx.watchlistExpiry;
}
ctx.undeleteProcessApi = new Morebits.wiki.api('undeleting page...', query, ctx.onUndeleteSuccess, ctx.statusElement, fnProcessUndeleteError);
Line 4,019 ⟶ 4,057:
}
if (ctx.watchlistExpiry) {
query.watchlistexpiry = ctx.watchlistExpiry;
}
if (ctx.protectCascade) {
query.cascade = 'true';
Line 4,054 ⟶ 4,095:
// tags: ctx.changeTags, // flaggedrevs tag support: [[phab:T247721]]
reason: ctx.editSummary,
watchlist: ctx.watchlistOption // Doesn't support watchlist expiry [[phab:T263336]]
};
|