From 82eabdadbd2179c7cf107f3ca150a066f8d7e4fd Mon Sep 17 00:00:00 2001 From: Michael Wisely <108433848+michael-wisely-gravwell@users.noreply.github.com> Date: Wed, 10 Jan 2024 14:56:26 -0700 Subject: [PATCH] Make bootstrap globally available (#1639) * Make bootstrap globally available * Include docs about bootstrap programmatic API --- docs/community/topics/bootstrap.rst | 1 + src/pydata_sphinx_theme/assets/scripts/bootstrap.js | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/community/topics/bootstrap.rst b/docs/community/topics/bootstrap.rst index 6bf4e540f..b5b9947cc 100644 --- a/docs/community/topics/bootstrap.rst +++ b/docs/community/topics/bootstrap.rst @@ -60,3 +60,4 @@ JavaScript ^^^^^^^^^^ - Data attributes for all JavaScript plugins are now namespaced to help distinguish Bootstrap functionality from third parties and your code. For example, we use ``data-bs-toggle`` instead of ``data-toggle``. +- Bootstrap's `Programmatic API `_, ``bootstrap``, is also available. This API can be useful for initializing opt-in components that are not initialized by default such as `Popovers `_. diff --git a/src/pydata_sphinx_theme/assets/scripts/bootstrap.js b/src/pydata_sphinx_theme/assets/scripts/bootstrap.js index ec34c0d4e..3f381bb0e 100644 --- a/src/pydata_sphinx_theme/assets/scripts/bootstrap.js +++ b/src/pydata_sphinx_theme/assets/scripts/bootstrap.js @@ -1,6 +1,6 @@ // Import and setup functions to control Bootstrap's behavior. import "@popperjs/core"; -import { Tooltip } from "bootstrap"; +import * as bootstrap from "bootstrap"; import { documentReady } from "./mixin"; import "../styles/bootstrap.scss"; @@ -17,7 +17,9 @@ function TriggerTooltip() { document.querySelectorAll('[data-bs-toggle="tooltip"]') ); tooltipTriggerList.map(function (tooltipTriggerEl) { - return new Tooltip(tooltipTriggerEl, { delay: { show: 500, hide: 100 } }); + return new bootstrap.Tooltip(tooltipTriggerEl, { + delay: { show: 500, hide: 100 }, + }); }); } @@ -54,3 +56,5 @@ function showBackToTop() { documentReady(TriggerTooltip); documentReady(backToTop); documentReady(showBackToTop); + +window.bootstrap = bootstrap;