blob: 7b970b4491f41268e874a3be5bc0ef4747df02f6 [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": "AAAA,AAOA,GAAM,GAAe,IAGf,EAAa,SAAS,cAAc,kBACpC,EAAiB,SAAS,cAAc,OAC9C,WAAY,QAAQ,GAMpB,GAAM,GAAiB,GAAI,sBACzB,CAAC,CAAC,KAAO,CACP,GAAI,EAAE,kBAAoB,EACxB,OAAW,KAAK,UAAS,iBAAiB,kCACxC,EAAE,aAAa,aAAc,YAG/B,QAAW,KAAK,UAAS,iBAAiB,kCACxC,EAAE,gBAAgB,eAIxB,CAAE,UAAW,EAAG,WAAY,GAAG,EAAe,GAAK,QAErD,EAAe,QAAQ,GAIvB,GAAM,GAAe,SAAS,cAAc,oBAC5C,WAAc,iBAAiB,WAAY,GAAK,CArChD,MAsCE,GAAM,GAAS,EAAE,OACjB,AAAI,KAAW,GAAgB,IAAW,EAAa,mBACrD,WAAO,iBAAP,QAAuB,kBACvB,OAAO,SAAS,CAAE,IAAK,EAAG,SAAU",
"names": []
}