You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

99 lines
2.5 KiB

(function (Drupal) {
//stuff goes here
})(Drupal);
(function (Drupal) {
Drupal.behaviors.LangSwitchBehavior = {
attach: function (context, settings) {
const textEn = context.querySelector('#text-en');
const textFr = context.querySelector('#text-fr');
const showEn = context.querySelector('#show-text-en');
const showFr = context.querySelector('#show-text-fr');
// Hide French text initially
if (textFr) {
textFr.style.display = 'none';
}
if (showEn && textEn && textFr) {
showEn.addEventListener('click', function (e) {
e.preventDefault();
textEn.style.display = '';
textFr.style.display = 'none';
});
}
if (showFr && textEn && textFr) {
showFr.addEventListener('click', function (e) {
e.preventDefault();
textEn.style.display = 'none';
textFr.style.display = '';
});
}
}
};
})(Drupal);
//(function (Drupal, once) {
//async function getAudioSourceFromNode(url) {
//const res = await fetch(url, {
//headers: { 'X-Requested-With': 'XMLHttpRequest' }
//});
//const html = await res.text();
//const doc = new DOMParser().parseFromString(html, 'text/html');
//// EXACT match for your markup
//const source = doc.querySelector(
//'audio[data-able-player] source[type="audio/mpeg"]'
//);
//return source?.src;
//}
//function playAbleAudio(src) {
//const audio = document.getElementById('global-able-player');
//if (!audio) return;
//const source = audio.querySelector('source');
//source.src = src;
//audio.load();
//// Access Able Player instance safely
//if (audio.ablePlayer) {
//audio.ablePlayer.refreshControls();
//audio.ablePlayer.playMedia();
//} else {
//audio.play();
//}
//document.getElementById('global-audio-wrapper')
//?.classList.remove('is-hidden');
//}
//Drupal.behaviors.ablePlayerRemoteLoad = {
//attach(context) {
//once('able-player-fetch', '.js-play-audio-from-node', context)
//.forEach(link => {
//link.addEventListener('click', async e => {
//e.preventDefault();
//const src = await getAudioSourceFromNode(link.href);
//if (!src) {
//console.warn('No Able Player audio found on page');
//return;
//}
//playAbleAudio(src);
//});
//});
//}
//};
//})(Drupal, once);