drupal-caravane/web/themes/custom/caravane/assets/js/main.js

50 lines
2.1 KiB
JavaScript

import { initVueContentModale } from './utils/vue-setup';
import { processClickableElements } from './utils/process-clickable-elements';
import { handleReactiveness, setMenuToggle, setHamburgerWhenLogged } from './utils/layout-setup';
import { initFirstLoadRouting, handleClickableElements } from './utils/handle-navigation';
import { setupMapStore } from './utils/map-setup';
import '../scss/main.scss'
// https://www.drupal.org/docs/drupal-apis/javascript-api/javascript-api-overview
(function ($, Drupal, drupalSettings) {
const CaravaneTheme = function () {
function init () {
console.log('DrupalSettings', drupalSettings);
const baseUrl = window.location.protocol + "//" + window.location.host;
const siteName = document.querySelector('#site_name').innerText;
const { store, mapStore, router, route } = initVueContentModale();
handleReactiveness();
setMenuToggle();
setHamburgerWhenLogged(drupalSettings);
// https://www.drupal.org/docs/extending-drupal/contributed-modules/contributed-module-documentation/leaflet/leaflet-api
Drupal.behaviors.customLeafletInteraction = {
attach: function(context, settings) {
$(context).on('leafletMapInit', function (e, settings, map, mapid, markers) {
const {
etapeListLinks,
generalListLinks,
logoLink,
mapIcons,
} = processClickableElements();
const clickableElements = [...etapeListLinks, ...generalListLinks, logoLink, ...mapIcons];
setupMapStore(mapStore, map, settings);
initFirstLoadRouting(store, router, baseUrl, siteName);
handleClickableElements(clickableElements, store, router, baseUrl, siteName, mapStore);
});
}
}
}
init()
}
CaravaneTheme()
})(jQuery, Drupal, drupalSettings)