blob: 38c4bb48e90caebaf57e0d0fcf7b1712170ba407 [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 */\nexport class 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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