MediaWiki:Gadget-Adiutor-PMR.js
Eʼtibor bering: Oʻzgartirishlaringizni koʻrish uchun, yangi moslamalaringizning saqlashdan keyin, brauzer keshini tozalash kerak:
Mozilla / Firefox: Ctrl+Shift+R, IE: Ctrl+F5, Safari: Cmd+Shift+R, Konqueror: F5, Opera: Tools → Preferences orqali keshni tozalang.
/*
* Adiutor: A gadget to assist various user actions
* Author: Vikipolimer
* Licencing and attribution: [[:tr:VP:Adiutor#Lisanslama ve atıf]]
* Module: Page move requests
*/
/* <nowiki> */
$.when(mw.loader.using(["mediawiki.user", "oojs-ui-core", "oojs-ui-windows", ]), $.ready).then(function() {
var mwConfig = mw.config.get(["wgAction", "wgPageName", "wgTitle", "wgUserGroups", "wgUserName", "wgCanonicalNamespace", "wgNamespaceNumber"]);
api = new mw.Api();
function PageMoveRequestDialog(config) {
PageMoveRequestDialog.super.call(this, config);
}
OO.inheritClass(PageMoveRequestDialog, OO.ui.ProcessDialog);
PageMoveRequestDialog.static.name = 'PageMoveRequestDialog';
PageMoveRequestDialog.static.title = 'Adiutor — Sahifani koʻchirishga nomzod sifatida koʻrsatish';
PageMoveRequestDialog.static.actions = [{
action: 'save',
label: 'Bajarish',
flags: ['primary', 'progressive']
}, {
label: 'Yopish',
flags: 'safe'
}];
PageMoveRequestDialog.prototype.initialize = function() {
PageMoveRequestDialog.super.prototype.initialize.apply(this, arguments);
var headerTitle = new OO.ui.MessageWidget({
type: 'notice',
inline: true,
label: new OO.ui.HtmlSnippet('<strong>Sahifani koʻchirishga nomzod sifatida koʻrsatish</strong><br><small>„Koʻchirish“ sahifa nomini oʻzgartirish uchun ishlatiladi. Quyida sahifaning yangi nomi va nom oʻzgartirish sababi koʻrsatilishi lozim.</small>')
});
var RequestRationale = new OO.ui.FieldsetLayout({
label: '',
});
RequestRationale.addItems([
new OO.ui.FieldLayout(NewPageName = new OO.ui.TextInputWidget({
value: '',
indicator: 'required',
}), {
label: 'Yangi nomi',
}),
new OO.ui.FieldLayout(rationaleInput = new OO.ui.MultilineTextInputWidget({
placeholder: 'Bu yerda nom oʻzgartirish sababini bayon eting.',
value: '',
indicator: 'required',
}), {
label: 'Sababi',
align: 'inline',
}),
]);
this.content = new OO.ui.PanelLayout({
padded: true,
expanded: false
});
this.content.$element.prepend(headerTitle.$element, '<br><hr><br>', RequestRationale.$element, '<br>', rationaleInput.$element);
this.$body.prepend(this.content.$element);
};
PageMoveRequestDialog.prototype.getActionProcess = function(action) {
var dialog = this;
if(action) {
return new OO.ui.Process(function() {
createRequest(NewPageName, rationaleInput);
dialog.close({
action: action
});
});
}
return PageMoveRequestDialog.super.prototype.getActionProcess.call(this, action);
};
var windowManager = new OO.ui.WindowManager();
$(document.body).prepend(windowManager.$element);
var dialog = new PageMoveRequestDialog();
windowManager.addWindows([dialog]);
windowManager.openWindow(dialog);
function createRequest(NewPageName, rationaleInput) {
api.postWithToken('csrf', {
action: 'edit',
title: mwConfig.wgPageName,
prependtext: '{{koʻchirishga |1= ' + NewPageName.value + '|sabab= ' + rationaleInput.value + ' }}',
summary: 'Sahifa koʻchirishga nomzod sifatida koʻrsatildi',
tags: 'Adiutor',
format: 'json'
}).done(function() {
window.location = mwConfig.wgPageName;
});
}
});
/* </nowiki> */