MediaWiki:Gadget-Navbox.js

/* JavaScript enhancements for Template:Navbox.



$(document).ready(function {

// Automatically expand navbox when there is only one const navboxes = $(".zw-navbox"); if (navboxes.length == 1) { navboxes.removeClass("mw-collapsed"); }

// If there are multiple navboxes generated by Template:Categories but only one manually curated one, uncollapse that one const curatedNavboxes = navboxes.not(".categories__navboxes .zw-navbox"); if (curatedNavboxes.length == 1) { curatedNavboxes.removeClass("mw-collapsed"); }

// Automatically expand navbox if it is the link target const targetedNavbox = navboxes.filter(":target"); if (targetedNavbox.length == 1) { targetedNavbox.removeClass("mw-collapsed"); }   // When a navbox is clicked, copy its link to the clipboard $(".zw-navbox__header").click(function {       const navboxId =  $(this).parent(".zw-navbox").attr("id");        if (navboxId) {        	const navboxUrl = window.location.origin+window.location.pathname+"#"+navboxId;        	navigator.clipboard.writeText(navboxUrl);        }     }); });