Skip to content

Commit

Permalink
Make bootstrap globally available (#1639)
Browse files Browse the repository at this point in the history
* Make bootstrap globally available

* Include docs about bootstrap programmatic API
  • Loading branch information
michael-wisely-gravwell authored Jan 10, 2024
1 parent ea92bd1 commit 82eabda
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/community/topics/bootstrap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://getbootstrap.com/docs/5.0/getting-started/javascript/#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 <https://getbootstrap.com/docs/5.0/components/popovers/#overview>`_.
8 changes: 6 additions & 2 deletions src/pydata_sphinx_theme/assets/scripts/bootstrap.js
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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 },
});
});
}

Expand Down Expand Up @@ -54,3 +56,5 @@ function showBackToTop() {
documentReady(TriggerTooltip);
documentReady(backToTop);
documentReady(showBackToTop);

window.bootstrap = bootstrap;

0 comments on commit 82eabda

Please sign in to comment.