Jump to content

Snippets/Force preview/de

From mediawiki.org
This page is a translated version of the page Snippets/Force preview and the translation is 9% complete.
Verwenden von "Snippets"
Liste aller "Snippets"
de
Sprache(n): JavaScript
Kompatibel mit: MediaWiki 1.23++ (Vector)

Force preview is JavaScript that prevents specified individuals or groups from saving a wiki page before they preview it at least once.

In order to use this code, insert it into your wiki's MediaWiki:Common.js page.

Note that this method is not foolproof. If a user disables JavaScript in their browser, they will not have preview forced on them. If you want to ensure that this policy is enforced, then you should look at Erweiterung:ForcePreview .

// Force Preview and Edit-Summary - Start
if (mw.config.get("wgAction") === "edit")
	$.when(mw.loader.using("user.options"), $.ready).then(function () {
		var $wpSave = $("#wpSave"),
			$wpPreview = $("#wpPreview"),
			saveVal = $wpSave.val(),
			classNames = "oo-ui-widget-enabled oo-ui-flaggedElement-progressive oo-ui-flaggedElement-primary";
		if (!mw.user.options.get("forceeditsummary") || mw.user.options.get("previewonfirst"))
			mw.loader.using("mediawiki.api", function () {
				new mw.Api().saveOptions({forceeditsummary: 1, previewonfirst: 0});
			});
		if (!$("#wikiPreview,#wikiDiff").is(":visible") && $wpSave.length && $wpPreview.length) {
			$wpSave.prop("disabled", true)
				.val("Save page (use preview first)")
				.parent().removeClass(classNames).addClass("oo-ui-widget-disabled");
			$wpPreview.one("click", function (e) { // re-enable
				$wpSave.prop("disabled", false)
					.val(saveVal)
					.parent().removeClass("oo-ui-widget-disabled").addClass(classNames);
			}).parent().addClass(classNames);
		}
	});
// Force Preview and Edit-Summary - End

Siehe auch