blob: 113ad5a771e27f8a515a2b5f7f888c61c135b9ff [file] [log] [blame]
{
"version": 3,
"sources": ["search.ts"],
"sourcesContent": ["/**\n * @license\n * Copyright 2020 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\nconst headerHeight = 3.5;\n\n// Append a div above the site header to use for the sticky header transition.\nconst siteHeader = document.querySelector('.js-siteHeader');\nconst headerSentinel = document.createElement('div');\nsiteHeader?.prepend(headerSentinel);\n\n/**\n * headerObserver watches the headerSentinel. When the headerSentinel is out of view a\n * callback function transitions the search results header in to the sticky position.\n */\nconst headerObserver = new IntersectionObserver(\n ([e]) => {\n if (e.intersectionRatio < 1) {\n for (const x of document.querySelectorAll('[class^=\"SearchResults-header\"')) {\n x.setAttribute('data-fixed', 'true');\n }\n } else {\n for (const x of document.querySelectorAll('[class^=\"SearchResults-header\"')) {\n x.removeAttribute('data-fixed');\n }\n }\n },\n { threshold: 1, rootMargin: `${headerHeight * 16 * 3}px` }\n);\nheaderObserver.observe(headerSentinel);\n\n// Add an event listener to scroll to the top of the page when the whitespace on the\n// header is double clicked.\nconst searchHeader = document.querySelector('.js-searchHeader');\nsearchHeader?.addEventListener('dblclick', e => {\n const target = e.target;\n if (target === searchHeader || target === searchHeader.lastElementChild) {\n window.getSelection()?.removeAllRanges();\n window.scrollTo({ top: 0, behavior: 'smooth' });\n }\n});\n\nexport {};\n"],
"mappings": "AAUA,IAAMA,EAAa,SAAS,cAAc,gBAAgB,EACpDC,EAAiB,SAAS,cAAc,KAAK,EACnDD,GAAA,MAAAA,EAAY,QAAQC,GAMpB,IAAMC,EAAiB,IAAI,qBACzB,CAAC,CAACC,CAAC,IAAM,CACP,GAAIA,EAAE,kBAAoB,EACxB,QAAWC,KAAK,SAAS,iBAAiB,gCAAgC,EACxEA,EAAE,aAAa,aAAc,MAAM,MAGrC,SAAWA,KAAK,SAAS,iBAAiB,gCAAgC,EACxEA,EAAE,gBAAgB,YAAY,CAGpC,EACA,CAAE,UAAW,EAAG,WAAY,GAAG,IAAe,GAAK,KAAM,CAC3D,EACAF,EAAe,QAAQD,CAAc,EAIrC,IAAMI,EAAe,SAAS,cAAc,kBAAkB,EAC9DA,GAAA,MAAAA,EAAc,iBAAiB,WAAYF,GAAK,CArChD,IAAAG,EAsCE,IAAMC,EAASJ,EAAE,QACbI,IAAWF,GAAgBE,IAAWF,EAAa,qBACrDC,EAAA,OAAO,aAAa,IAApB,MAAAA,EAAuB,kBACvB,OAAO,SAAS,CAAE,IAAK,EAAG,SAAU,QAAS,CAAC,EAElD",
"names": ["siteHeader", "headerSentinel", "headerObserver", "e", "x", "searchHeader", "_a", "target"]
}