index-bs5.ts 908 B

12345678910111213141516171819202122232425262728293031
  1. import { Tooltip } from 'bootstrap-5'
  2. const footerLanguageElement = document.querySelector(
  3. '[data-ol-lang-selector-tooltip]'
  4. ) as Element
  5. const allTooltips = document.querySelectorAll('[data-bs-toggle="tooltip"]')
  6. const possibleTooltips = document.querySelectorAll(
  7. '[data-bs-toggle="tooltip-if-needed"]'
  8. )
  9. // eslint-disable-next-line no-unused-vars
  10. const footLangTooltip = new Tooltip(footerLanguageElement)
  11. allTooltips.forEach(element => {
  12. // eslint-disable-next-line no-unused-vars
  13. const tooltip = new Tooltip(element)
  14. })
  15. possibleTooltips.forEach(element => {
  16. // put data-bs-toggle="tooltip-if-needed" on .badge-content
  17. // then tooltip is only shown if .badge is clipped due to max-width
  18. if (
  19. element.parentElement &&
  20. element.scrollWidth > element.parentElement?.scrollWidth
  21. ) {
  22. // eslint-disable-next-line no-unused-vars
  23. const tooltip = new Tooltip(element)
  24. }
  25. })