main.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  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');
  22. if (searchInput) {
  23. const searchWidget = new SearchWidget(searchInput as HTMLInputElement);
  24. const searchButton = document.querySelector('button.search-icon') as HTMLButtonElement;
  25. searchButton.addEventListener('click', () => searchWidget.toggleActive());
  26. }
  27. initTabs();
  28. }, false);