MediaWiki:Common.js

From OtherX
Revision as of 19:44, 24 December 2023 by OtherXAdmin (talk | contribs)
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* Restrict zooming out beyond the initial page size on mobile */
var initialScale = 1;

document.addEventListener('wheel', function(e) {
    if (e.deltaY < 0 && window.innerWidth <= window.screen.width) {
        /* Zoom in */
        initialScale *= 1.1;
    } else if (e.deltaY > 0 && window.innerWidth <= window.screen.width && initialScale > 1) {
        /* Zoom out */
        initialScale /= 1.1;
    }

    updateViewport();
});

function updateViewport() {
    var viewport = document.querySelector("meta[name=viewport]");
    if (viewport) {
        viewport.content = "width=device-width, initial-scale=" + initialScale + ", maximum-scale=1, user-scalable=yes";
    }
}