MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */ function viewSwitching($rootElement) { var showButtonText = $rootElement.data("vs-showtext") || 'More'; var hideButtonText = $rootElement.data("vs-hidetext") || 'Less'; var toSkip = $rootElement.find(".vsSwitcher").find("*"); var elemsToHide = $rootElement.find(".vsHide").not(toSkip); var elemsToShow = $rootElement.find(".vsShow").not(toSkip); // Find the element to place the toggle button in. var toggleElement = $rootElement.find(".vsToggleElement").not(toSkip).first; // The toggleElement becomes clickable in its entirety, but // we need to prevent this if a contained link is clicked instead. toggleElement.children("a").on("click", function (e) {       if (e && e.stopPropagation)            e.stopPropagation;        else            window.event.cancelBubble = true;    }); // Add the toggle button. var toggleButton = $(''); $(' ').addClass('NavToggle').append(toggleButton).prependTo(toggleElement); // Determine the visibility toggle category (for the links in the bar on the left). var toggleCategory = "others"; var classNames = $rootElement.attr("class").split(/\s+/); for (var i = 0; i < classNames.length; ++i) { var className = classNames[i].split('-'); if (className[0] == 'vsToggleCategory') { toggleCategory = className[1]; }   }    // Register the visibility toggle. toggleElement.css("cursor", "pointer"); toggleElement.on("click", VisibilityToggles.register(toggleCategory, function show { toggleButton.html(hideButtonText); elemsToShow.hide; showAll(elemsToHide); },       function hide { toggleButton.html(showButtonText); showAll(elemsToShow); elemsToHide.hide; })); }