2020-06-09 15:44:20 +02:00
|
|
|
/* global bootstrap: false */
|
|
|
|
|
2022-04-12 17:07:25 +02:00
|
|
|
(() => {
|
2020-06-09 15:44:20 +02:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
// Tooltip and popover demos
|
|
|
|
document.querySelectorAll('.tooltip-demo')
|
2022-04-12 17:07:25 +02:00
|
|
|
.forEach(tooltip => {
|
2020-06-09 15:44:20 +02:00
|
|
|
new bootstrap.Tooltip(tooltip, {
|
|
|
|
selector: '[data-bs-toggle="tooltip"]'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
document.querySelectorAll('[data-bs-toggle="popover"]')
|
2022-04-12 17:07:25 +02:00
|
|
|
.forEach(popover => {
|
2020-06-09 15:44:20 +02:00
|
|
|
new bootstrap.Popover(popover)
|
|
|
|
})
|
|
|
|
|
|
|
|
document.querySelectorAll('.toast')
|
2022-04-12 17:07:25 +02:00
|
|
|
.forEach(toastNode => {
|
|
|
|
const toast = new bootstrap.Toast(toastNode, {
|
2020-06-09 15:44:20 +02:00
|
|
|
autohide: false
|
|
|
|
})
|
|
|
|
|
|
|
|
toast.show()
|
|
|
|
})
|
|
|
|
|
2021-05-18 07:31:15 +02:00
|
|
|
// Disable empty links and submit buttons
|
|
|
|
document.querySelectorAll('[href="#"], [type="submit"]')
|
2022-04-12 17:07:25 +02:00
|
|
|
.forEach(link => {
|
|
|
|
link.addEventListener('click', event => {
|
2020-12-04 15:00:21 +01:00
|
|
|
event.preventDefault()
|
2020-06-09 15:44:20 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
function setActiveItem() {
|
2022-04-12 17:07:25 +02:00
|
|
|
const { hash } = window.location
|
2020-06-09 15:44:20 +02:00
|
|
|
|
|
|
|
if (hash === '') {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-04-12 17:07:25 +02:00
|
|
|
const link = document.querySelector(`.bd-aside a[href="${hash}"]`)
|
2021-05-18 07:31:15 +02:00
|
|
|
|
|
|
|
if (!link) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-04-12 17:07:25 +02:00
|
|
|
const active = document.querySelector('.bd-aside .active')
|
|
|
|
const parent = link.parentNode.parentNode.previousElementSibling
|
2020-06-09 15:44:20 +02:00
|
|
|
|
|
|
|
link.classList.add('active')
|
|
|
|
|
|
|
|
if (parent.classList.contains('collapsed')) {
|
|
|
|
parent.click()
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!active) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-04-12 17:07:25 +02:00
|
|
|
const expanded = active.parentNode.parentNode.previousElementSibling
|
2020-06-09 15:44:20 +02:00
|
|
|
|
|
|
|
active.classList.remove('active')
|
|
|
|
|
|
|
|
if (expanded && parent !== expanded) {
|
|
|
|
expanded.click()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setActiveItem()
|
|
|
|
window.addEventListener('hashchange', setActiveItem)
|
|
|
|
})()
|