Files
Fedor 4394550ff1 feat: улучшения формы и отображение case_taxonomy
- Добавлено отображение case_taxonomy вместо 'Разобрались' на странице кейса
- Улучшена интеграция iframe формы с обработкой событий
- Добавлен лог диалога по интеграции React формы
2025-12-16 11:40:31 +03:00

171 lines
5.4 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* Template Name: Страница с формой
* Template Post Type: page
*
* Шаблон страницы с формой обратной связи
*
* @package Clientprav
*/
get_header();
?>
<div class="min-h-screen bg-gray-50 pt-24 pb-16">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<!-- Навигация назад -->
<a href="<?php echo esc_url(home_url('/')); ?>"
class="text-gray-600 hover:text-gray-900 mb-8 inline-flex items-center gap-2 transition-colors">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"></path>
</svg>
Назад на главную
</a>
<!-- Заголовок -->
<div class="mb-8">
<h1 class="text-5xl text-gray-900 mb-4">Получить помощь</h1>
<p class="text-xl text-gray-600">
Заполните форму, и мы поможем защитить ваши права бесплатно
</p>
</div>
<!-- Форма в iframe -->
<div class="bg-white rounded-2xl shadow-lg overflow-hidden">
<div class="form-iframe-wrapper">
<iframe
id="aiform-iframe"
src="https://aiform.clientright.ru/"
frameborder="0"
scrolling="yes"
allow="camera; microphone; geolocation"
class="w-full border-0"
style="min-height: 800px; height: 100vh; max-height: 1200px;">
</iframe>
</div>
</div>
</div>
</div>
<style>
/* Адаптивные стили для iframe */
.form-iframe-wrapper {
position: relative;
width: 100%;
min-height: 800px;
height: 100vh;
max-height: 1200px;
overflow: hidden;
}
#aiform-iframe {
width: 100%;
height: 100%;
border: none;
display: block;
}
/* Адаптация для мобильных устройств */
@media (max-width: 768px) {
.form-iframe-wrapper {
min-height: 600px;
max-height: 100vh;
}
#aiform-iframe {
min-height: 600px;
}
}
/* Для очень маленьких экранов */
@media (max-width: 480px) {
.form-iframe-wrapper {
min-height: 500px;
}
#aiform-iframe {
min-height: 500px;
}
}
</style>
<script>
// Улучшенная интеграция с формой через postMessage
window.addEventListener('message', function(event) {
// Проверяем источник сообщения
if (event.origin !== 'https://aiform.clientright.ru') {
return;
}
const iframe = document.getElementById('aiform-iframe');
const data = event.data;
// Автоматическая высота iframe
if (data && typeof data === 'object') {
// Изменение высоты
if (data.type === 'resize' && data.height) {
if (iframe) {
iframe.style.height = data.height + 'px';
}
}
// Форма отправлена успешно
if (data.type === 'form-submitted' || data.type === 'submit-success') {
console.log('Форма отправлена:', data);
// Можно отправить событие в Google Analytics, если нужно
if (typeof gtag !== 'undefined') {
gtag('event', 'form_submit', {
'event_category': 'Form',
'event_label': 'AI Form'
});
}
// Можно показать уведомление на странице WordPress
// showNotification('Спасибо! Ваша заявка отправлена.');
}
// Ошибка при отправке
if (data.type === 'form-error' || data.type === 'submit-error') {
console.error('Ошибка формы:', data);
}
// Прогресс заполнения формы
if (data.type === 'form-progress') {
// Можно показать прогресс-бар, если нужно
// updateProgressBar(data.progress);
}
}
});
// Улучшенная обработка загрузки iframe
document.addEventListener('DOMContentLoaded', function() {
const iframe = document.getElementById('aiform-iframe');
if (!iframe) return;
// Обработка загрузки iframe
iframe.addEventListener('load', function() {
// Пытаемся установить связь с формой
try {
// Запрашиваем начальную высоту
iframe.contentWindow.postMessage({
type: 'get-height'
}, 'https://aiform.clientright.ru');
} catch (e) {
// Игнорируем ошибки CORS
console.warn('Не удалось установить связь с формой:', e);
}
});
// Обработка ошибок загрузки
iframe.addEventListener('error', function() {
console.error('Ошибка загрузки формы');
});
});
</script>
<?php
get_footer();