476 lines
21 KiB
PHP
476 lines
21 KiB
PHP
<?php get_header(); ?>
|
|
<div class="wrapper--default">
|
|
<div id="primary" class="wrapper--inner">
|
|
<div id="content" role="main" class="span8 offset2">
|
|
<?php if ( have_posts() ) : ?>
|
|
<?php while ( have_posts() ) : the_post(); ?>
|
|
<article class="post mt-12">
|
|
<h1 class=""><?php the_title(); ?></h1>
|
|
<p class="subtitle"><?= get_field('subtitle'); ?></p>
|
|
<div class="the-content">
|
|
<?php the_content(); ?>
|
|
<?php wp_link_pages(); ?>
|
|
</div><!-- the-content -->
|
|
</article>
|
|
<?php endwhile; ?>
|
|
<?php else : ?>
|
|
<article class="post error">
|
|
<h1 class="404">Nothing posted yet</h1>
|
|
</article>
|
|
<?php endif; ?>
|
|
</div><!-- #content .site-content -->
|
|
</div><!-- #primary .content-area -->
|
|
</div>
|
|
|
|
<div id="primary" class="row-fluid mx-auto lg:container lg:mx-auto">
|
|
<div id="content" role="main" class="wrapper--inner span8 offset2">
|
|
<?php if (have_posts()) : ?>
|
|
<div id="app">
|
|
<div class="page-data post">
|
|
<div id="calc-container">
|
|
<div class="calc-bar-fix">
|
|
<div id="calc-bar" ref="calcBar">
|
|
<div class="calc-s calc-placeholder"></div>
|
|
<!-- Step 1 -->
|
|
<div class="calc-s active" id="calc-ch-0" ref="slide1">
|
|
<div class="calc-box gray-bg box-shadow">
|
|
<div class="calc-box--data">
|
|
<div class="calc-box--title">
|
|
<h2>Krok 1</h2>
|
|
</div>
|
|
<ul class="calc-radio" v-if="isLoaded">
|
|
<li v-for="(step, index) in acfData.acf.step_1" :key="index" @click="setStep_1(step.text, index)" :class="{ selected: index === selected_option_1 }">
|
|
<div class="radio"></div>
|
|
<div class="radio-text">
|
|
<div class="radio-title">{{ step.text }}</div>
|
|
</div>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="next disabled" v-if="!configData.step_1">
|
|
<svg class="svg-arrow" width="32" height="32" viewBox="0 0 32 32" fill="none">
|
|
<path d="M11.166 23.963L22.36 17.5C23.79 16.676 23.79 15.325 22.36 14.5L11.165 8.037C9.73502 7.211 8.56702 7.887 8.56702 9.537V22.463C8.56702 24.113 9.73702 24.789 11.165 23.963H11.166Z" fill="#F8F8F8" />
|
|
</svg>
|
|
</div>
|
|
<div v-else>
|
|
<div class="next" v-if="windowWidth > 1000" @click="swipeSlide('slide2', -125, 2)">
|
|
<svg class="svg-arrow" width="32" height="32" viewBox="0 0 32 32" fill="none">
|
|
<path d="M11.166 23.963L22.36 17.5C23.79 16.676 23.79 15.325 22.36 14.5L11.165 8.037C9.73502 7.211 8.56702 7.887 8.56702 9.537V22.463C8.56702 24.113 9.73702 24.789 11.165 23.963H11.166Z" fill="#F8F8F8" />
|
|
</svg>
|
|
</div>
|
|
<div class="next" v-else @click="swipeSlide('slide2', -100, 2)">
|
|
<svg class="svg-arrow" width="32" height="32" viewBox="0 0 32 32" fill="none">
|
|
<path d="M11.166 23.963L22.36 17.5C23.79 16.676 23.79 15.325 22.36 14.5L11.165 8.037C9.73502 7.211 8.56702 7.887 8.56702 9.537V22.463C8.56702 24.113 9.73702 24.789 11.165 23.963H11.166Z" fill="#F8F8F8" />
|
|
</svg>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Step 2 -->
|
|
<div class="calc-s" id="calc-ch-1" ref="slide2">
|
|
<div class="calc-box gray-bg box-shadow">
|
|
<div class="calc-box--data">
|
|
<div class="calc-box--title">
|
|
<h2>Krok 2</h2>
|
|
</div>
|
|
<div class="slide-data">
|
|
<img :src="acfData.acf.step_2.image" alt="">
|
|
<ul class="calc-texts" v-if="isLoaded">
|
|
<li>
|
|
<p>{{ acfData.acf.step_2.width }} ( od 2m do 7m ):<br><span>{{ configData.step_2.width / 1000 }}m</span></p>
|
|
<input v-model="configData.step_2.width" ref="rangeWidth" type="range" name="width" id="width" min="2000" max="7000" step="500">
|
|
</li>
|
|
<li>
|
|
<p>{{ acfData.acf.step_2.length }} ( od 2m do 7m ):<br><span>{{ configData.step_2.length / 1000 }}m</span></p>
|
|
<input v-model="configData.step_2.length" type="range" name="length" id="length" min="2000" max="7000" step="500">
|
|
</li>
|
|
<li>
|
|
<p>{{ acfData.acf.step_2.height }} ( do 2,8m lub do 3,5m ):<br><span>{{ configData.step_2.height / 1000 }}m</span></p>
|
|
<input v-model="configData.step_2.height" ref="rangeHeight" type="range" name="height" id="height" min="2800" max="3500" step="100">
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<div v-if="windowWidth > 1000">
|
|
<div class="prev" @click="swipeSlide('slide1', -55, 1)">
|
|
<svg class="svg-arrow" width="32" height="32" viewBox="0 0 32 32" fill="none">
|
|
<path d="M11.166 23.963L22.36 17.5C23.79 16.676 23.79 15.325 22.36 14.5L11.165 8.037C9.73502 7.211 8.56702 7.887 8.56702 9.537V22.463C8.56702 24.113 9.73702 24.789 11.165 23.963H11.166Z" fill="#F8F8F8" />
|
|
</svg>
|
|
</div>
|
|
<div class="next" @click="swipeSlide('slide3', -195, 3)">
|
|
<svg class="svg-arrow" width="32" height="32" viewBox="0 0 32 32" fill="none">
|
|
<path d="M11.166 23.963L22.36 17.5C23.79 16.676 23.79 15.325 22.36 14.5L11.165 8.037C9.73502 7.211 8.56702 7.887 8.56702 9.537V22.463C8.56702 24.113 9.73702 24.789 11.165 23.963H11.166Z" fill="#F8F8F8" />
|
|
</svg>
|
|
</div>
|
|
</div>
|
|
<div v-else>
|
|
<div class="prev" @click="swipeSlide('slide1', 0, 1)">
|
|
<svg class="svg-arrow" width="32" height="32" viewBox="0 0 32 32" fill="none">
|
|
<path d="M11.166 23.963L22.36 17.5C23.79 16.676 23.79 15.325 22.36 14.5L11.165 8.037C9.73502 7.211 8.56702 7.887 8.56702 9.537V22.463C8.56702 24.113 9.73702 24.789 11.165 23.963H11.166Z" fill="#F8F8F8" />
|
|
</svg>
|
|
</div>
|
|
<div class="next" @click="swipeSlide('slide3', -200, 3)">
|
|
<svg class="svg-arrow" width="32" height="32" viewBox="0 0 32 32" fill="none">
|
|
<path d="M11.166 23.963L22.36 17.5C23.79 16.676 23.79 15.325 22.36 14.5L11.165 8.037C9.73502 7.211 8.56702 7.887 8.56702 9.537V22.463C8.56702 24.113 9.73702 24.789 11.165 23.963H11.166Z" fill="#F8F8F8" />
|
|
</svg>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Step 3 -->
|
|
<div class="calc-s" id="calc-ch-2" ref="slide3">
|
|
<div class="calc-box gray-bg box-shadow">
|
|
<div class="calc-box--data">
|
|
<div class="calc-box--title">
|
|
<h2>Krok 3</h2>
|
|
</div>
|
|
<ul class="calc-radio" v-if="isLoaded">
|
|
<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-text">
|
|
<div class="radio-title">{{ step.text }}</div>
|
|
</div>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div v-if="windowWidth > 1000">
|
|
<div class="prev" @click="swipeSlide('slide2', -125, 2)">
|
|
<svg class="svg-arrow" width="32" height="32" viewBox="0 0 32 32" fill="none">
|
|
<path d="M11.166 23.963L22.36 17.5C23.79 16.676 23.79 15.325 22.36 14.5L11.165 8.037C9.73502 7.211 8.56702 7.887 8.56702 9.537V22.463C8.56702 24.113 9.73702 24.789 11.165 23.963H11.166Z" fill="#F8F8F8" />
|
|
</svg>
|
|
</div>
|
|
<div class="next disabled" v-if="!configData.step_3">
|
|
<svg class="svg-arrow" width="32" height="32" viewBox="0 0 32 32" fill="none">
|
|
<path d="M11.166 23.963L22.36 17.5C23.79 16.676 23.79 15.325 22.36 14.5L11.165 8.037C9.73502 7.211 8.56702 7.887 8.56702 9.537V22.463C8.56702 24.113 9.73702 24.789 11.165 23.963H11.166Z" fill="#F8F8F8" />
|
|
</svg>
|
|
</div>
|
|
<div class="next" v-else @click="swipeSlide('slide4', -265, 4)">
|
|
<svg class="svg-arrow" width="32" height="32" viewBox="0 0 32 32" fill="none">
|
|
<path d="M11.166 23.963L22.36 17.5C23.79 16.676 23.79 15.325 22.36 14.5L11.165 8.037C9.73502 7.211 8.56702 7.887 8.56702 9.537V22.463C8.56702 24.113 9.73702 24.789 11.165 23.963H11.166Z" fill="#F8F8F8" />
|
|
</svg>
|
|
</div>
|
|
</div>
|
|
<div v-else>
|
|
<div class="prev" @click="swipeSlide('slide2', -100, 2)">
|
|
<svg class="svg-arrow" width="32" height="32" viewBox="0 0 32 32" fill="none">
|
|
<path d="M11.166 23.963L22.36 17.5C23.79 16.676 23.79 15.325 22.36 14.5L11.165 8.037C9.73502 7.211 8.56702 7.887 8.56702 9.537V22.463C8.56702 24.113 9.73702 24.789 11.165 23.963H11.166Z" fill="#F8F8F8" />
|
|
</svg>
|
|
</div>
|
|
<div class="next disabled" v-if="!configData.step_3">
|
|
<svg class="svg-arrow" width="32" height="32" viewBox="0 0 32 32" fill="none">
|
|
<path d="M11.166 23.963L22.36 17.5C23.79 16.676 23.79 15.325 22.36 14.5L11.165 8.037C9.73502 7.211 8.56702 7.887 8.56702 9.537V22.463C8.56702 24.113 9.73702 24.789 11.165 23.963H11.166Z" fill="#F8F8F8" />
|
|
</svg>
|
|
</div>
|
|
<div class="next" v-else @click="swipeSlide('slide4', -300, 4)">
|
|
<svg class="svg-arrow" width="32" height="32" viewBox="0 0 32 32" fill="none">
|
|
<path d="M11.166 23.963L22.36 17.5C23.79 16.676 23.79 15.325 22.36 14.5L11.165 8.037C9.73502 7.211 8.56702 7.887 8.56702 9.537V22.463C8.56702 24.113 9.73702 24.789 11.165 23.963H11.166Z" fill="#F8F8F8" />
|
|
</svg>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Step 4 -->
|
|
<div class="calc-s" id="calc-ch-2" ref="slide4">
|
|
<div class="calc-box gray-bg box-shadow">
|
|
<div class="calc-box--data">
|
|
<div class="calc-box--title">
|
|
<h2>Krok 4</h2>
|
|
</div>
|
|
<ul class="calc-texts" v-if="isLoaded">
|
|
<li>
|
|
<p>{{acfData.acf.step_4.miejsce_montazu}}</p>
|
|
<input v-model="configData.step_4.miejsce_montazu" type="text" name="miejsce_montazu" id="calc_miejsce_montazu" class="input" require>
|
|
</li>
|
|
<li>
|
|
<p>{{acfData.acf.step_4.name}}</p>
|
|
<input v-model="configData.step_4.name" type="text" name="name" id="calc_name" class="input" require>
|
|
</li>
|
|
<li>
|
|
<p>{{acfData.acf.step_4.email}}</p>
|
|
<input v-model="configData.step_4.email" type="email" name="email" id="calc_email" class="input" require>
|
|
</li>
|
|
<li>
|
|
<p>{{acfData.acf.step_4.phone}}</p>
|
|
<input v-model="configData.step_4.phone" type="tel" name="phone" id="calc_phone" class="input" require>
|
|
</li>
|
|
</ul>
|
|
|
|
<button class="btn_send btn btn-primary" type="submit" @click="sendEmail()" :disabled="isSended">Wyślij</button>
|
|
</div>
|
|
|
|
<div v-if="windowWidth > 1000">
|
|
<div class="prev" @click="swipeSlide('slide3', -195, 3)">
|
|
<svg class="svg-arrow" width="32" height="32" viewBox="0 0 32 32" fill="none">
|
|
<path d="M11.166 23.963L22.36 17.5C23.79 16.676 23.79 15.325 22.36 14.5L11.165 8.037C9.73502 7.211 8.56702 7.887 8.56702 9.537V22.463C8.56702 24.113 9.73702 24.789 11.165 23.963H11.166Z" fill="#F8F8F8" />
|
|
</svg>
|
|
</div>
|
|
</div>
|
|
<div v-else>
|
|
<div class="prev" @click="swipeSlide('slide3', -200, 3)">
|
|
<svg class="svg-arrow" width="32" height="32" viewBox="0 0 32 32" fill="none">
|
|
<path d="M11.166 23.963L22.36 17.5C23.79 16.676 23.79 15.325 22.36 14.5L11.165 8.037C9.73502 7.211 8.56702 7.887 8.56702 9.537V22.463C8.56702 24.113 9.73702 24.789 11.165 23.963H11.166Z" fill="#F8F8F8" />
|
|
</svg>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="progress-bar">
|
|
<div class="progress-bar">
|
|
<div class="progress-bar-line" :style="{ width: progressBar + '%' }"></div>
|
|
</div>
|
|
<!-- <progress id="calculate-progres" :value="progressBar" max="100"></progress> -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<section class="section-header xl:container xl:mx-auto">
|
|
<h2 class="title">Przykładowe realizacje</h2>
|
|
</section>
|
|
<section class="section-realizacje flex flex-row items-center flex-wrap sm:justify-start xl:container xl:mx-auto">
|
|
<?php
|
|
$related = get_posts(
|
|
array(
|
|
'category__in' => wp_get_post_categories($post->ID),
|
|
'numberposts' => 4,
|
|
'post_type' => 'realizacje',
|
|
'post__not_in' => array($post->ID)
|
|
)
|
|
);
|
|
|
|
if ($related) foreach ($related as $post) {
|
|
setup_postdata($post); ?>
|
|
|
|
<a href="<?= the_permalink(); ?>" class="recent-realizations-item" style="background-image: url(<?= get_the_post_thumbnail_url(); ?>)">
|
|
|
|
<p class="absolute text-xl min-w-full min-h-full bg-opacity-90 h-full w-full flex items-center justify-center text-white text-center">
|
|
<?= get_the_title(); ?></p>
|
|
</a>
|
|
|
|
<?php } wp_reset_postdata(); ?>
|
|
</section>
|
|
</div>
|
|
</div>
|
|
<?php else : ?>
|
|
<article class="post error">
|
|
<h1 class="404">Nothing posted yet</h1>
|
|
</article>
|
|
<?php endif; ?>
|
|
</div><!-- #content .site-content -->
|
|
</div>
|
|
|
|
<script>
|
|
var app = Vue.createApp({
|
|
el: '#app',
|
|
data() {
|
|
return {
|
|
isLoaded: false,
|
|
isSended: false,
|
|
selected_option_1: null,
|
|
selected_option_3: null,
|
|
progressBar: 25,
|
|
windowWidth: 0,
|
|
|
|
acfData: {
|
|
acf: {}
|
|
},
|
|
|
|
|
|
acfData_step_3: {
|
|
|
|
},
|
|
|
|
configData: {
|
|
step_1: '',
|
|
step_2: {
|
|
length: 2000,
|
|
width: 2000,
|
|
height: 2500
|
|
},
|
|
step_3: '',
|
|
step_4: {
|
|
name: '',
|
|
email: '',
|
|
phone: ''
|
|
}
|
|
}
|
|
}
|
|
},
|
|
async beforeMount() {
|
|
this.getWindowWidth();
|
|
try {
|
|
const res = await fetch(`<?php echo get_home_url() ?>/wp-json/wp/v2/pages/<?php echo get_the_ID() ?>`);
|
|
const data = await res.json();
|
|
this.acfData = data;
|
|
this.isLoaded = true;
|
|
} catch (error) {
|
|
console.error('Error fetching data:', error);
|
|
this.isLoaded = true;
|
|
}
|
|
|
|
console.log(this.acfData);
|
|
|
|
},
|
|
methods: {
|
|
setStep_1(value, index) {
|
|
this.configData.step_1 = value
|
|
this.selected_option_1 = index
|
|
this.updateStep2Content();
|
|
this.updateStep3Content();
|
|
},
|
|
updateStep2Content() {
|
|
// Tutaj umieszczasz logikę, która zmienia zawartość kroku 2 w zależności od wyboru w kroku 1.
|
|
// Przykład: zmiana obrazka w kroku 2 na podstawie wyboru
|
|
if (this.selected_option_1 === 0) { // Zakładając, że pierwsza opcja w kroku 1 zmienia obraz na 'obrazek1.webp'
|
|
this.acfData.acf.step_2.image = '/wp-content/uploads/2024/02/konfigurator-ogrod-zimowy.png';
|
|
} else if (this.selected_option_1 === 1) { // Druga opcja zmienia obraz na 'obrazek2.webp'
|
|
this.acfData.acf.step_2.image = '/wp-content/uploads/2024/02/konfigurator-ogrod-letni.png';
|
|
} else if (this.selected_option_1 === 2) { // Druga opcja zmienia obraz na 'obrazek2.webp'
|
|
this.acfData.acf.step_2.image = '/wp-content/uploads/2024/02/konfigurator-ogrod-dach-jednospadowy.png';
|
|
}
|
|
// 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) {
|
|
this.configData.step_3 = value
|
|
this.selected_option_3 = index
|
|
},
|
|
swipeSlide(refName, percent, progress) {
|
|
const myDiv = this.$refs.calcBar;
|
|
const slide = this.$refs[refName];
|
|
const calcSElements = myDiv.querySelectorAll('.calc-s');
|
|
|
|
calcSElements.forEach((element) => {
|
|
element.classList.remove('active');
|
|
});
|
|
|
|
myDiv.style.marginLeft = `${percent}%`;
|
|
slide.classList.add('active');
|
|
|
|
this.progressBar = ((100 / 4) * progress)
|
|
},
|
|
sendEmail() {
|
|
if (this.checkFields()) {
|
|
const url = '/konfigurator-mail.php';
|
|
const data = {
|
|
configData: this.configData,
|
|
};
|
|
|
|
this.isSended = true
|
|
|
|
const options = {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify(data),
|
|
};
|
|
|
|
|
|
fetch(url, options)
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
this.isSended = false
|
|
this.resetAllFields()
|
|
this.swipeSlide('slide1', 0)
|
|
window.location.href = "/konfigurator-podziekowania/";
|
|
})
|
|
.catch(error => {
|
|
this.isSended = false
|
|
console.error(error);
|
|
});
|
|
} else {
|
|
alert('Proszę uzupełnić wszystkie pola.');
|
|
}
|
|
},
|
|
areAllFieldsFilled(configData) {
|
|
const checkFields = (data) => {
|
|
for (const key in data) {
|
|
const value = data[key];
|
|
if (typeof value === 'object') {
|
|
if (!checkFields(value)) {
|
|
return false;
|
|
}
|
|
} else if (value === '' || value === null || value === undefined) {
|
|
return false;
|
|
} else if (typeof value === 'string' && value.trim() === '') {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
|
|
return checkFields(configData);
|
|
},
|
|
checkFields() {
|
|
return this.areAllFieldsFilled(this.configData);
|
|
},
|
|
resetAllFields() {
|
|
const stack = [this.configData];
|
|
|
|
this.selected_option_1 = null
|
|
this.selected_option_3 = null
|
|
|
|
while (stack.length > 0) {
|
|
const obj = stack.pop();
|
|
|
|
for (const key in obj) {
|
|
const value = obj[key];
|
|
|
|
if (typeof value === 'object') {
|
|
stack.push(value);
|
|
} else {
|
|
if (Array.isArray(value)) {
|
|
obj[key] = [];
|
|
} else if (typeof value === 'number') {
|
|
obj[key] = 0;
|
|
} else if (typeof value === 'string') {
|
|
obj[key] = '';
|
|
} else if (typeof value === 'boolean') {
|
|
obj[key] = false;
|
|
} else {
|
|
obj[key] = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
getWindowWidth() {
|
|
this.windowWidth = window.innerWidth;
|
|
},
|
|
},
|
|
mounted() {
|
|
window.addEventListener('resize', this.getWindowWidth);
|
|
this.getWindowWidth();
|
|
},
|
|
computed: {
|
|
debug() {
|
|
return this.configData
|
|
}
|
|
},
|
|
beforeDestroy() {
|
|
window.removeEventListener('resize', this.getWindowWidth);
|
|
},
|
|
})
|
|
|
|
app.mount('#app')
|
|
</script>
|
|
<?php get_footer(); ?>
|