User:Euphoria/common.js: Difference between revisions

From Test Wiki
Content deleted Content added
OOUI buttons
fix
Line 1:
// <nowiki>
mw.loader.using(['mediawiki.util', 'mediawiki.api', 'oojs-ui-core', 'oojs-ui-widgets'], function () {
const pagePrefix = 'User:Euphoria/Test VfD';
 
Line 22:
 
const actions = [
{ name: 'delete', colorcolorClass: '#e74c3c', flag: 'destructiveoo-ui-destructiveElement' },
{ name: 'keep', colorcolorClass: '#27ae60', flag: 'progressiveoo-ui-progressiveElement' },
{ name: 'no consensus', color: '#f1c40f', flagcolorClass: 'oo-ui-warningElement' }
];
 
actions.forEach(function (actionObj) {
// Create OOUI button
const btn = new OO.ui.ButtonWidget({
label: actionObj.name.charAt(0).toUpperCase(),
title: 'Close as ' + actionObj.name,
flagsclasses: actionObj.flag['vfd-btn', ? [actionObj.flag] : [colorClass],
framedflags: false['small'] // small button size
});
 
// Mouse hover brightness handled automatically by OOUI
btn.on('click', function (e) {
e.preventDefault();
Line 62 ⟶ 60:
'\n{{subst:vb}}';
 
// Edit discussion page
api.postWithToken('csrf', {
action: 'edit',
Line 85 ⟶ 82:
 
if (actionObj.name === 'delete') {
// Delete target page
api.postWithToken('csrf', {
action: 'delete',
Line 101 ⟶ 97:
 
if (talkId !== "-1") {
// Delete talk page if exists
api.postWithToken('csrf', {
action: 'delete',
Line 121 ⟶ 116:
);
} else {
// Keep / No consensus: update page and talk page
api.get({
action: 'query',
Line 185 ⟶ 179:
});
 
// Append OOUI button element to container
container.appendChild(btn.$element[0]);
});
Line 193 ⟶ 186:
});
});
// </nowiki>