MediaWiki:Common.js: Difference between revisions

From Heureka Wiki
Jump to navigation Jump to search
New page: →Any JavaScript here will be loaded for all users on every page load.: var isViewingMainPage = (/^MediaWiki(\/.+)? - MediaWiki$/.test(document.title)); if (isViewingMainPage) { docu...
 
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on every page load. */


var isViewingMainPage = (/^MediaWiki(\/.+)? - MediaWiki$/.test(document.title));
//var isViewingMainPage = (/^MediaWiki(\/.+)? - MediaWiki$/.test(document.title));
if (isViewingMainPage) {
//if (isViewingMainPage) {
  document.write('<style type="text/css">/*<![CDATA[*/ #lastmod, #siteSub, h1.firstHeading { display: none !important; } #content { padding-top: 1em; }/*]]>*/</style>');
//  document.write('<style type="text/css">/*<![CDATA[*/ #lastmod, #siteSub, h1.firstHeading { display: none !important; } #content { padding-top: 1em; }/*]]>*/</style>');
}
//}


/* Force preview for anons */
// Force Preview and Edit-Summary - Start
/* by Marc Mongenet, 2006, fr.wikipedia */
// Force preview is JavaScript that prevents specified individuals or groups from saving a wiki page before they preview it at least once.
// https://www.mediawiki.org/wiki/Manual:Force_preview
//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


function forcePreview() {
  if (wgUserName != null || wgAction != "edit") return;
  saveButton = document.getElementById("wpSave");
  if (!saveButton) return;
  saveButton.disabled = true;
  saveButton.value = "Save page (use preview first)";
  saveButton.style.fontWeight = "normal";
  document.getElementById("wpPreview").style.fontWeight = "bold";
}
addOnloadHook(forcePreview);
/* End of forcePreview */
/** includePage ************
* force the loading of another JavaScript file
*
* Maintainer: [[Commons:User:Dschwen]]
*/
function includePage( name )
{
document.write('<script type="text/javascript" src="' + wgScript + '?title='
  + name
  + '&action=raw&ctype=text/javascript"><\/script>'
);
}
/* End of includePage */




Line 43: Line 39:
// TODO: migrate to JSConfig
// TODO: migrate to JSConfig
// var load_extratabs = true;
// var load_extratabs = true;
var load_edittools = true;
//var load_edittools = true;


// extra drop down menu on editing for adding special characters
// extra drop down menu on editing for adding special characters
includePage( 'MediaWiki:Edittools.js' );
// includePage( 'MediaWiki:Edittools.js' );


//Editpage scripts
//Editpage scripts
if (wgAction=='edit' || wgAction == 'submit')
//if (wgAction=='edit' || wgAction == 'submit')
  importScript('MediaWiki:Editpage.js')
//  importScript('MediaWiki:Editpage.js')


/* End of extra pages */
/* End of extra pages */

Latest revision as of 13:53, 25 January 2024

/* Any JavaScript here will be loaded for all users on every page load. */

//var isViewingMainPage = (/^MediaWiki(\/.+)? - MediaWiki$/.test(document.title));
//if (isViewingMainPage) {
//  document.write('<style type="text/css">/*<![CDATA[*/ #lastmod, #siteSub, h1.firstHeading { display: none !important; } #content { padding-top: 1em; }/*]]>*/</style>');
//}

// Force Preview and Edit-Summary - Start
// Force preview is JavaScript that prevents specified individuals or groups from saving a wiki page before they preview it at least once.
// https://www.mediawiki.org/wiki/Manual:Force_preview
//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



/* Including extra .js pages */ 

// switches for scripts
// TODO: migrate to JSConfig
// var load_extratabs = true;
//var load_edittools = true;

// extra drop down menu on editing for adding special characters
// includePage( 'MediaWiki:Edittools.js' );

//Editpage scripts
//if (wgAction=='edit' || wgAction == 'submit')
//  importScript('MediaWiki:Editpage.js')

/* End of extra pages */