blob: 028d44d66cc6ffd42528bf498956842c4980f455 [file] [log] [blame]
{
"version": 3,
"sources": ["versions.ts"],
"sourcesContent": ["/*!\n * @license\n * Copyright 2021 The Go Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style\n * license that can be found in the LICENSE file.\n */\n\n/**\n * VersionsController encapsulates event listeners and UI updates\n * for the versions page. As the the expandable sections containing\n * the symbol history for a package are opened and closed it toggles\n * visiblity of the buttons to expand or collapse them. On page load\n * it adds an indicator to the version that matches the version request\n * by the user for the page or the canonical url path.\n */\nclass VersionsController {\n private expand = document.querySelector<HTMLButtonElement>('.js-versionsExpand');\n private collapse = document.querySelector<HTMLButtonElement>('.js-versionsCollapse');\n private details = [...document.querySelectorAll<HTMLDetailsElement>('.js-versionDetails')];\n\n constructor() {\n if (!this.expand?.parentElement) return;\n if (this.details.some(d => d.tagName === 'DETAILS')) {\n this.expand.parentElement.style.display = 'block';\n }\n\n for (const d of this.details) {\n d.addEventListener('click', () => {\n this.updateButtons();\n });\n }\n\n this.expand?.addEventListener('click', () => {\n this.details.map(d => (d.open = true));\n this.updateButtons();\n });\n\n this.collapse?.addEventListener('click', () => {\n this.details.map(d => (d.open = false));\n this.updateButtons();\n });\n\n this.updateButtons();\n this.setCurrent();\n }\n\n /**\n * setCurrent applies the active style to the version dot\n * for the version that matches the canonical URL path.\n */\n private setCurrent() {\n const canonicalPath = document.querySelector<HTMLElement>('.js-canonicalURLPath')?.dataset\n ?.canonicalUrlPath;\n const versionLink = document.querySelector<HTMLElement>(\n `.js-versionLink[href=\"${canonicalPath}\"]`\n );\n if (versionLink) {\n versionLink.style.fontWeight = 'bold';\n }\n }\n\n private updateButtons() {\n setTimeout(() => {\n if (!this.expand || !this.collapse) return;\n let someOpen, someClosed;\n for (const d of this.details) {\n someOpen = someOpen || d.open;\n someClosed = someClosed || !d.open;\n }\n this.expand.style.display = someClosed ? 'inline-block' : 'none';\n this.collapse.style.display = someClosed ? 'none' : 'inline-block';\n });\n }\n}\n\nnew VersionsController();\n"],
"mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAeA,wBAAyB,CAKvB,aAAc,CAJN,YAAS,SAAS,cAAiC,sBACnD,cAAW,SAAS,cAAiC,wBACrD,aAAU,CAAC,GAAG,SAAS,iBAAqC,uBAGlE,GAAI,EAAC,KAAK,QAAQ,cAClB,CAAI,KAAK,QAAQ,KAAK,GAAK,EAAE,UAAY,YACvC,MAAK,OAAO,cAAc,MAAM,QAAU,SAG5C,SAAW,KAAK,MAAK,QACnB,EAAE,iBAAiB,QAAS,IAAM,CAChC,KAAK,kBAIT,KAAK,QAAQ,iBAAiB,QAAS,IAAM,CAC3C,KAAK,QAAQ,IAAI,GAAM,EAAE,KAAO,IAChC,KAAK,kBAGP,KAAK,UAAU,iBAAiB,QAAS,IAAM,CAC7C,KAAK,QAAQ,IAAI,GAAM,EAAE,KAAO,IAChC,KAAK,kBAGP,KAAK,gBACL,KAAK,cAOC,YAAa,CACnB,KAAM,GAAgB,SAAS,cAA2B,yBAAyB,SAC/E,iBACE,EAAc,SAAS,cAC3B,yBAAyB,OAE3B,AAAI,GACF,GAAY,MAAM,WAAa,QAI3B,eAAgB,CACtB,WAAW,IAAM,CACf,GAAI,CAAC,KAAK,QAAU,CAAC,KAAK,SAAU,OACpC,GAAI,GAAU,EACd,SAAW,KAAK,MAAK,QACnB,EAAW,GAAY,EAAE,KACzB,EAAa,GAAc,CAAC,EAAE,KAEhC,KAAK,OAAO,MAAM,QAAU,EAAa,eAAiB,OAC1D,KAAK,SAAS,MAAM,QAAU,EAAa,OAAS,kBAK1D,GAAI",
"names": []
}