переработал систему модалок и добавил блоки
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
|
||||
.form-block-wrapper .ff-el-group {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.form-block-wrapper .ff-el-input--label label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
font-weight: 600;
|
||||
color: #374151;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.form-block-wrapper .ff-el-form-control {
|
||||
width: 100%;
|
||||
padding: 12px 16px;
|
||||
border: 2px solid #e5e7eb;
|
||||
border-radius: 8px;
|
||||
font-size: 16px;
|
||||
transition: all 0.2s ease;
|
||||
background: #ffffff;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.form-block-wrapper .ff-el-form-control:focus {
|
||||
outline: none;
|
||||
border-color: #3b82f6;
|
||||
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
|
||||
}
|
||||
|
||||
.form-block-wrapper .ff-btn-submit {
|
||||
width: 100%;
|
||||
padding: 14px 24px;
|
||||
background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
.form-block-wrapper .ff-btn-submit:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 8px 25px rgba(59, 130, 246, 0.3);
|
||||
}
|
||||
|
||||
.form-block-wrapper .ff-btn-submit:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.form-block-wrapper .asterisk-right label::after {
|
||||
content: ' *';
|
||||
color: #ef4444;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.form-block-wrapper .ff-message-success,
|
||||
.form-block-wrapper .ff-message-container {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.form-block-wrapper.form-loading .ff-btn-submit {
|
||||
opacity: 0.7;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.form-block-wrapper {
|
||||
margin: 20px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.form-block-wrapper .ff-el-form-control {
|
||||
font-size: 16px;
|
||||
padding: 10px 14px;
|
||||
}
|
||||
|
||||
.form-block-wrapper .ff-btn-submit {
|
||||
font-size: 16px;
|
||||
padding: 12px 20px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) and (min-width: 769px) {
|
||||
.form-block-wrapper {
|
||||
padding: 25px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
$form_id = get_field('form_id') ?: '3';
|
||||
$form_title = get_field('form_title') ?: 'Форма обратной связи';
|
||||
$submit_button_text = get_field('submit_button_text') ?: 'Отправить';
|
||||
|
||||
$unique_id = 'form-block-' . $block['id'];
|
||||
|
||||
$current_url = home_url($_SERVER['REQUEST_URI']);
|
||||
$page_title = get_the_title() ?: 'Главная страница';
|
||||
$form_name = $form_title;
|
||||
|
||||
$hidden_value = "Форма: {$form_name} | Страница: {$page_title} | URL: {$current_url}";
|
||||
?>
|
||||
|
||||
<section class="container mx-auto mt-[22px]" id="<?php echo esc_attr($unique_id); ?>">
|
||||
<div class="text-[24px] font-[700] mb-[20px] text-[#374151]">
|
||||
<?php echo esc_html($form_title); ?>
|
||||
</div>
|
||||
|
||||
<div class="form-block-wrapper bg-white p-[30px] rounded-[12px] max-w-[300px]"
|
||||
data-form-id="<?php echo esc_attr($form_id); ?>"
|
||||
data-submit-text="<?php echo esc_attr($submit_button_text); ?>"
|
||||
data-hidden-value="<?php echo esc_attr($hidden_value); ?>">
|
||||
<?php echo do_shortcode('[fluentform id="' . esc_attr($form_id) . '"]'); ?>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const section = document.getElementById('<?php echo esc_js($unique_id); ?>');
|
||||
if (!section) return;
|
||||
|
||||
const block = section.querySelector('.form-block-wrapper');
|
||||
if (!block) return;
|
||||
|
||||
const submitText = block.dataset.submitText;
|
||||
const hiddenValue = block.dataset.hiddenValue;
|
||||
|
||||
function updateForm() {
|
||||
const submitButton = block.querySelector('.ff-btn-submit');
|
||||
const hiddenInput = block.querySelector('input[name="hidden"]');
|
||||
|
||||
let updated = false;
|
||||
|
||||
if (submitButton && submitText) {
|
||||
submitButton.textContent = submitText;
|
||||
updated = true;
|
||||
}
|
||||
|
||||
if (hiddenInput && hiddenValue && !hiddenInput.value) {
|
||||
hiddenInput.value = hiddenValue;
|
||||
updated = true;
|
||||
}
|
||||
|
||||
return updated;
|
||||
}
|
||||
|
||||
if (!updateForm()) {
|
||||
let attempts = 0;
|
||||
const maxAttempts = 3;
|
||||
|
||||
const interval = setInterval(() => {
|
||||
attempts++;
|
||||
if (updateForm() || attempts >= maxAttempts) {
|
||||
clearInterval(interval);
|
||||
}
|
||||
}, 150);
|
||||
}
|
||||
|
||||
block.addEventListener('focusin', updateForm, { once: true });
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user