Difference between revisions of "MediaWiki:Common.js"
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...) |
|||
(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>'); | |
− | } | + | //} |
− | / | + | // 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 | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
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') | |
/* End of extra pages */ | /* End of extra pages */ |
Latest revision as of 14: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 */