{ | |
"version": 3, | |
"sources": ["unit.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\nimport { CopyToClipboardController } from './clipboard.js';\nimport './toggle-tip.js';\nimport { ExpandableRowsTableController } from './table.js';\n\ndocument\n .querySelectorAll<HTMLTableElement>('.js-expandableTable')\n .forEach(\n el =>\n new ExpandableRowsTableController(\n el,\n document.querySelector<HTMLButtonElement>('.js-expandAllDirectories')\n )\n );\n\n/**\n * Instantiates CopyToClipboardController controller copy buttons\n * on the unit page.\n */\ndocument.querySelectorAll<HTMLButtonElement>('.js-copyToClipboard').forEach(el => {\n new CopyToClipboardController(el);\n});\n\n/**\n * Event handlers for expanding and collapsing the readme section.\n */\nconst readme = document.querySelector('.js-readme');\nconst readmeContent = document.querySelector('.js-readmeContent');\nconst readmeOutline = document.querySelector('.js-readmeOutline');\nconst readmeExpand = document.querySelectorAll('.js-readmeExpand');\nconst readmeCollapse = document.querySelector('.js-readmeCollapse');\nconst mobileNavSelect = document.querySelector<HTMLSelectElement>('.DocNavMobile-select');\nif (readme && readmeContent && readmeOutline && readmeExpand.length && readmeCollapse) {\n if (window.location.hash.includes('readme')) {\n readme.classList.add('UnitReadme--expanded');\n }\n mobileNavSelect?.addEventListener('change', e => {\n if ((e.target as HTMLSelectElement).value.startsWith('readme-')) {\n readme.classList.add('UnitReadme--expanded');\n }\n });\n readmeExpand.forEach(el =>\n el.addEventListener('click', e => {\n e.preventDefault();\n readme.classList.add('UnitReadme--expanded');\n readme.scrollIntoView();\n })\n );\n readmeCollapse.addEventListener('click', e => {\n e.preventDefault();\n readme.classList.remove('UnitReadme--expanded');\n if (readmeExpand[1]) {\n readmeExpand[1].scrollIntoView({ block: 'center' });\n }\n });\n readmeContent.addEventListener('keyup', () => {\n readme.classList.add('UnitReadme--expanded');\n });\n readmeContent.addEventListener('click', () => {\n readme.classList.add('UnitReadme--expanded');\n });\n readmeOutline.addEventListener('click', () => {\n readme.classList.add('UnitReadme--expanded');\n });\n document.addEventListener('keydown', e => {\n if ((e.ctrlKey || e.metaKey) && e.key === 'f') {\n readme.classList.add('UnitReadme--expanded');\n }\n });\n}\n\n/**\n * Expand details items that are focused. This will expand\n * deprecated symbols when they are navigated to from the index\n * or a direct link.\n */\nfor (const a of document.querySelectorAll<HTMLAnchorElement>('.js-deprecatedTagLink')) {\n const hash = new URL(a.href).hash;\n const heading = document.querySelector(hash);\n const details = heading?.parentElement?.parentElement as HTMLDetailsElement | null;\n if (details) {\n a.addEventListener('click', () => {\n details.open = true;\n });\n if (location.hash === hash) {\n details.open = true;\n }\n }\n}\n\n/**\n * Disable unavailable sections in navigation dropdown on mobile.\n */\nconst readmeOption = document.querySelector('.js-readmeOption');\nif (readmeOption && !readme) {\n readmeOption.setAttribute('disabled', 'true');\n}\nconst unitDirectories = document.querySelector('.js-unitDirectories');\nconst directoriesOption = document.querySelector('.js-directoriesOption');\nif (!unitDirectories && directoriesOption) {\n directoriesOption.setAttribute('disabled', 'true');\n}\ndocument.querySelectorAll('.js-buildContextSelect').forEach(el => {\n el.addEventListener('change', e => {\n window.location.search = `?GOOS=${(e.target as HTMLSelectElement).value}`;\n });\n});\n\n/**\n * Adds double click event listener to the header that will\n * scroll the page back to the top.\n */\nconst unitHeader = document.querySelector('.js-unitHeader');\nunitHeader?.addEventListener('dblclick', e => {\n const target = e.target as HTMLElement;\n if (\n target === unitHeader.firstElementChild &&\n unitHeader.classList.contains('UnitHeader--sticky')\n ) {\n window.getSelection()?.removeAllRanges();\n window.scrollTo({ top: 0 });\n }\n});\n\n/**\n * Calculates dynamic heights values for header elements to support\n * variable size sticky positioned elements in the header so that banners\n * and breadcumbs may overflow to multiple lines.\n */\nconst header = document.querySelector<HTMLElement>('.UnitHeader');\nconst breadcrumbs = header?.querySelector<HTMLElement>('.UnitHeader-breadcrumbs');\nconst content = header?.querySelector<HTMLElement>('.UnitHeader-content');\nconst calcSize = () => {\n document.documentElement.style.removeProperty('--full-header-height');\n document.documentElement.style.setProperty(\n '--full-header-height',\n `${(header?.getBoundingClientRect().height ?? 0) / 16}rem`\n );\n document.documentElement.style.setProperty('--banner-height', `0rem`);\n document.documentElement.style.setProperty(\n '--breadcrumbs-height',\n `${(breadcrumbs?.getBoundingClientRect().height ?? 0) / 16}rem`\n );\n document.documentElement.style.setProperty(\n '--content-height',\n `${(content?.getBoundingClientRect().height ?? 0) / 16}rem`\n );\n};\ncalcSize();\nwindow.addEventListener('resize', function () {\n calcSize();\n});\n\n/**\n * Observer for header that applies classnames to transition\n * header elements into their sticky position and back into the\n * full size position.\n */\nconst observer = new IntersectionObserver(\n ([e]) => {\n if (e.intersectionRatio < 1) {\n unitHeader?.classList.add('UnitHeader--sticky');\n unitHeader?.classList.remove('UnitHeader--full');\n } else {\n unitHeader?.classList.remove('UnitHeader--sticky');\n unitHeader?.classList.add('UnitHeader--full');\n calcSize();\n }\n },\n { threshold: 1.0, rootMargin: '40px' }\n);\n\nconst headerSentinel = document.querySelector('.js-headerSentinel');\nif (headerSentinel) {\n observer.observe(headerSentinel);\n}\n"], | |
"mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAOA,2DACA,wBACA,2DAEA,SACG,iBAAmC,uBACnC,QACC,GACE,GAAI,GACF,EACA,SAAS,cAAiC,8BAQlD,SAAS,iBAAoC,uBAAuB,QAAQ,GAAM,CAChF,GAAI,GAA0B,KAMhC,KAAM,GAAS,SAAS,cAAc,cAChC,EAAgB,SAAS,cAAc,qBACvC,EAAgB,SAAS,cAAc,qBACvC,EAAe,SAAS,iBAAiB,oBACzC,EAAiB,SAAS,cAAc,sBACxC,EAAkB,SAAS,cAAiC,wBAClE,AAAI,GAAU,GAAiB,GAAiB,EAAa,QAAU,GACjE,QAAO,SAAS,KAAK,SAAS,WAChC,EAAO,UAAU,IAAI,wBAEvB,GAAiB,iBAAiB,SAAU,GAAK,CAC/C,AAAK,EAAE,OAA6B,MAAM,W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