Toggle menu
862
3.8K
30.2K
279.1K
Catglobe Wiki
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MediaWiki:Common.js

MediaWiki interface page
Revision as of 10:33, 30 October 2024 by [email protected] (talk | contribs)

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.
function attachModifiedClickHandler(element) {
    const handlers = $._data(element, 'events')?.click;
    if (handlers && handlers.length > 0) {
        const originalHandler = handlers[0].handler;

        $(element).off('click').on('click', function(event) {
            event.stopPropagation();
            originalHandler.call(this, event);
        });
        $(element).addClass('FixCatTreeClick');
    }
}

addOnLoadHandler(function() {

  const observer = new MutationObserver((mutations) => {
    mutations.forEach((mutation) => {
        const { target } = mutation;

        if (mutation.attributeName === 'class' && target.classList.contains('CategoryTreeToggleHandlerAttached') &&
                !target.classList.contains('FixCatTreeClick')) {
            attachModifiedClickHandler(target);
        }
    });
  });


  observer.observe(document.body, {
    attributes: true,
    attributeFilter: ['class'],
    subtree: true
  });

});