MediaWiki:KETForm.js

Vikipedi, özgür ansiklopedi

Not: Sayfayı kaydettikten sonra değişiklikleri görebilmek için tarayıcınızın önbelleğinizi temizlemeniz gerekir. Google Chrome, Firefox, Microsoft Edge ve Safari: ⇧ Shift tuşuna basılı tutun ve Yeniden Yükle araç çubuğu düğmesine tıklayın. Ayrıntılar ve diğer tarayıcılara yönelik yönergeler için Vikipedi:Önbelleğinizi atlayın sayfasını inceleyin.

/* <nowiki> */
$.when(), $.ready, mw.loader.using(['mediawiki.api', 'mediawiki.widgets', 'mediawiki.util', 'oojs-ui-core', 'oojs-ui-windows']).then(function() {
	var reasonInput, titleInput, reasonPreview;
	if((mw.config.get("wgPageName") !== "Vikipedi:Kullanıcı_engelleme_talepleri")) {
		return;
	}
	var api = new mw.Api();
	var requestsPageTitle = 'Vikipedi:Kullanıcı engelleme talepleri';

	function UserBlockRequestDialog(config) {
		UserBlockRequestDialog.super.call(this, config);
	}
	OO.inheritClass(UserBlockRequestDialog, OO.ui.ProcessDialog);
	UserBlockRequestDialog.static.name = 'UserBlockRequestDialog';
	UserBlockRequestDialog.static.title = 'Kullanıcı Engelleme Talebi';
	UserBlockRequestDialog.static.actions = [{
		action: 'save',
		label: 'Talep Oluştur',
		flags: ['primary', 'progressive']
	}, {
		label: 'İptal',
		flags: 'safe'
	}];
	UserBlockRequestDialog.prototype.initialize = function() {
		UserBlockRequestDialog.super.prototype.initialize.apply(this, arguments);
		var headerTitle = new OO.ui.MessageWidget({
			type: 'notice',
			inline: true,
			label: new OO.ui.HtmlSnippet('<small>Burada talepte bulunmadan önce kullanıcının Vikipedi kuralları ve <a href="https://tr.wikipedia.org/wiki/Vikipedi:Engelleme_politikas%C4%B1">engelleme politikası</a> hakkında bilgilendirilmesi gerekmektedir.</small>')
		});
		titleInput = new OO.ui.TextInputWidget({
			'showMissing': false,
			'required': true,
		});
		reasonInput = new OO.ui.MultilineTextInputWidget({
			'placeholder': 'Bu kullanıcının neden engellenmesi gerekiyor?',
			'required': 'true'
		});
		reasonPreview = new OO.ui.LabelWidget();
		var fieldset = new OO.ui.FieldsetLayout();
		fieldset.addItems([new OO.ui.FieldLayout(titleInput, {
			'label': 'Kullanıcı Adı:',
			align: 'top'
		}), new OO.ui.FieldLayout(reasonInput, {
			'label': 'Gerekçe:',
			align: 'top'
		}), ]);
		this.content = new OO.ui.PanelLayout({
			padded: true,
			expanded: false
		});
		this.content.$element.append(headerTitle.$element, '<br><hr><br>', fieldset.$element);
		this.$body.append(this.content.$element);
	};
	UserBlockRequestDialog.prototype.getActionProcess = function(action) {
		var dialog = this;
		if(action) {
			return new OO.ui.Process(function() {
				api.edit(requestsPageTitle, function() {
					return {
						appendtext: '\n\n' + makeRequestText(),
						summary: '[[Kullanıcı:' + titleInput.getValue() + '|' + titleInput.getValue() + ']] için engel talebi eklendi'
					};
				}).then(function() {
					window.location.href = mw.util.getUrl(requestsPageTitle);
				});
				dialog.close({
					action: action
				});
			});
		}
		return UserBlockRequestDialog.super.prototype.getActionProcess.call(this, action);
	};
	var windowManager = new OO.ui.WindowManager();
	$(document.body).append(windowManager.$element);
	var dialog = new UserBlockRequestDialog();
	windowManager.addWindows([dialog]);
	windowManager.openWindow(dialog);

	function makeRequestText() {
		var reason = reasonInput.getValue();
		return '{{kopyala:Vikipedi:Kullanıcı engelleme talepleri/Önyükleme-şablon |1= ' + titleInput.getValue() + ' |2= ' + reason + '}}';
	}
});
/* </nowiki> */