Skip to content

Commit

Permalink
reverted changes to DocumentContent
Browse files Browse the repository at this point in the history
removed bootstrap script
imported boostrap js module to app.ts
  • Loading branch information
Sandravaphilips committed Jul 26, 2023
1 parent 5dbf0d6 commit 182755c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
8 changes: 8 additions & 0 deletions peachjam/js/app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import peachJam from './peachjam';
import * as bootstrap from '../static/bootstrap/dist/js/bootstrap.bundle.js';

declare global {
interface Window {
bootstrap?: any;
}
}
window.bootstrap = bootstrap;

(() => {
peachJam.setup();
Expand Down
10 changes: 5 additions & 5 deletions peachjam/js/components/DocumentContent/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class OffCanvas {
protected offCanvas: any;
body: HTMLElement | null;
constructor (element: HTMLElement) {
this.offCanvas = new (window as { [key: string]: any }).bootstrap.Offcanvas(element);
this.offCanvas = new window.bootstrap.Offcanvas(element);
this.body = element.querySelector('[data-offcanvas-body]');
}

Expand All @@ -36,7 +36,7 @@ class DocumentContent {

constructor (root: HTMLElement) {
this.root = root;
this.documentElement = this.root.querySelector('[data-document-element]');
this.documentElement = this.root.querySelector('.content');

this.setupTabs();
this.setupNav();
Expand All @@ -58,13 +58,13 @@ class DocumentContent {
// If toc setup and mounted successfully, activate toc tab otherwise activate search tab
if (tocSetupOnTab && tocTabTriggerEl) {
tocTabTriggerEl.classList.remove('d-none');
const tocTab = new (window as { [key: string]: any }).bootstrap.Tab(tocTabTriggerEl);
const tocTab = new window.bootstrap.Tab(tocTabTriggerEl);
tocTab.show();
} else if (this.root.getAttribute('data-display-type') === 'pdf' && pdfPreviewsTabTriggerEl) {
const pdfPreviewsTab = new (window as { [key: string]: any }).bootstrap.Tab(pdfPreviewsTabTriggerEl);
const pdfPreviewsTab = new window.bootstrap.Tab(pdfPreviewsTabTriggerEl);
pdfPreviewsTab.show();
} else if (searchTabTriggerEl) {
const searchTab = new (window as { [key: string]: any }).bootstrap.Tab(searchTabTriggerEl);
const searchTab = new window.bootstrap.Tab(searchTabTriggerEl);
searchTab.show();
}
}
Expand Down
1 change: 0 additions & 1 deletion peachjam/templates/peachjam/layouts/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
type="text/css"/>
{% endblock %}
{% block head-js %}
<script defer src="{% static 'bootstrap/dist/js/bootstrap.bundle.js' %}"></script>
<!-- Small script to add the current user agent to the root HTML element -->
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function () {
Expand Down

0 comments on commit 182755c

Please sign in to comment.