Bureaucrats, editor, Interface administrators, Administrators (Semantic MediaWiki), Curators (Semantic MediaWiki), Editors (Semantic MediaWiki), Administrators
47,327
edits
No edit summary Tag: Manual revert |
No edit summary |
||
Line 1:
"use strict";
/** <nowiki>
* Secondary gadget for the wiki article feedback feature, which runs solely on
Line 7 ⟶ 9:
*/
var conf = mw.config.get(['wgPageName']),
main = {
* Startup method
*/
init: function init() {
var wrappers = $('.gloop-feedback-wrapper');
// Loop through all of the feedback on the page, and add a link to resolve them
for (var i = 0; i < wrappers.length; i++) {
var
},
handleWrapper: function handleWrapper(wrapper) {
if (!feedbackId) {
// No ID exists,
console.warn('Could not init feedback actions: no ID present', wrapper);
// Find the toggle to resolve the feedback
var toggle = $(wrapper).find('.gloop-feedback-resolve-toggle');
if (!toggle.length) {
// No toggle exists, don't do anything
console.warn('Could not init feedback actions: no toggle present', wrapper);
if (toggle.hasClass('table-bg-green')) {
}
$(toggle).on('click', function () {
main.doResolveConfirm(feedbackId, toggle);
},
/**
* Shows a confirmation popup for resolving feedback
doResolveConfirm: function doResolveConfirm(feedbackId, toggle) {
OO.ui.confirm('Clicking OK will resolve this feedback, marking it as complete/no action needed. You cannot unresolve feedback after resolving it.').done(function (confirmed) {
if (confirmed) {
main.doResolve(feedbackId, toggle);
}
});
},
doResolve: function doResolve(feedbackId, toggle) {
var searchString = '\\|id=' + feedbackId + '\n\\|date=(.*)\n\\|resolved=no';
var regex = new RegExp(searchString, 'gim');
new mw.Api().edit(conf.wgPageName, function (revision) {
return {
text: revision.content.replace(regex, '|id=' + feedbackId + '\n|date=$1\n|resolved=yes'),
summary: 'Resolving user-submitted feedback',
assert: 'user',
minor: true
};
}).then(function () {
$(toggle).removeClass('table-bg-red');
$(toggle).addClass('table-bg-green');
$(toggle).find('span').text('Resolved');
$(toggle).off('click');
});
}
};
mw.loader.using(['mediawiki.api', 'oojs-ui-core', 'oojs-ui-windows'], function () {
});
|