MediaWiki:Gadget-twinkleblock.js: Difference between revisions
Content deleted Content added
Repo at 001f236: simplify IIFEs (#2074); apply autofixes 3 (#2079); apply autofixes 2 (#2069) |
Repo at e7d4c6c: fix some no-jquery/no-extend autofixes (#2088); capitalize Morebit class names (#2087); fix linter error no-sequences (#2083) |
||
Line 34:
Twinkle.block.field_template_options = {};
const Window = new Morebits.
// need to be verbose about who we're blocking
Window.setTitle('Block or issue block template to ' + relevantUserName);
Line 47:
Window.addFooterLink('Unblock this user', 'Special:Unblock/' + relevantUserName, true);
const form = new Morebits.
const actionfield = form.append({
type: 'field',
Line 187:
const unblockLink = document.querySelector('.morebits-dialog-footerlinks a');
if (blockedUserName !== relevantUserName) {
unblockLink.hidden = true
unblockLink.nextSibling.hidden = true; // link+trailing bullet } else {
unblockLink.hidden = false
unblockLink.nextSibling.hidden = false; // link+trailing bullet }
Line 233 ⟶ 235:
Twinkle.block.processUserInfo(data, fn);
}, (msg) => {
Morebits.
Morebits.
});
};
Line 341 ⟶ 343:
if (blockBox) {
field_preset = new Morebits.
field_preset.append({
type: 'select',
Line 350 ⟶ 352:
});
field_block_options = new Morebits.
field_block_options.append({ type: 'div', name: 'currentblock', label: ' ' });
field_block_options.append({ type: 'div', name: 'hasblocklog', label: ' ' });
Line 530 ⟶ 532:
};
if (templateBox) {
field_template_options = new Morebits.
field_template_options.append({
type: 'select',
Line 721 ⟶ 723:
oldfield = $form.find('fieldset[name="field_template_options"]')[0];
oldfield.parentNode.replaceChild(field_template_options.render(), oldfield);
e.target.form.root.previewer = new Morebits.wiki.
} else {
$form.find('fieldset[name="field_template_options"]').hide();
Line 732 ⟶ 734:
const sameUser = blockedUserName === relevantUserName;
Morebits.
let statusStr = relevantUserName + ' is ' + (Twinkle.block.currentBlockInfo.partial === '' ? 'partially blocked' : 'blocked sitewide');
Line 749 ⟶ 751:
if (Twinkle.block.currentBlockInfo.expiry === 'infinity') {
statusStr += ' (indefinite)';
} else if (new Morebits.
statusStr += ' (expires ' + new Morebits.
}
Line 766 ⟶ 768:
}
Morebits.
// Default to the current block conditions on intial form generation
Line 780 ⟶ 782:
const lastBlockAction = Twinkle.block.blockLog[0];
if (lastBlockAction.action === 'unblock') {
$blockloglink.append(' (unblocked ' + new Morebits.
} else { // block or reblock
$blockloglink.append(' (' + lastBlockAction.params.duration + ', expired ' + new Morebits.
}
}
Morebits.
Morebits.
}
Line 1,516 ⟶ 1,518:
Twinkle.block.callback.change_template(e);
} else {
Morebits.
}
};
Line 1,523 ⟶ 1,525:
const expiry = e.target.form.expiry;
if (e.target.value === 'custom') {
Morebits.
} else {
Morebits.
expiry.value = e.target.value;
}
Line 1,584 ⟶ 1,586:
form.expiry.value = expiry;
if (form.expiry_preset.value === 'custom') {
Morebits.
} else {
Morebits.
}
}
Line 1,673 ⟶ 1,675:
form.expiry.value = Twinkle.block.prev_template_expiry;
}
Morebits.
// Partial
Morebits.
Morebits.
} else if (templateBox) { // Only present if block && template forms both visible
Morebits.
form.blank_duration.parentNode,
!settings.indefinite && !settings.nonstandard
Line 1,684 ⟶ 1,686:
}
Morebits.
// Only particularly relevant if template form is present
Morebits.
Morebits.
// Partial block
Morebits.
form.root.previewer.closePreview();
Line 1,778 ⟶ 1,780:
}
Morebits.
Morebits.
const statusElement = new Morebits.
blockoptions.action = 'block';
Line 1,856 ⟶ 1,858:
logExpiry = 'indefinitely';
} else {
const expiryDate = new Morebits.
logExpiry += (expiryDate.isBefore(new Date()) ? ', expired ' : ' until ') + expiryDate.calendar();
}
} else { // no duration, action=unblock, just show timestamp
logExpiry = ' ' + new Morebits.
}
message += Morebits.string.toUpperCaseFirstChar(logevents.action) + 'ed by ' + logevents.user + logExpiry +
Line 1,866 ⟶ 1,868:
if (!confirm(message)) {
Morebits.
return;
}
Line 1,875 ⟶ 1,877:
blockoptions.tags = Twinkle.changeTags;
blockoptions.token = mw.user.tokens.get('csrfToken');
const mbApi = new Morebits.wiki.
statusElement.info('Completed');
if (toWarn) {
Line 1,884 ⟶ 1,886:
});
} else if (toWarn) {
Morebits.
Morebits.
Twinkle.block.callback.issue_template(templateoptions);
} else {
Line 1,898 ⟶ 1,900:
const userTalkPage = 'User_talk:' + mw.config.get('wgRelevantUserName');
const params = Object.assign(formData || {}, {
messageData: Twinkle.block.blockPresetsInfo[formData.template],
reason: Twinkle.block.field_template_options.block_reason,
Line 1,909 ⟶ 1,911:
Morebits.wiki.actionCompleted.notice = 'Actions complete, loading user talk page in a few seconds';
const wikipedia_page = new Morebits.wiki.
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.block.callback.main);
Line 1,928 ⟶ 1,930:
if (params.indefinite) {
text += '|indef=yes';
} else if (!params.blank_duration && !new Morebits.
// Block template wants a duration, not date
text += '|time=' + params.expiry;
Line 1,990 ⟶ 1,992:
Twinkle.block.callback.main = function twinkleblockcallbackMain(pageobj) {
let params = pageobj.getCallbackParameters(),
date = new Morebits.
messageData = params.messageData,
text;
Line 1,997 ⟶ 1,999:
if (Twinkle.getPref('blankTalkpageOnIndefBlock') && params.template !== 'uw-lblock' && params.indefinite) {
Morebits.
text = date.monthHeader() + '\n';
} else {
Line 2,016 ⟶ 2,018:
if (!dateHeaderRegexResult || dateHeaderRegexResult.index !== lastHeaderIndex) {
Morebits.
text += date.monthHeader() + '\n';
}
|