main.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. // import '@webcomponents/custom-elements';
  2. import { SearchWidget } from './search-widget';
  3. import { initTabs } from './tabs';
  4. import { TocHighlighter } from './toc-highlighter';
  5. // tslint:disable-next-line
  6. require('../styles/main.scss');
  7. document.addEventListener('DOMContentLoaded', () => {
  8. const topBar = document.querySelector('.top-bar');
  9. if (topBar) {
  10. window.addEventListener('scroll', (e) => {
  11. if (window.scrollY === 0) {
  12. topBar.classList.remove('floating');
  13. } else {
  14. topBar.classList.add('floating');
  15. }
  16. });
  17. }
  18. const toc = document.querySelector('#TableOfContents') as HTMLDivElement;
  19. const tocHighlighter = new TocHighlighter(toc);
  20. tocHighlighter.highlight();
  21. const searchInput = document.querySelector('#searchInput') as HTMLInputElement;
  22. const searchWidget = new SearchWidget(searchInput);
  23. const searchButton = document.querySelector('button.search-icon') as HTMLButtonElement;
  24. searchButton.addEventListener('click', () => searchWidget.toggleActive());
  25. initTabs();
  26. }, false);