MediaWiki:Common.js: Difference between revisions

no edit summary
No edit summary
No edit summary
(24 intermediate revisions by 2 users not shown)
Line 69: Line 69:
         var rows = $('[class^="colortable-"] td b:contains("' + rowContent + '")');
         var rows = $('[class^="colortable-"] td b:contains("' + rowContent + '")');
         rows.each(function () {
         rows.each(function () {
             if ($(this).text() == rowContent) $(this).parent().addClass('tone-4');
             const textContent = $(this).parents('td')[0].textContent.trim();
            if (textContent == rowContent) $(this).parent().addClass('tone-4');
         })
         })
     })
     })
Line 187: Line 188:
     if (getCookie('elwiki-dark-mode') == 'true') $('body').addClass('dark-mode');
     if (getCookie('elwiki-dark-mode') == 'true') $('body').addClass('dark-mode');
     if (getCookie('not-new') == null) $('#dark-mode-switch').addClass('new');
     if (getCookie('not-new') == null) $('#dark-mode-switch').addClass('new');
    // This is pretty cringe, tabs don't load sometimes
    if (!$('.tabber-new.loaded').length) mw.loader.load('https://elwiki.net/wiki/index.php?title=MediaWiki:Gadget-Tabs.js&action=raw&ctype=text/javascript')
}
}


Line 193: Line 197:
     performIE();
     performIE();
     enhancements();
     enhancements();
    // Fix the preview button losing custom script output
    // This is a complete ChatGPT moment, I couldn't be arsed to debug on my own
    $(document).on('DOMNodeInserted', function (event) {
        var element = event.target;
        if ($(element).hasClass('previewnote')) {
            var previewLoaded = $(element).find('.previewloading').length == 0;
            if (previewLoaded && !$(element).hasClass('custom-preview-run')) {
                $(element).addClass('custom-preview-run');
                enhancements();
            }
        }
    });
});
});


Line 483: Line 500:
     }
     }
}
}
//Fix height issue with ads
var HeightFix = $("#mw-content-block");
//$("#mw-related-navigation").css("min-height", HeightFix.height());
$("#mw-related-navigation").attr("style", "min-height: " + HeightFix.height() + "px !important");


//Get Ad Dart Number
//Get Ad Dart Number
Line 493: Line 515:


// Fix scripts literally disappearing when clicking "save changes" in VE
// Fix scripts literally disappearing when clicking "save changes" in VE
var originalSaveComplete = ve.init.mw.ArticleTarget.prototype.saveComplete;
mw.hook('ve.activationComplete').add(function () {
mw.hook('ve.activationComplete').add(function () {
    var originalSaveComplete = ve.init.mw.ArticleTarget.prototype.saveComplete;
     ve.init.mw.ArticleTarget.prototype.saveComplete = function (data) {
     ve.init.mw.ArticleTarget.prototype.saveComplete = function (data) {
         // Calling the original implementation first
         // Calling the original implementation first
Line 502: Line 523:
         doRoundEdges();
         doRoundEdges();
         enhancements();
         enhancements();
    }
});
// Now also fix the preview button
// This is a complete ChatGPT moment, I couldn't be arsed to debug on my own
$(document).on('DOMNodeInserted', function (event) {
    var element = event.target;
    if ($(element).hasClass('previewnote')) {
        var previewLoaded = $(element).find('.previewloading').length == 0;
        if (previewLoaded && !$(element).hasClass('custom-preview-run')) {
            $(element).addClass('custom-preview-run');
            enhancements();
        }
     }
     }
});
});
25,162

edits