User:Monster Domosed/common.js: Difference between revisions

No edit summary
No edit summary
Line 1: Line 1:
/*mw.loader.load('https://deadlock.wiki/index.php?title=User:Monster_Domosed/Wiki_Redesign.js&action=raw&ctype=text/javascript');*/
/*mw.loader.load('https://deadlock.wiki/index.php?title=User:Monster_Domosed/Wiki_Redesign.js&action=raw&ctype=text/javascript');*/
$(function () {
    function toggleFixedWidth(isEnabled) {
        document.documentElement.classList.toggle('fixed-width-mode', isEnabled);
        mw.cookie.set('fixedWidth', isEnabled ? 'true' : 'false', {
            prefix: '',
            expires: 365 * 86400
        });
    }
    var enabled = mw.cookie.get('fixedWidth', '', 'true') === 'true';
    toggleFixedWidth(enabled);
    var link = mw.util.addPortletLink(
        'p-personal',
        '#',
        'Fixed width',
        'pt-fixedwidth'
    );
    if (!link) return;
    $(link).find('a').on('click', function (e) {
        e.preventDefault();
        var current = document.documentElement.classList.contains('fixed-width-mode');
        toggleFixedWidth(!current);
    });
});


$(function () {
$(function () {