mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-23 23:48:48 +02:00
Add dark theme based on browser preference
This commit is contained in:
15
tfjm/static/main.js
Normal file
15
tfjm/static/main.js
Normal file
@ -0,0 +1,15 @@
|
||||
function initModal(target, url, content_id = 'form-content') {
|
||||
document.querySelector('[data-bs-target="#' + target + 'Modal"]').addEventListener('click', () => {
|
||||
let modalBody = document.querySelector("#" + target + "Modal div.modal-body")
|
||||
|
||||
if (!modalBody.innerHTML.trim()) {
|
||||
if (url instanceof Function) url = url()
|
||||
|
||||
fetch(url, {headers: {'CONTENT-ONLY': '1'}})
|
||||
.then(resp => resp.text())
|
||||
.then(resp => new DOMParser().parseFromString(resp, 'text/html'))
|
||||
.then(res => modalBody.innerHTML = res.getElementById(content_id).outerHTML)
|
||||
.then(() => $('.selectpicker').selectpicker()) // TODO Update that when the library will be JQuery-free
|
||||
}
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user