From 684731638a64ebcc472638a8873609adc6b801da Mon Sep 17 00:00:00 2001 From: Davinder Singh Date: Mon, 4 Nov 2024 12:14:52 +0000 Subject: [PATCH] Merge pull request #21195 from overleaf/ds-adding-tooltips-trigger-bs5 BS5 Migration - Adding tooltips trigger for BS5 styling GitOrigin-RevId: 0a446af5bc72f28ec8e2512fd4b248a6b78221a2 --- services/web/frontend/js/bootstrap-3.ts | 4 +--- services/web/frontend/js/bootstrap-5.ts | 3 ++- .../web/frontend/js/features/tooltip/index-bs3.ts | 2 ++ .../web/frontend/js/features/tooltip/index-bs5.ts | 15 +++++++++++++++ 4 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 services/web/frontend/js/features/tooltip/index-bs3.ts create mode 100644 services/web/frontend/js/features/tooltip/index-bs5.ts diff --git a/services/web/frontend/js/bootstrap-3.ts b/services/web/frontend/js/bootstrap-3.ts index 68d04baafe..2c7b3b8214 100644 --- a/services/web/frontend/js/bootstrap-3.ts +++ b/services/web/frontend/js/bootstrap-3.ts @@ -1,6 +1,4 @@ import 'bootstrap' import './features/contact-form' import './features/bookmarkable-tab/index' - -$('[data-ol-lang-selector-tooltip]').tooltip({ trigger: 'hover' }) -$('[data-toggle="tooltip"]').tooltip() +import './features/tooltip/index-bs3' diff --git a/services/web/frontend/js/bootstrap-5.ts b/services/web/frontend/js/bootstrap-5.ts index a4132ec789..b9dc3d8679 100644 --- a/services/web/frontend/js/bootstrap-5.ts +++ b/services/web/frontend/js/bootstrap-5.ts @@ -1,2 +1,3 @@ -import 'bootstrap-5' import './features/bookmarkable-tab/index-bs5' +import './features/tooltip/index-bs5' +import 'bootstrap-5' diff --git a/services/web/frontend/js/features/tooltip/index-bs3.ts b/services/web/frontend/js/features/tooltip/index-bs3.ts new file mode 100644 index 0000000000..e71965bcd1 --- /dev/null +++ b/services/web/frontend/js/features/tooltip/index-bs3.ts @@ -0,0 +1,2 @@ +$('[data-ol-lang-selector-tooltip]').tooltip({ trigger: 'hover' }) +$('[data-toggle="tooltip"]').tooltip() diff --git a/services/web/frontend/js/features/tooltip/index-bs5.ts b/services/web/frontend/js/features/tooltip/index-bs5.ts new file mode 100644 index 0000000000..ba40b16daf --- /dev/null +++ b/services/web/frontend/js/features/tooltip/index-bs5.ts @@ -0,0 +1,15 @@ +import { Tooltip } from 'bootstrap-5' + +const footerLanguageElement = document.querySelector( + '[data-ol-lang-selector-tooltip]' +) as Element + +const allTooltips = document.querySelectorAll('[data-bs-toggle="tooltip"]') + +// eslint-disable-next-line no-unused-vars +const footLangTooltip = new Tooltip(footerLanguageElement) + +allTooltips.forEach(element => { + // eslint-disable-next-line no-unused-vars + const tooltip = new Tooltip(element) +})