| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- // Petit loader pour charger les modules en environnement sans bundler
- (function() {
- function loadScript(src, cb) {
- var s = document.createElement('script');
- s.src = src;
- s.onload = cb;
- s.async = false;
- document.head.appendChild(s);
- }
- // Attendre que le DOM et Bootstrap soient prêts
- function whenReady(callback) {
- if (document.readyState === 'loading') {
- document.addEventListener('DOMContentLoaded', callback);
- } else {
- callback();
- }
- }
- whenReady(function() {
- // Attendre que Bootstrap soit disponible (quelques ms si nécessaire)
- function waitForBootstrap(callback, attempts) {
- attempts = attempts || 0;
- if (window.bootstrap && window.bootstrap.Dropdown) {
- callback();
- } else if (attempts < 20) {
- setTimeout(function() {
- waitForBootstrap(callback, attempts + 1);
- }, 50);
- } else {
- console.warn('[loader.js] Bootstrap non disponible après 1s, chargement sans attendre');
- callback();
- }
- }
- waitForBootstrap(function() {
- // Charger d'abord les helpers core, puis UI, puis editor
- loadScript('/assets/js/core/dom-ready.js', function() {
- loadScript('/assets/js/ui/header.js', function() {
- // header initialisé
- // Forcer une réinitialisation des dropdowns après un court délai
- setTimeout(function() {
- if (window.initDropdownsManually) {
- window.initDropdownsManually();
- }
- }, 100);
- });
- // Charger l'éditeur seulement si la page contient un canvas de carte
- if (document.getElementById('mapCanvas')) {
- loadScript('/assets/js/editor/map-editor.js', function() {
- // map-editor chargé
- });
- }
- });
- });
- });
- })();
|