MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 19: | Line 19: | ||
// Related to centering the content; fix for popups. | // Related to centering the content; fix for popups. | ||
(function () { | |||
var body = document.getElementsByTagName("body")[0]; | var body = document.getElementsByTagName("body")[0]; | ||
var callback = function(mutList, _obs) { | var callback = function(mutList, _obs) { | ||
Line 33: | Line 33: | ||
var observer = new MutationObserver(callback); | var observer = new MutationObserver(callback); | ||
observer.observe(body, { childList: true }); | observer.observe(body, { childList: true }); | ||
}); | })(); |
Revision as of 07:09, 2 August 2023
/* Any JavaScript here will be loaded for all users on every page load. */
// Update this to `SELECT MAX(page_id) FROM page` on August 3rd
// Don't forget the same in Mobile.js
var launchDayMaxPageId = 5000;
if (false && !mw.config.get("wgIsMainPage") &&
mw.config.get("wgNamespaceNumber") == 0 &&
mw.config.get("wgArticleId") <= launchDayMaxPageId
) {
var notice = document.getElementById("siteNotice");
notice.style.border = "2px solid var(--bdr-hl)";
notice.style.padding = "5px";
notice.style.fontSize = "1.2em";
notice.innerHTML =
"<b>[Test] Warning: This page was created during Early Access. " +
"It may not be up to date with the release version.</b>";
}
// Related to centering the content; fix for popups.
(function () {
var body = document.getElementsByTagName("body")[0];
var callback = function(mutList, _obs) {
var mut = mutList[0];
var mutNode = mut.addedNodes;
if (mutNode.length !== 0 && mutNode[0].classList.contains("mwe-popups")) {
var eleLeft = mutNode[0].style.left;
var marginLeft = window.getComputedStyle(body).getPropertyValue("margin-left");
// subtract the left margin from the computed value
mutNode[0].style.left = "calc("+ eleLeft + " - "+ marginLeft + ")";
}
};
var observer = new MutationObserver(callback);
observer.observe(body, { childList: true });
})();