This commit is contained in:
Roman Pyrih
2024-12-20 15:48:16 +01:00
parent d9fb74972a
commit a5e1095e2c
3 changed files with 620 additions and 596 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -20,34 +20,34 @@ function enableScroll() {
//Gallery lightbox //Gallery lightbox
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
// ===> DOM elements <=== // // ===> DOM elements <=== //
const $imagesContainer = document.getElementById('gallery-lightbox'); const $imagesContainer = document.getElementById('gallery-lightbox');
const $lightbox = document.getElementById('lightbox'); const $lightbox = document.getElementById('lightbox');
// ===> Event listeners and triggers <=== // if ($imagesContainer && $lightbox) {
// ===> Event listeners and triggers <=== //
// Show lightbox // Show lightbox
$imagesContainer.addEventListener('click', e => { $imagesContainer.addEventListener('click', e => {
const imageWrapper = e.target.closest('.gallery-image'); const imageWrapper = e.target.closest('.gallery-image');
if (imageWrapper) { if (imageWrapper) {
const image = imageWrapper.querySelector('img'); const image = imageWrapper.querySelector('img');
if (image) { if (image) {
$lightbox.innerHTML = '<div class="close-lightbox"></div>' + image.outerHTML; $lightbox.innerHTML = '<div class="close-lightbox"></div>' + image.outerHTML;
$lightbox.classList.add('show'); $lightbox.classList.add('show');
}
} }
} });
});
// Hide Lightbox // Hide Lightbox
$lightbox.addEventListener('click', (e) => { $lightbox.addEventListener('click', (e) => {
if (!e.target.hasAttribute('src')) { if (!e.target.hasAttribute('src')) {
$lightbox.classList.remove('show'); $lightbox.classList.remove('show');
} }
}); });
// Loading... // Loading...
setTimeout(() => setTimeout(() => {
$imagesContainer.classList.remove('loading') $imagesContainer.classList.remove('loading');
, 1500); }, 1500);
}
}); });

View File

@@ -130,7 +130,7 @@
<h2>Krok 3</h2> <h2>Krok 3</h2>
</div> </div>
<ul class="calc-radio" v-if="isLoaded"> <ul class="calc-radio" v-if="isLoaded">
<li v-for="(step, index) in acfData.acf.step_3" :key="index" @click="setStep_3(step.text, index)" :class="{ selected: index === selected_option_3 }"> <li v-for="(step, index) in acfData_step_3" :key="index" @click="setStep_3(step.text, index)" :class="{ selected: index === selected_option_3 }">
<div class="radio"></div> <div class="radio"></div>
<div class="radio-text"> <div class="radio-text">
<div class="radio-title">{{ step.text }}</div> <div class="radio-title">{{ step.text }}</div>
@@ -279,6 +279,11 @@
acf: {} acf: {}
}, },
acfData_step_3: {
},
configData: { configData: {
step_1: '', step_1: '',
step_2: { step_2: {
@@ -295,19 +300,27 @@
} }
} }
}, },
beforeMount() { async beforeMount() {
this.getWindowWidth() this.getWindowWidth();
fetch(`<?php echo get_home_url() ?>/wp-json/wp/v2/pages/<?php echo get_the_ID() ?>`) try {
.then(res => res.json()) const res = await fetch(`<?php echo get_home_url() ?>/wp-json/wp/v2/pages/<?php echo get_the_ID() ?>`);
.then(data => this.acfData = data) const data = await res.json();
.then(this.isLoaded = true) this.acfData = data;
this.isLoaded = true;
} catch (error) {
console.error('Error fetching data:', error);
this.isLoaded = true;
}
console.log(this.acfData);
}, },
methods: { methods: {
setStep_1(value, index) { setStep_1(value, index) {
this.configData.step_1 = value this.configData.step_1 = value
this.selected_option_1 = index this.selected_option_1 = index
this.updateStep2Content(); this.updateStep2Content();
this.updateStep3Content();
}, },
updateStep2Content() { updateStep2Content() {
// Tutaj umieszczasz logikę, która zmienia zawartość kroku 2 w zależności od wyboru w kroku 1. // Tutaj umieszczasz logikę, która zmienia zawartość kroku 2 w zależności od wyboru w kroku 1.
@@ -321,6 +334,17 @@
} }
// I tak dalej dla innych opcji... // I tak dalej dla innych opcji...
}, },
updateStep3Content() {
if (this.selected_option_1 === 0) {
this.acfData_step_3 = this.acfData.acf.step_3.items_1
} else if (this.selected_option_1 === 1) {
this.acfData_step_3 = this.acfData.acf.step_3.items_2
} else if (this.selected_option_1 === 2) {
this.acfData_step_3 = this.acfData.acf.step_3.items_3
}
},
setStep_3(value, index) { setStep_3(value, index) {
this.configData.step_3 = value this.configData.step_3 = value
this.selected_option_3 = index this.selected_option_3 = index