2022-08-02 18:50:27 +02:00
|
|
|
import Splide from '@splidejs/splide';
|
|
|
|
|
2022-06-17 17:51:59 +02:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// DATA
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2022-08-02 18:50:27 +02:00
|
|
|
// UTILS
|
|
|
|
|
|
|
|
const body = document.body;
|
|
|
|
|
2022-08-03 14:55:32 +02:00
|
|
|
// SPLIDE SLIDER
|
2022-08-02 18:50:27 +02:00
|
|
|
|
2022-08-04 17:56:28 +02:00
|
|
|
const logo = document.querySelector('.logo__icon');
|
|
|
|
let slider = document.querySelector('.splide');
|
|
|
|
const slides = document.querySelectorAll('.splide__slide');
|
2022-08-02 18:50:27 +02:00
|
|
|
|
2022-08-03 14:55:32 +02:00
|
|
|
// EXHIBITION IFRAME
|
2022-07-22 17:53:26 +02:00
|
|
|
|
|
|
|
const sidebar = document.querySelector('.sidebar');
|
2022-08-08 11:31:25 +02:00
|
|
|
const sidebarNavLinks = document.querySelectorAll('.sidebar__nav-link--iframe');
|
2022-07-28 18:59:14 +02:00
|
|
|
const exhibitionIframe = document.querySelector('.exhibition');
|
2022-07-22 17:53:26 +02:00
|
|
|
|
2022-08-08 11:31:25 +02:00
|
|
|
// NAV LINKS TARGET
|
|
|
|
|
|
|
|
const mediaQueries = {
|
|
|
|
remTabletWidth: 48,
|
|
|
|
remDesktopWidth: 62
|
|
|
|
}
|
|
|
|
|
2022-06-17 17:51:59 +02:00
|
|
|
// ----------------------------------------------------------------------------
|
2022-07-28 18:59:14 +02:00
|
|
|
// LOGIC
|
2022-06-17 17:51:59 +02:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2022-07-28 18:59:14 +02:00
|
|
|
// UTILS
|
|
|
|
|
|
|
|
// Enable CSS :active pseudo-class in Safari Mobile
|
|
|
|
function enableActivePseudoClass() {
|
|
|
|
document.addEventListener("touchstart", function() {},false);
|
|
|
|
}
|
|
|
|
|
2022-06-17 17:51:59 +02:00
|
|
|
// Convert rem to pixels by getting font-size CSS property
|
|
|
|
function convertRemToPixels(rem) {
|
2022-08-02 18:50:27 +02:00
|
|
|
let fontSize = parseFloat(window.getComputedStyle(body).getPropertyValue('font-size'));
|
2022-07-07 17:09:48 +02:00
|
|
|
return rem * fontSize;
|
2022-06-17 17:51:59 +02:00
|
|
|
}
|
|
|
|
|
2022-08-03 14:55:32 +02:00
|
|
|
// SPLIDE SLIDER
|
2022-08-02 18:50:27 +02:00
|
|
|
|
|
|
|
function setUpSlider() {
|
2022-08-04 17:56:28 +02:00
|
|
|
if (slider) {
|
|
|
|
slider = new Splide('.splide', {
|
2022-08-02 18:50:27 +02:00
|
|
|
type: 'fade',
|
|
|
|
rewind: true,
|
|
|
|
rewindByDrag: true,
|
|
|
|
speed: 400,
|
|
|
|
fixedWidth: '100vw',
|
|
|
|
fixedHeight: '100vh',
|
|
|
|
arrows: false,
|
|
|
|
pagination: false,
|
|
|
|
easing: 'ease-in-out',
|
|
|
|
drag: true,
|
|
|
|
wheel: true
|
2022-08-04 17:56:28 +02:00
|
|
|
});
|
2022-08-02 18:50:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-04 17:56:28 +02:00
|
|
|
function mountSlider() {
|
2022-08-05 15:57:01 +02:00
|
|
|
if (slider) {
|
|
|
|
slider.mount();
|
|
|
|
}
|
2022-08-04 17:56:28 +02:00
|
|
|
}
|
|
|
|
|
2022-08-02 18:50:27 +02:00
|
|
|
function goToNextSlideOnClick() {
|
2022-08-04 17:56:28 +02:00
|
|
|
if (slider) {
|
|
|
|
slider.on('click', function(e) {
|
|
|
|
slider.go('>');
|
2022-08-02 18:50:27 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-05 15:57:01 +02:00
|
|
|
function turnLogoToBlack() {
|
2022-08-04 17:56:28 +02:00
|
|
|
if (logo) {
|
|
|
|
logo.classList.remove('logo__icon--white');
|
|
|
|
logo.classList.add('logo__icon--black');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-05 15:57:01 +02:00
|
|
|
function turnLogoToWhite() {
|
2022-08-04 17:56:28 +02:00
|
|
|
if (logo) {
|
|
|
|
logo.classList.remove('logo__icon--black');
|
|
|
|
logo.classList.add('logo__icon--white');
|
2022-08-03 16:49:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-04 17:56:28 +02:00
|
|
|
function editLogoColor(slide) {
|
|
|
|
if (slide) {
|
|
|
|
if (slide.getAttribute('data-logo-color') === 'white') {
|
2022-08-05 15:57:01 +02:00
|
|
|
turnLogoToWhite();
|
2022-08-04 17:56:28 +02:00
|
|
|
} else if (slide.getAttribute('data-logo-color') === 'black') {
|
2022-08-05 15:57:01 +02:00
|
|
|
turnLogoToBlack();
|
2022-08-04 17:56:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function editLogoColorOnSliderMounted() {
|
|
|
|
if (slider && slides) {
|
|
|
|
slider.on('mounted', function() {
|
|
|
|
editLogoColor(slides[0]);
|
|
|
|
})
|
2022-08-03 16:49:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function editLogoColorOnSlideActive() {
|
2022-08-04 17:56:28 +02:00
|
|
|
if (slider) {
|
|
|
|
slider.on('active', function(e) {
|
|
|
|
editLogoColor(e.slide);
|
2022-08-03 16:49:26 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-05 15:57:01 +02:00
|
|
|
function enableLogoRotation() {
|
2022-08-04 17:56:28 +02:00
|
|
|
if (logo) {
|
|
|
|
logo.classList.add('logo__icon--rotate-horizontal-bottom');
|
2022-08-01 16:59:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-05 15:57:01 +02:00
|
|
|
function disableLogoRotation() {
|
2022-08-04 17:56:28 +02:00
|
|
|
if (logo) {
|
|
|
|
logo.classList.remove('logo__icon--rotate-horizontal-bottom');
|
2022-08-01 16:59:46 +02:00
|
|
|
}
|
|
|
|
}
|
2022-07-22 17:53:26 +02:00
|
|
|
|
2022-08-03 14:55:32 +02:00
|
|
|
function rotateLogoOnSliderMove() {
|
2022-08-04 17:56:28 +02:00
|
|
|
if (slider && logo) {
|
|
|
|
slider.on('move', function(e) {
|
2022-08-05 15:57:01 +02:00
|
|
|
logo.removeEventListener('animationiteration', disableLogoRotation);
|
|
|
|
enableLogoRotation();
|
2022-08-03 14:55:32 +02:00
|
|
|
});
|
2022-08-04 17:56:28 +02:00
|
|
|
slider.on('moved', function(e) {
|
2022-08-05 15:57:01 +02:00
|
|
|
logo.addEventListener('animationiteration', disableLogoRotation);
|
2022-08-03 14:55:32 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// EXHIBITION IFRAME
|
|
|
|
|
2022-07-22 17:53:26 +02:00
|
|
|
function slimDownSidebar() {
|
2022-07-28 18:59:14 +02:00
|
|
|
if (sidebar && !sidebar.classList.contains('sidebar--slimmed')) {
|
2022-07-22 17:53:26 +02:00
|
|
|
sidebar.classList.add('sidebar--slimmed');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-01 16:59:46 +02:00
|
|
|
function enableExhibitionIframeVisibility() {
|
|
|
|
if (exhibitionIframe) {
|
|
|
|
exhibitionIframe.classList.add('exhibition--visible');
|
|
|
|
}
|
|
|
|
}
|
2022-07-28 18:59:14 +02:00
|
|
|
|
2022-08-01 16:59:46 +02:00
|
|
|
function disableExhibitionIframeVisibility() {
|
|
|
|
if (exhibitionIframe) {
|
|
|
|
exhibitionIframe.classList.remove('exhibition--visible');
|
2022-07-28 18:59:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-01 16:59:46 +02:00
|
|
|
function editBackgroundColor(sidebarNavLink) {
|
|
|
|
if (body && sidebar) {
|
|
|
|
if (sidebarNavLink.getAttribute('data-background') === 'feldgrau') {
|
|
|
|
body.classList.remove('body--white-background');
|
|
|
|
sidebar.classList.remove('sidebar--white-background');
|
|
|
|
} else if (sidebarNavLink.getAttribute('data-background') === 'white') {
|
|
|
|
body.classList.add('body--white-background');
|
|
|
|
sidebar.classList.add('sidebar--white-background');
|
2022-07-28 18:59:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadExhibitionIframe() {
|
|
|
|
if (sidebarNavLinks.length > 0 && exhibitionIframe) {
|
2022-07-22 17:53:26 +02:00
|
|
|
for (let i = 0; i < sidebarNavLinks.length; i++) {
|
2022-07-28 18:59:14 +02:00
|
|
|
sidebarNavLinks[i].addEventListener('click', function(e) {
|
2022-08-08 12:40:16 +02:00
|
|
|
if (window.innerWidth >= convertRemToPixels(mediaQueries.remDesktopWidth)) {
|
|
|
|
logo.removeEventListener('animationiteration', disableLogoRotation);
|
|
|
|
enableLogoRotation();
|
|
|
|
disableExhibitionIframeVisibility();
|
|
|
|
exhibitionIframe.addEventListener('load', function(e) {
|
|
|
|
logo.addEventListener('animationiteration', disableLogoRotation);
|
|
|
|
slimDownSidebar();
|
|
|
|
enableExhibitionIframeVisibility();
|
|
|
|
editBackgroundColor(sidebarNavLinks[i]);
|
|
|
|
});
|
|
|
|
}
|
2022-07-28 18:59:14 +02:00
|
|
|
});
|
2022-07-22 17:53:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-08 11:31:25 +02:00
|
|
|
// NAV LINKS TARGET
|
|
|
|
|
|
|
|
function setNavLinksIframeTarget() {
|
|
|
|
if (sidebarNavLinks) {
|
|
|
|
for (let i = 0; i < sidebarNavLinks.length; i++) {
|
|
|
|
sidebarNavLinks[i].setAttribute('target', 'exhibition');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function setNavLinksBlankTarget() {
|
|
|
|
if (sidebarNavLinks) {
|
|
|
|
for (let i = 0; i < sidebarNavLinks.length; i++) {
|
|
|
|
sidebarNavLinks[i].setAttribute('target', '_blank');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function editNavLinksTarget() {
|
2022-08-08 12:40:16 +02:00
|
|
|
if (window.innerWidth >= convertRemToPixels(mediaQueries.remDesktopWidth)) {
|
2022-08-08 11:31:25 +02:00
|
|
|
setNavLinksIframeTarget();
|
2022-08-08 12:40:16 +02:00
|
|
|
} else {
|
|
|
|
setNavLinksBlankTarget();
|
2022-08-08 11:31:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function editNavLinksTargetOnResize() {
|
|
|
|
window.addEventListener('resize', function(e) {
|
|
|
|
editNavLinksTarget();
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-06-17 17:51:59 +02:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// PROGRAM
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2022-07-28 18:59:14 +02:00
|
|
|
// UTILS
|
|
|
|
|
|
|
|
enableActivePseudoClass();
|
2022-07-22 17:53:26 +02:00
|
|
|
|
2022-08-03 14:55:32 +02:00
|
|
|
// SPLIDE SLIDER
|
2022-08-02 18:50:27 +02:00
|
|
|
|
|
|
|
setUpSlider();
|
2022-08-04 17:56:28 +02:00
|
|
|
editLogoColorOnSliderMounted();
|
|
|
|
mountSlider();
|
2022-08-02 18:50:27 +02:00
|
|
|
goToNextSlideOnClick();
|
2022-08-03 16:49:26 +02:00
|
|
|
editLogoColorOnSlideActive();
|
2022-08-03 14:55:32 +02:00
|
|
|
rotateLogoOnSliderMove();
|
2022-08-02 18:50:27 +02:00
|
|
|
|
2022-08-03 14:55:32 +02:00
|
|
|
// EXHIBITION IFRAME
|
2022-07-22 17:53:26 +02:00
|
|
|
|
2022-07-28 18:59:14 +02:00
|
|
|
loadExhibitionIframe();
|
2022-08-08 11:31:25 +02:00
|
|
|
|
|
|
|
// NAV LINKS TARGET
|
|
|
|
|
|
|
|
editNavLinksTarget();
|
|
|
|
editNavLinksTargetOnResize();
|