MediaWiki:Common.js: Difference between revisions
Technician (talk | contribs) (Created page with "→Any JavaScript here will be loaded for all users on every page load.: $(document).ready(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");...") |
Technician (talk | contribs) No edit summary Tag: Reverted |
||
Line 11: | Line 11: | ||
// subtract the left margin from the computed value | // subtract the left margin from the computed value | ||
mutNode[0].style.left = "calc("+ eleLeft + " - "+ marginLeft + ")"; | mutNode[0].style.left = "calc("+ eleLeft + " - "+ marginLeft + ")"; | ||
alert(mutNode[0].style.left); | |||
} | } | ||
}; | }; |
Revision as of 18:48, 13 July 2023
/* Any JavaScript here will be loaded for all users on every page load. */ $(document).ready(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 + ")"; alert(mutNode[0].style.left); } }; var observer = new MutationObserver(callback); observer.observe(body, { childList: true }); });