2024-07-15 16:34:28 +02:00
|
|
|
import { createApp } from 'vue'
|
2024-07-23 00:01:44 +02:00
|
|
|
import { createPinia } from 'pinia'
|
2024-07-15 16:34:28 +02:00
|
|
|
import '../scss/main.scss'
|
|
|
|
import Etape from './vuejs/Etape.vue'
|
|
|
|
|
2024-07-23 00:01:44 +02:00
|
|
|
import { useEtapeStore } from './stores/etape';
|
2024-07-15 16:34:28 +02:00
|
|
|
|
2024-07-23 00:01:44 +02:00
|
|
|
// Working with the history API
|
|
|
|
// https://developer.mozilla.org/en-US/docs/Web/API/History_API/Working_with_the_History_API
|
2024-07-10 16:16:51 +02:00
|
|
|
|
2024-07-16 17:01:09 +02:00
|
|
|
// /**
|
|
|
|
// * @file
|
|
|
|
// * reha behaviors.
|
|
|
|
// * https://www.drupal.org/docs/drupal-apis/javascript-api/javascript-api-overview
|
|
|
|
// */
|
|
|
|
// (function (Drupal) {
|
2024-07-10 16:16:51 +02:00
|
|
|
|
2024-07-16 17:01:09 +02:00
|
|
|
// 'use strict';
|
|
|
|
|
|
|
|
// Drupal.behaviors.reha = {
|
|
|
|
// attach: function (context, settings) {
|
|
|
|
// console.log('It works!');
|
|
|
|
// }
|
|
|
|
// };
|
|
|
|
|
|
|
|
// } (Drupal));
|
|
|
|
|
|
|
|
(function (Drupal, drupalSettings) {
|
|
|
|
const CaravaneTheme = function () {
|
|
|
|
const _is_front = drupalSettings.path.isFront
|
|
|
|
console.log('drupalSettings', drupalSettings)
|
|
|
|
|
|
|
|
// let _I18n
|
|
|
|
|
|
|
|
// ___ _ _
|
|
|
|
// |_ _|_ _ (_) |_
|
|
|
|
// | || ' \| | _|
|
|
|
|
// |___|_||_|_|\__|
|
|
|
|
function init () {
|
|
|
|
console.log('CaravaneTheme init()')
|
|
|
|
initVues()
|
2024-07-29 23:39:35 +02:00
|
|
|
toggleMenu()
|
2024-07-16 17:01:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function initVues(){
|
|
|
|
initVueEtapeModale();
|
|
|
|
}
|
|
|
|
|
|
|
|
function initVueEtapeModale(){
|
2024-07-23 00:01:44 +02:00
|
|
|
const app = createApp(Etape).use(createPinia());
|
|
|
|
const store = useEtapeStore();
|
|
|
|
app.mount('#etape-modale');
|
2024-07-10 16:16:51 +02:00
|
|
|
|
2024-07-23 00:01:44 +02:00
|
|
|
processEtapeLinks(store);
|
2024-07-10 16:16:51 +02:00
|
|
|
}
|
|
|
|
|
2024-07-16 17:01:09 +02:00
|
|
|
|
2024-07-23 00:01:44 +02:00
|
|
|
function onClickEtapeLink(e, store){
|
2024-07-16 17:01:09 +02:00
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
let a = e.currentTarget;
|
|
|
|
let nid = a.dataset.nodeNid;
|
|
|
|
console.log(nid);
|
|
|
|
|
2024-07-23 00:01:44 +02:00
|
|
|
store.fetchEtapeData(nid);
|
2024-07-16 17:01:09 +02:00
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-07-23 00:01:44 +02:00
|
|
|
function processEtapeLinks(store){
|
2024-07-16 17:01:09 +02:00
|
|
|
let etape_link_fields = document.querySelectorAll('#etapes-liste div.views-field-title');
|
2024-07-23 00:01:44 +02:00
|
|
|
etape_link_fields.forEach((field) => {
|
2024-07-16 17:01:09 +02:00
|
|
|
let nid = null;
|
|
|
|
let classList = field.classList;
|
|
|
|
classList.forEach((classe) => {
|
|
|
|
let reg = /data-node-(\d+)/;
|
|
|
|
let result = classe.match(reg);
|
|
|
|
if (result) {
|
|
|
|
nid = result[1];
|
|
|
|
console.log(nid);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
if (nid) {
|
|
|
|
let a = field.querySelector('a');
|
|
|
|
a.setAttribute('data-node-nid', nid);
|
2024-07-23 00:01:44 +02:00
|
|
|
a.addEventListener('click', (e) => onClickEtapeLink(e, store));
|
2024-07-16 17:01:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-07-29 23:39:35 +02:00
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function toggleMenu() {
|
|
|
|
const menuButton = document.querySelector('#block-caravane-mainnavigation > #menu');
|
|
|
|
const menuContainer = document.querySelector('#block-caravane-mainnavigation > #menu > ul');
|
|
|
|
const menuTitle = document.querySelector('#menu-title');
|
|
|
|
const menuBurger = document.querySelector('#hamburger');
|
|
|
|
const menuH2 = document.querySelector('#menu > h2');
|
|
|
|
menuButton.addEventListener('click', (e) => {
|
|
|
|
// e.preventDefault();
|
|
|
|
menuContainer.classList.toggle('open');
|
|
|
|
menuTitle.classList.toggle('open');
|
|
|
|
menuBurger.classList.toggle('open');
|
|
|
|
menuH2.classList.toggle('open');
|
2024-07-16 17:01:09 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
init()
|
|
|
|
} // end CaravaneTheme()
|
|
|
|
|
|
|
|
CaravaneTheme()
|
|
|
|
})(Drupal, drupalSettings)
|