2022-10-28 22:56:04 +02:00
|
|
|
/* eslint-disable no-unused-vars */
|
|
|
|
const { protocol, host } = window.location;
|
2022-10-28 22:40:02 +02:00
|
|
|
|
2023-08-02 15:34:41 +02:00
|
|
|
let timeout = null;
|
|
|
|
|
2022-10-28 22:56:04 +02:00
|
|
|
/**
|
2022-03-04 16:33:45 +01:00
|
|
|
* Fonction permettant d'afficher un message dans un toastr
|
|
|
|
* @param {String} message
|
|
|
|
*/
|
2022-10-28 22:40:02 +02:00
|
|
|
function showToastr(message, success = false) {
|
2022-10-28 22:56:04 +02:00
|
|
|
const x = document.getElementById("toastr");
|
|
|
|
if (message) {
|
2022-03-01 16:09:46 +01:00
|
|
|
x.getElementsByTagName("SPAN")[0].innerHTML = message;
|
|
|
|
}
|
|
|
|
|
2023-08-02 15:34:41 +02:00
|
|
|
if (timeout) {
|
|
|
|
clearTimeout(timeout);
|
|
|
|
x.classList.remove("show");
|
|
|
|
}
|
|
|
|
|
|
|
|
x.classList.remove("success");
|
|
|
|
x.classList.remove("error");
|
2022-10-28 22:56:04 +02:00
|
|
|
if (success) {
|
2023-08-02 15:34:41 +02:00
|
|
|
x.classList.add("success");
|
|
|
|
} else {
|
|
|
|
x.classList.add("error");
|
2022-04-08 15:03:01 +02:00
|
|
|
}
|
2023-08-02 15:34:41 +02:00
|
|
|
|
|
|
|
x.classList.add("show");
|
|
|
|
|
|
|
|
timeout = setTimeout(() => {
|
|
|
|
x.classList.remove("show");
|
2022-10-28 22:56:04 +02:00
|
|
|
}, 3000);
|
|
|
|
}
|
2022-03-01 16:09:46 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Fonction permettant de masquer le toastr
|
|
|
|
*/
|
|
|
|
function hideToastr() {
|
2022-10-28 22:56:04 +02:00
|
|
|
const x = document.getElementById("toastr");
|
2022-03-01 16:09:46 +01:00
|
|
|
|
|
|
|
x.className = x.className.replace("show", "");
|
|
|
|
x.getElementsByTagName("SPAN")[0].innerHTML = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ensemble d'actions effectuées au chargement de la page
|
|
|
|
*/
|
2022-10-28 22:56:04 +02:00
|
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
|
|
const $navbarBurgers = Array.prototype.slice.call(
|
|
|
|
document.querySelectorAll(".navbar-burger"),
|
|
|
|
0
|
|
|
|
);
|
2022-03-01 16:09:46 +01:00
|
|
|
if ($navbarBurgers.length > 0) {
|
2022-10-28 22:56:04 +02:00
|
|
|
$navbarBurgers.forEach((el) => {
|
|
|
|
el.addEventListener("click", () => {
|
|
|
|
const { target } = el.dataset;
|
2022-03-01 16:09:46 +01:00
|
|
|
const $target = document.getElementById(target);
|
|
|
|
|
2022-10-28 22:56:04 +02:00
|
|
|
el.classList.toggle("is-active");
|
|
|
|
$target.classList.toggle("is-active");
|
2022-03-01 16:09:46 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2022-10-28 22:56:04 +02:00
|
|
|
});
|