test
This commit is contained in:
@@ -241,7 +241,10 @@
|
||||
align-items: center;
|
||||
min-height: 46px;
|
||||
border-bottom: 1px solid var(--color-line);
|
||||
color: var(--color-text);
|
||||
font: inherit;
|
||||
font-weight: 700;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.site-footer {
|
||||
@@ -315,6 +318,15 @@
|
||||
box-shadow: var(--shadow-soft);
|
||||
}
|
||||
|
||||
.lead-form__trap {
|
||||
position: absolute;
|
||||
left: -10000px;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.lead-form__head {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
@@ -381,6 +393,67 @@
|
||||
color: var(--color-success);
|
||||
}
|
||||
|
||||
.lead-modal {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 120;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.lead-modal[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.lead-modal__overlay {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: rgba(44, 33, 29, 0.58);
|
||||
}
|
||||
|
||||
.lead-modal__dialog {
|
||||
position: relative;
|
||||
width: min(100%, 520px);
|
||||
max-height: calc(100vh - 40px);
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.lead-modal__close {
|
||||
position: absolute;
|
||||
top: 14px;
|
||||
right: 14px;
|
||||
z-index: 2;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 50%;
|
||||
background: var(--color-surface-soft);
|
||||
}
|
||||
|
||||
.lead-modal__close::before,
|
||||
.lead-modal__close::after {
|
||||
position: absolute;
|
||||
top: 17px;
|
||||
left: 10px;
|
||||
width: 16px;
|
||||
height: 2px;
|
||||
border-radius: 2px;
|
||||
background: var(--color-text);
|
||||
content: "";
|
||||
}
|
||||
|
||||
.lead-modal__close::before {
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
.lead-modal__close::after {
|
||||
transform: rotate(-45deg);
|
||||
}
|
||||
|
||||
.lead-modal .lead-form {
|
||||
padding-top: 54px;
|
||||
}
|
||||
|
||||
.cookie-note {
|
||||
position: fixed;
|
||||
right: 24px;
|
||||
|
||||
@@ -48,6 +48,10 @@ body.menu-is-open {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
body.lead-modal-is-open {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.button-main,
|
||||
.lead-form__button {
|
||||
display: inline-flex;
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
var catalogButton = document.querySelector('.site-header__menu-button');
|
||||
var cookieNote = document.querySelector('[data-cookie-note]');
|
||||
var cookieButton = document.querySelector('[data-cookie-accept]');
|
||||
var leadModal = document.querySelector('[data-lead-modal]');
|
||||
var leadOpenNodes = document.querySelectorAll('[data-lead-open]');
|
||||
var leadCloseNodes = document.querySelectorAll('[data-lead-close]');
|
||||
var phoneInputs = document.querySelectorAll('[data-phone-mask]');
|
||||
var emailInputs = document.querySelectorAll('[data-email-mask]');
|
||||
|
||||
function setMenuState(isOpen) {
|
||||
if (!menu || !toggle) {
|
||||
@@ -19,6 +24,67 @@
|
||||
toggle.setAttribute('aria-expanded', isOpen ? 'true' : 'false');
|
||||
}
|
||||
|
||||
function setLeadModalState(isOpen, source) {
|
||||
if (!leadModal) {
|
||||
return;
|
||||
}
|
||||
|
||||
leadModal.hidden = !isOpen;
|
||||
body.classList.toggle('lead-modal-is-open', isOpen);
|
||||
|
||||
if (!isOpen) {
|
||||
return;
|
||||
}
|
||||
|
||||
var pageInput = leadModal.querySelector('input[name="lead_page"]');
|
||||
var sourceInput = leadModal.querySelector('input[name="lead_source"]');
|
||||
var firstInput = leadModal.querySelector('input[name="lead_name"]');
|
||||
|
||||
if (pageInput) {
|
||||
pageInput.value = document.title + ' | ' + window.location.pathname;
|
||||
}
|
||||
|
||||
if (sourceInput) {
|
||||
sourceInput.value = source || 'Попап заявки';
|
||||
}
|
||||
|
||||
if (firstInput) {
|
||||
window.setTimeout(function () {
|
||||
firstInput.focus();
|
||||
}, 80);
|
||||
}
|
||||
}
|
||||
|
||||
function applyPhoneMask(input) {
|
||||
var digits = input.value.replace(/\D/g, '');
|
||||
|
||||
if (digits.charAt(0) === '8') {
|
||||
digits = '7' + digits.slice(1);
|
||||
}
|
||||
|
||||
if (digits.charAt(0) === '7') {
|
||||
digits = digits.slice(1);
|
||||
}
|
||||
|
||||
digits = digits.slice(0, 10);
|
||||
|
||||
var value = '+7';
|
||||
if (digits.length > 0) {
|
||||
value += ' (' + digits.slice(0, 3);
|
||||
}
|
||||
if (digits.length >= 3) {
|
||||
value += ') ' + digits.slice(3, 6);
|
||||
}
|
||||
if (digits.length >= 6) {
|
||||
value += '-' + digits.slice(6, 8);
|
||||
}
|
||||
if (digits.length >= 8) {
|
||||
value += '-' + digits.slice(8, 10);
|
||||
}
|
||||
|
||||
input.value = value;
|
||||
}
|
||||
|
||||
if (menu && toggle) {
|
||||
toggle.addEventListener('click', function () {
|
||||
setMenuState(!menu.classList.contains('is-open'));
|
||||
@@ -46,6 +112,44 @@
|
||||
});
|
||||
}
|
||||
|
||||
leadOpenNodes.forEach(function (node) {
|
||||
node.addEventListener('click', function (event) {
|
||||
event.preventDefault();
|
||||
setMenuState(false);
|
||||
setLeadModalState(true, node.getAttribute('data-lead-source') || node.textContent.trim());
|
||||
});
|
||||
});
|
||||
|
||||
leadCloseNodes.forEach(function (node) {
|
||||
node.addEventListener('click', function () {
|
||||
setLeadModalState(false);
|
||||
});
|
||||
});
|
||||
|
||||
document.addEventListener('keydown', function (event) {
|
||||
if (event.key === 'Escape') {
|
||||
setLeadModalState(false);
|
||||
}
|
||||
});
|
||||
|
||||
phoneInputs.forEach(function (input) {
|
||||
input.addEventListener('focus', function () {
|
||||
if (!input.value) {
|
||||
input.value = '+7';
|
||||
}
|
||||
});
|
||||
|
||||
input.addEventListener('input', function () {
|
||||
applyPhoneMask(input);
|
||||
});
|
||||
});
|
||||
|
||||
emailInputs.forEach(function (input) {
|
||||
input.addEventListener('input', function () {
|
||||
input.value = input.value.replace(/\s/g, '').toLowerCase();
|
||||
});
|
||||
});
|
||||
|
||||
if (cookieNote && cookieButton && window.localStorage) {
|
||||
if (localStorage.getItem('sevTortCookieAccepted') !== 'yes') {
|
||||
cookieNote.hidden = false;
|
||||
|
||||
Reference in New Issue
Block a user