Difference between revisions of "MediaWiki:Common.js"
Jump to navigation
Jump to search
m (Commented out editpage-scripts that was not working properly) |
(Updated the Force Preview-script.) |
||
Line 9: | Line 9: | ||
// Force preview is JavaScript that prevents specified individuals or groups from saving a wiki page before they preview it at least once. | // 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 | // https://www.mediawiki.org/wiki/Manual:Force_preview | ||
− | if (mw.config.get("wgAction") === "edit") | + | //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 | // Force Preview and Edit-Summary - End | ||
Revision as of 11:39, 24 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 */