index-website-static/assets/js/onload.js

55 lines
1.2 KiB
JavaScript
Raw Normal View History

2025-12-23 17:29:27 +01:00
import { headerToggle, headerScrollVisibility } from './header.js';
2025-12-23 19:17:52 +01:00
import { copyLink } from './share.js';
2025-12-24 16:00:47 +01:00
import { btnSticky } from './mobile-sticky.js';
const responsiveMedium = 1080;
const responsiveSmall = 768;
2025-12-23 17:29:27 +01:00
// TEMP, with includeHTML() --------------------------------------
2025-12-16 18:00:01 +01:00
2025-12-19 12:33:59 +01:00
window.onload = async function () {
2025-12-23 17:29:27 +01:00
await runIncludeHTML();
initAfterLoad();
2025-12-16 18:00:01 +01:00
};
2025-12-19 12:33:59 +01:00
function runIncludeHTML() {
if (typeof includeHTML === "function") {
const result = includeHTML();
if (result instanceof Promise) {
return result;
}
}
return Promise.resolve();
}
2025-12-23 17:29:27 +01:00
/// INIT --------------------------------------------------------
2025-12-19 12:33:59 +01:00
// Note: une fois que IncludeHTML() est supprimé, on peut supprimer tout le temp au dessus
// remplacer `function initAfterLoad()` par ↓
2025-12-23 19:17:52 +01:00
// window.onload = async function () { }
2025-12-19 12:33:59 +01:00
function initAfterLoad() {
headerToggle();
2025-12-23 17:29:27 +01:00
headerScrollVisibility();
2025-12-23 19:17:52 +01:00
copyLink();
2025-12-24 16:00:47 +01:00
btnSticky(responsiveSmall);
}
function responsiveLoader() {
let isLoaded = false;
function checkResize() {
if (window.innerWidth < responsiveSmall && !isLoaded) {
// other functions qui ne chargent que pour la version mobile ...
isLoaded = true;
}
}
checkResize();
window.addEventListener('resize', checkResize);
2025-12-19 12:33:59 +01:00
}