//Header openCatalog(); // кнопка каталог concatcUs(); // кнопка Заказать звонок chooseCity(); // выбрать город modalAuth(); // авторизация modalRestorePass(); // восстановить пароль modalRestorePassSuccess(); //восстановить пароль - успешно modalRestoreError(); // восстановить пароль - ошибка modalReg(); // регистрация searchResult(); // focus input searchResultMob(); // поиск мобилки //Footer footerSpoiler(); // спойлер моб версия //Главная страница swiperMain(); // swiper главная страница первый экран swiperMainMob(); // swiper первый экран до 780px swiperCatalog(); // swiper главная страница каталог catalogTabsHandler(); // переключатель табов каталога catalogButtonsHandler(); // в разделе каталог добавление в избранное и сравнить swiperMachines(); // swiper раздел Machines swiperPartners(); // swiper раздел Нам доверяют cookiePopup(); // показ Куки //Страница Карточка товара productPageSwiper(); // swiper первый экран productPageMobSwiper(); // swiper первый экран мобилки productTabs(); // табы с описанием товара offerSwiper(); // swiper Выгодное предложение swiperProjects(); // swiper Реализованные проекты swiperViewed(); // swiper Недавно просматривали swiperModels(); // swiper Образцы изделей таб-3 fancyboxSliderProduct(); // образцы изделей telMask(); // Imask swiperTab5(); // swiper Аксуссуары таб-5 swiperTab6(); // swiper Оснастка таб-6 swiperTab7(); // swiper Похожая техника таб-7 addToCart(); // модальное окно Товар добален в корзину getConsult(); // модальное окно - Заказать консультацию tableHover(); // таблица Характеристики выделение цветом //Модальное окно - Карточка товара кратко modalProductTabs(); // переключение табов modalViewed(); // раздел Недавно просматривали //Модальные окна orderParts(); // Модальное окно - Заказать запчасти addedToCompare(); // Товар добавлен в сравнение addedToCart(); // настройка модального окна - Товар добавлен в корзину modalSubs(); // Поп-ап - успешная подписка на рассылку //Страница каталог toggleList(); // выподающий список toogleSorting(); // сортировка swiperArticles(); // swiper раздел Статьи по разделу swiperReviews(); // swiper Отзывы партнеров infoShowMore(); // мобильный верстка раздел полезная информация //Страница о компании swiperHistory(); // swiper история развития //Личный кабинет accountProfile(); // таб мой профиль accountOrders(); // мои заказы compareTable(); // переключение табов раздел сравнение contactsSwiper(); // раздел контакты // contactsMap(); // карта раздел контакты exitAccount(); // Выйти из аккаунта // Страница каталог подфильтры catalogFilters(); //страница Новости - новость swiperNewsItem(); //корзина cartCounter(); // счетчик количества в корзине modalCartOrder(); // Оформление заказа modalCartOrderSucc(); // заказ оформлен успешно //статьи swiperArticlesPage(); // swiper Последние статьи //Лицензии и сертификаты fancyboxSlider(); // поп-ап галерея //Вакансии openForm(); // кнопка откликнуться в вакансиии //Контакты contactsPageSwiper(); contactspageMap(); //демозал swiperDemohall(); // Корпоративная жизнь - мероприятие fancyboxSliderCorp(); //Header function openCatalog() { const catalogBtn = document.querySelector('.js_catalog_btn'); const modal = document.querySelector('.js_modal_catalog'); let clicked = false; const openModal = function () { modal.classList.add('active'); document.body.style.overflow = 'hidden'; catalogBtn.classList.add('catalog-open'); clicked = true; }; const closeModal = function () { modal.classList.remove('active'); document.body.style.overflow = null; catalogBtn.classList.remove('catalog-open'); }; function toggleModal() { if (!modal.classList.contains('active')) { openModal(); } else { closeModal(); } } if (catalogBtn) { catalogBtn.addEventListener('click', toggleModal); } if (modal) { document.addEventListener('click', (e) => { e.stopPropagation(); const clickBtn = e.composedPath().includes(catalogBtn); const click = e.composedPath().includes(modal); if (!click && !clickBtn && modal.classList.contains('active') && clicked) { closeModal(); } }); } } function concatcUs() { const openModalLink = document.querySelector('.js_header_button_call'); const openModalLinkMob = document.querySelector('.js_modal_call_mob'); const closeModalBtn = document.querySelector('.js_modal_contact_close'); const closeModalBtnMob = document.querySelector('.js_modal_contact_close_mob'); const modal = document.querySelector('.js_modal_contact'); const openModal = function () { modal.classList.add('active'); document.body.style.overflow = 'hidden'; }; const closeModal = function () { modal.classList.remove('active'); document.body.style.overflow = null; }; if (openModalLink) { openModalLink.addEventListener('click', openModal); } if (openModalLinkMob) { openModalLinkMob.addEventListener('click', openModal); } if (closeModalBtn) { closeModalBtn.addEventListener('click', closeModal); } if (closeModalBtnMob) { closeModalBtnMob.addEventListener('click', closeModal); } } function chooseCity() { const openModalBtn = document.querySelector('.js_city_choose'); const closeModalBtn = document.querySelector('.js_modal_city_close'); const modal = document.querySelector('.js_modal_city'); const overlay = document.querySelector('.js_modal_city_overlay'); let cities = document.querySelectorAll('.js_city_item'); const openModal = function () { modal.classList.remove('modal-city--hidden'); overlay.classList.remove('modal-city-overlay--hidden'); // document.body.style.overflow = 'hidden'; openModalBtn.classList.add('header-up-left__city--active'); }; const closeModal = function () { modal.classList.add('modal-city--hidden'); overlay.classList.add('modal-city-overlay--hidden'); // document.body.style.overflow = null; openModalBtn.classList.remove('header-up-left__city--active'); }; cities.forEach((city) => { city.addEventListener('click', (e) => { e.preventDefault(); let currentCity = city; if (!currentCity.classList.contains('city-main__item--active')) { cities.forEach((city) => { city.classList.remove('city-main__item--active'); }); currentCity.classList.add('city-main__item--active'); openModalBtn.innerHTML = currentCity.innerText; closeModal(); } }); }); if (openModalBtn) { openModalBtn.addEventListener('click', openModal); } if (closeModalBtn) { closeModalBtn.addEventListener('click', closeModal); } document.addEventListener('keydown', function (event) { if (event.code === 'Escape' && !modal.classList.contains('modal-city--hidden')) { closeModal(); } }); } function modalAuth() { // const openModalLink = document.querySelector('.js_header_entry'); const closeModalBtn = document.querySelector('.js_modal_auth_close'); const modal = document.querySelector('.js_modal_auth'); const overlay = document.querySelector('.js_modal_auth_overlay'); const passwordField = document.querySelector('.js_auth_pass'); const showPasswordBtn = document.querySelector('.js_auth_show_pass'); const openRestoreLink = document.querySelector('.js_restore_pass'); const openModal = function () { modal.classList.add('active'); document.body.style.overflow = 'hidden'; }; const closeModal = function () { modal.classList.remove('active'); document.body.style.overflow = null; }; // if (openModalLink) { // openModalLink.addEventListener('click', openModal); // } if (closeModalBtn || openRestoreLink) { closeModalBtn.addEventListener('click', closeModal); openRestoreLink.addEventListener('click', closeModal); } document.addEventListener('keydown', function (event) { if (event.code === 'Escape' && modal.classList.contains('active')) { closeModal(); } }); if (showPasswordBtn) { showPasswordBtn.addEventListener('click', function () { if (passwordField.type === 'password') { passwordField.type = 'text'; } else { passwordField.type = 'password'; } }); } } function modalRestorePass() { const openModalLink = document.querySelector('.js_restore_pass'); const closeModalBtn = document.querySelector('.js_modal_restore_close'); const closeModalInner = document.querySelector('.js_restore_back'); const modal = document.querySelector('.js_modal_restore'); const openModal = function () { document.body.style.overflow = 'hidden'; modal.classList.add('active'); }; const closeModal = function () { modal.classList.remove('active'); document.body.style.overflow = null; }; if (openModalLink) { openModalLink.addEventListener('click', openModal); } if (closeModalBtn || closeModalInner) { closeModalBtn.addEventListener('click', closeModal); closeModalInner.addEventListener('click', closeModal); } document.addEventListener('keydown', function (event) { if (event.code === 'Escape' && modal.classList.contains('active')) { closeModal(); } }); } function modalRestorePassSuccess() { // const openModalLink = document.querySelector('.js_test'); const closeModalBtn = document.querySelector('.js_modal_restore_succ_close'); const closeModalInner = document.querySelector('.js_res_succ_ok'); const closeModalInnerBack = document.querySelector('.js_res_succ_back'); const modal = document.querySelector('.js_modal_restore_succ'); const openModal = function () { modal.classList.add('active'); document.body.style.overflow = 'hidden'; }; const closeModal = function () { modal.classList.remove('active'); document.body.style.overflow = null; }; // if (openModalLink) { // openModalLink.addEventListener('click', openModal); // } if (closeModalBtn || closeModalInner || closeModalInnerBack) { closeModalBtn.addEventListener('click', closeModal); closeModalInner.addEventListener('click', closeModal); closeModalInnerBack.addEventListener('click', closeModal); } document.addEventListener('keydown', function (event) { if (event.code === 'Escape' && modal.classList.contains('active')) { closeModal(); } }); } function modalRestoreError() { // const openModalLink = document.querySelector('.js_test'); const closeModalBtn = document.querySelector('.js_modal_restore_error_close'); const closeModalInnerBack = document.querySelector('.js_restore_error_back'); const modal = document.querySelector('.js_modal_restore_error'); const openModal = function () { modal.classList.add('active'); document.body.style.overflow = 'hidden'; }; const closeModal = function () { modal.classList.remove('active'); document.body.style.overflow = null; }; // if (openModalLink) { // openModalLink.addEventListener('click', openModal); // } if (closeModalBtn || closeModalInnerBack) { closeModalBtn.addEventListener('click', closeModal); closeModalInnerBack.addEventListener('click', closeModal); } } function modalReg() { const openModalLink = document.querySelector('.js_header_entry'); const closeModalBtn = document.querySelector('.js_modal_reg_close'); const closeModalInner = document.querySelector('.js_back_inner'); const modal = document.querySelector('.js_modal_reg'); const passwordField = document.querySelector('.js_reg_pass'); const showPasswordBtn = document.querySelector('.js_reg_show_pass'); const passwordFieldConfirm = document.querySelector('.js_pass_conf'); const showPasswordConfirmBtn = document.querySelector('.js_reg_show_pass_conf'); const openRestoreLink = document.querySelector('.js_restore_pass'); const openModal = function () { modal.classList.add('active'); document.body.style.overflow = 'hidden'; }; const closeModal = function () { modal.classList.remove('active'); document.body.style.overflow = null; }; if (openModalLink) { openModalLink.addEventListener('click', openModal); } if (closeModalBtn || closeModalInner) { closeModalBtn.addEventListener('click', closeModal); closeModalInner.addEventListener('click', closeModal); } if (openRestoreLink) { openRestoreLink.addEventListener('click', () => { modal.classList.remove('active'); }); } if (showPasswordBtn) { showPasswordBtn.addEventListener('click', function () { if (passwordField.type === 'password') { passwordField.type = 'text'; } else { passwordField.type = 'password'; } }); } if (showPasswordConfirmBtn) { showPasswordConfirmBtn.addEventListener('click', function () { if (passwordFieldConfirm.type === 'password') { passwordFieldConfirm.type = 'text'; } else { passwordFieldConfirm.type = 'password'; } }); } } function searchResult() { const searchInput = document.querySelector('.js_search_input'); const results = document.querySelector('.js_search_result'); if (searchInput) { searchInput.addEventListener('focus', function () { searchInput.classList.add('infocus'); results.classList.add('active'); }); document.addEventListener('click', (e) => { const clickInput = e.composedPath().includes(searchInput); const clickResults = e.composedPath().includes(results); if (!clickInput && !clickResults && results.classList.contains('active')) { results.classList.remove('active'); searchInput.classList.remove('infocus'); } }); } } function searchResultMob() { const openModalLink = document.querySelector('.js_search_btn_mob'); const modal = document.querySelector('.js_modal_search_mobile'); const closeModalBtn = document.querySelector('.js_modal_search_mobile_close'); const openModal = function () { modal.classList.add('active'); document.body.style.overflow = 'hidden'; }; const closeModal = function () { modal.classList.remove('active'); document.body.style.overflow = null; }; if (openModalLink && modal) { openModalLink.addEventListener('click', openModal); } if (closeModalBtn) { closeModalBtn.addEventListener('click', closeModal); } } //Footer function footerSpoiler() { const spoilerButtons = document.querySelectorAll('.js_comp_btn'); let i; if (window.innerWidth < 481) { for (i = 0; i < spoilerButtons.length; i++) { spoilerButtons[i].addEventListener('click', function () { this.classList.toggle('footer-spoiler-button--active'); let panel = this.nextElementSibling; if (panel.style.maxHeight) { panel.style.maxHeight = null; } else { panel.style.maxHeight = panel.scrollHeight + 'px'; } }); } } else return; } //Главная страница function swiperMain() { var swiper = new Swiper('.mySwiper', { navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, allowSlidePrev: true, allowSlideNext: true, observer: true, observeParents: true, pagination: { el: '.swiper-pagination', paginationClickable: true, dynamicBullets: true, clickable: true, }, breakpoints: {}, mousewheel: true, keyboard: true, }); } function swiperMainMob() { var swiper = new Swiper('.swiper-mob', { slidesPerView: 1.15, centeredSlides: true, spaceBetween: 15, pagination: { el: '.mob-pagination', paginationClickable: true, // dynamicBullets: true, clickable: true, }, breakpoints: {}, mousewheel: true, keyboard: true, }); } function swiperCatalog() { var swiper = new Swiper('.swiperCatalog', { pagination: { el: '.swiper-pagination', clickable: true, }, }); } function swiperMachines() { var swiper = new Swiper('.swiper-machine', { slidesPerView: 1, spaceBetween: 20, allowTouchMove: true, breakpoints: { 780: { slidesPerView: 3, spaceBetween: 3, }, 1200: { allowTouchMove: false, spaceBetween: 3, }, }, }); } function swiperPartners() { var swiper = new Swiper('.swiper-partners', { slidesPerView: 2.3, spaceBetween: 30, navigation: { nextEl: '.swiper-button-next_partner', prevEl: '.swiper-button-prev_partner', }, breakpoints: { 950: { slidesPerView: 3, }, }, }); } function catalogButtonsHandler() { const addToFavorite = document.querySelectorAll('.js_favorite'); const addToCompare = document.querySelectorAll('.js_compare'); addToFavorite.forEach((btn) => { btn.addEventListener('click', (e) => { e.preventDefault(); btn.classList.toggle('swiper-icons-right__favorite_active'); }); }); addToCompare.forEach((btn) => { btn.addEventListener('click', (e) => { e.preventDefault(); btn.classList.toggle('swiper-icons-right__compare_active'); }); }); } function catalogTabsHandler() { const tabs = document.querySelectorAll('.tab'); const tabsItems = document.querySelectorAll('.tabs__item'); tabs.forEach((tab) => { tab.addEventListener('click', function () { let currentBtn = tab; let tabId = currentBtn.getAttribute('data-tab'); let currentTab = document.querySelector(tabId); if (!currentBtn.classList.contains('active')) { tabs.forEach((tab) => { tab.classList.remove('active'); }); tabsItems.forEach((tab) => { tab.classList.remove('tabs__item-active'); }); currentBtn.classList.add('active'); currentTab.classList.add('tabs__item-active'); } }); }); } function cookiePopup() { const cookiePopup = document.querySelector('.js_cookie_popup'); const cookieButton = document.querySelector('.js_cookie_popup_btn'); let cookieName = 'cookie-vekprom=accepted'; if (cookiePopup) { if (document.cookie.includes(cookieName)) { return; } else { cookiePopup.style.display = 'block'; cookieButton.addEventListener('click', () => { document.cookie = 'cookie-vekprom=accepted; max-age=31536000; path=/'; cookiePopup.style.display = 'none'; }); } } } // страница Карточка товара function productPageSwiper() { var galleryTop = new Swiper('.gallery', { spaceBetween: 10, grabCursor: true, loop: true, loopedSlides: 4, keyboard: { enabled: true, onlyInViewport: false, }, }); /* thumbs */ var galleryThumbs = new Swiper('.gallery-thumbs', { spaceBetween: 10, centeredSlides: true, slidesPerView: 'auto', touchRatio: 0.4, slideToClickedSlide: true, keyboard: { enabled: true, onlyInViewport: false, }, }); /* set conteoller */ galleryTop.controller.control = galleryThumbs; galleryThumbs.controller.control = galleryTop; } function productPageMobSwiper() { var swiper = new Swiper('.swiper-product-mobile', { pagination: { el: '.product-mob-pag', paginationClickable: true, clickable: true, }, }); } function productTabs() { const tabs = document.querySelectorAll('.js-specification__tab'); const tabsItems = document.querySelectorAll('.specification__tabs-item'); tabs.forEach((tab) => { tab.addEventListener('click', function () { let currentBtn = tab; let tabId = currentBtn.getAttribute('data-tab'); let currentTab = document.querySelector(tabId); if (!currentBtn.classList.contains('active')) { tabs.forEach((tab) => { tab.classList.remove('active'); }); tabsItems.forEach((tab) => { tab.classList.remove('specification__tabs-item_active'); }); currentBtn.classList.add('active'); currentTab.classList.add('specification__tabs-item_active'); } }); }); } function fancyboxSliderProduct() { const corpLife = document.querySelector('.specification'); if (corpLife) { Fancybox.bind('[data-fancybox="gallery"]', { contentClick: 'iterateZoom', Images: { Panzoom: { maxScale: 2, }, }, }); } } function telMask() { const phoneMaskSelector = '.js_input_phone'; const phoneMaskInputs = document.querySelectorAll(phoneMaskSelector); const masksOptions = { phone: { mask: '+{7} (000) 000-00-00', }, }; for (const item of phoneMaskInputs) { new IMask(item, masksOptions.phone); } } function offerSwiper() { var swiper = new Swiper('.swiper-catalog-item', { pagination: { el: '.swiper-pagination', clickable: true, }, }); } function swiperProjects() { var swiper = new Swiper('.swiper-projects', { slidesPerView: 2, spaceBetween: 30, navigation: { nextEl: '.swiper-button-next_projects', prevEl: '.swiper-button-prev_projects', }, breakpoints: { 1024: { slidesPerView: 3, }, }, }); } function swiperModels() { var swiper = new Swiper('.swiper-models', { slidesPerView: 1.2, spaceBetween: 20, navigation: { nextEl: '.swiper-button-next_models', prevEl: '.swiper-button-prev_models', }, scrollbar: { el: '.spec-scrollbar', hide: false, draggable: true, }, breakpoints: { 1024: { slidesPerView: 3, }, }, }); } function swiperViewed() { var swiper = new Swiper('.swiper-viewed', { slidesPerView: 1, spaceBetween: 20, breakpoints: { 375: { slidesPerView: 2, }, 640: { slidesPerView: 3, }, 1200: { slidesPerView: 4, }, }, navigation: { nextEl: '.swiper-button-next_viewed', prevEl: '.swiper-button-prev_viewed', }, }); } function swiperTab5() { var swiper = new Swiper('.swiper-tab-5', { slidesPerView: 1, navigation: { nextEl: '.swiper-button-next_tab-5', prevEl: '.swiper-button-prev_tab-5', }, }); } function swiperTab6() { var swiper = new Swiper('.swiper-tab-6', { slidesPerView: 1, navigation: { nextEl: '.swiper-button-next_tab-6', prevEl: '.swiper-button-prev_tab-6', }, }); } function swiperTab7() { var swiper = new Swiper('.swiper-tab-7', { slidesPerView: 4, navigation: { nextEl: '.swiper-button-next_tab-7', prevEl: '.swiper-button-prev_tab-7', }, }); } function addToCart() { const openModalLink = document.querySelector('.js_buy'); const openModalLinkMob = document.querySelector('.js_buy_mob'); const closeModalBtn = document.querySelector('.js_modal_added_close'); const closeInModalBtn = document.querySelector('.js_modal_added_button'); const modal = document.querySelector('.js_modal_added'); const openModal = function () { modal.classList.add('active'); document.body.style.overflow = 'hidden'; }; const closeModal = function () { modal.classList.remove('active'); document.body.style.overflow = null; }; if (openModalLink) { openModalLink.addEventListener('click', openModal); } if (openModalLinkMob) { openModalLinkMob.addEventListener('click', () => { console.log('hi'); }); } if (closeModalBtn || closeInModalBtn) { closeModalBtn.addEventListener('click', closeModal); closeInModalBtn.addEventListener('click', closeModal); } document.addEventListener('keydown', function (event) { if (event.code === 'Escape' && modal.classList.contains('active')) { closeModal(); } }); } function addedToCompare() { // const openModalLink = document.querySelectorAll('.js_compare'); const closeModalBtn = document.querySelector('.js_modal_compare_close'); const modal = document.querySelector('.js_modal_compare'); const openModal = function () { modal.classList.add('active'); document.body.style.overflow = 'hidden'; }; const closeModal = function () { modal.classList.remove('active'); document.body.style.overflow = null; }; // if (openModalLink) { // openModalLink.forEach((item) => { // item.addEventListener('click', function (e) { // e.preventDefault(); // openModal(); // }); // }); // } if (closeModalBtn) { closeModalBtn.addEventListener('click', closeModal); } } function getConsult() { const openModalLink = document.querySelector('.js-cart__info-links-consult'); const openModalLinkMob = document.querySelector('.js_product_mob_consult'); const closeModalBtn = document.querySelector('.js_modal_parts_close'); const closeModalBtnMob = document.querySelector('.js_modal_contact_close_mob'); const modal = document.querySelector('.js_modal_consult'); const openModal = function () { modal.classList.add('active'); document.body.style.overflow = 'hidden'; }; const closeModal = function () { modal.classList.remove('active'); document.body.style.overflow = null; }; if (openModalLink) { openModalLink.addEventListener('click', openModal); } if (openModalLinkMob) { openModalLinkMob.addEventListener('click', openModal); } if (closeModalBtn) { closeModalBtn.addEventListener('click', closeModal); } if (closeModalBtnMob) { closeModalBtnMob.addEventListener('click', closeModal); } } // Карточка товара кратко (модальное окно) function modalProductTabs() { const tabs = document.querySelectorAll('.js-modal-spec__tab'); const tabsItems = document.querySelectorAll('.js-modal-spec__tabs-item'); tabs.forEach((tab) => { tab.addEventListener('click', function () { let currentBtn = tab; let tabId = currentBtn.getAttribute('data-tab'); let currentTab = document.querySelector(tabId); if (!currentBtn.classList.contains('active')) { tabs.forEach((tab) => { tab.classList.remove('active'); }); tabsItems.forEach((tab) => { tab.classList.remove('modal-spec__tabs-item_active'); }); currentBtn.classList.add('active'); currentTab.classList.add('modal-spec__tabs-item_active'); } }); }); } function tableHover() { window.addEventListener('DOMContentLoaded', () => { const table = document.querySelector('.js_table_product'); const titles = document.querySelectorAll('.js_table_title'); const rows = document.querySelectorAll('.js_tr'); titles.forEach((title, i) => { title.addEventListener('mouseenter', () => { title.classList.add('active'); rows.forEach((row) => { if (row.querySelector('td')) { row.querySelectorAll('td')[i].classList.add('active'); } }); }); title.addEventListener('mouseleave', () => { title.classList.remove('active'); rows.forEach((row) => { if (row.querySelector('td')) { row.querySelectorAll('td')[i].classList.remove('active'); } }); }); }); }); } function modalViewed() { var swiper = new Swiper('.swiper-modal-viewed', { slidesPerView: 4, spaceBetween: 20, navigation: { nextEl: '.swiper-button-next_modal-viewed', prevEl: '.swiper-button-prev_modal-viewed', }, }); } // модальные окна // модальные окна - Заказать запчасти function orderParts() { const openModalLink = document.querySelector('.js-cart__info-links-parts'); const openModalLinkMob = document.querySelector('.js_product_mob_parts'); const closeModalBtn = document.querySelector('.js-modal-parts__close'); const closeModalBtnMob = document.querySelector('.js_modal_parts_close_mob'); const modal = document.querySelector('.js_modal-parts'); const openModal = function () { modal.classList.add('active'); document.body.style.overflow = 'hidden'; }; const closeModal = function () { modal.classList.remove('active'); document.body.style.overflow = null; }; if (openModalLink) { openModalLink.addEventListener('click', openModal); } if (openModalLinkMob) { openModalLinkMob.addEventListener('click', openModal); } if (closeModalBtn) { closeModalBtn.addEventListener('click', closeModal); } if (closeModalBtnMob) { closeModalBtnMob.addEventListener('click', closeModal); } } // модальное окно - Заказать консультацию // модальное окно - Товар добавлен в корзину function addedToCart() { var swiper = new Swiper('.swiper-modal-added', { slidesPerView: 3, spaceBetween: 20, navigation: { nextEl: '.modal-added-bottom__btn-next', prevEl: '.modal-added-bottom__btn-prev', }, scrollbar: { el: '.modal-added-scrollbar', hide: false, draggable: true, }, }); } function modalSubs() { // const openModalLink = document.querySelector('.js_test'); const closeModalBtn = document.querySelector('.js_modal_subscription_close'); const modal = document.querySelector('.js_modal_subscription'); const openModalParts = function () { modal.classList.add('active'); document.body.style.overflow = 'hidden'; }; const closeModalParts = function () { modal.classList.remove('active'); document.body.style.overflow = null; }; // if (openModalLink) { // openModalLink.addEventListener('click', openModalParts); // } if (closeModalBtn) { closeModalBtn.addEventListener('click', closeModalParts); } document.addEventListener('keydown', function (event) { if (event.code === 'Escape' && modal.classList.contains('active')) { closeModal(); } }); } // каталог function toggleList() { const acc = document.getElementsByClassName('js_catalog_accordion'); // const titleTwo = document.querySelector('.js_cat_acc_two'); // const titleThree = document.querySelector('.js_cat_acc_three'); // const titleFive = document.querySelector('.js_cat_acc_five'); // const titleSix = document.querySelector('.js_cat_acc_six'); // const titleSeven = document.querySelector('.js_cat_acc_seven'); // const titleEight = document.querySelector('.js_cat_acc_eight'); let i; for (i = 0; i < acc.length; i++) { acc[i].addEventListener('click', function () { this.classList.toggle('catalog-accordion--active'); if (this.classList.contains('catalog-filters-acc__button')) { this.classList.toggle('active'); } let panel = this.nextElementSibling; if (panel.style.maxHeight) { panel.style.maxHeight = null; } else { panel.style.maxHeight = panel.scrollHeight + 'px'; } }); } // if (titleTwo) { // titleTwo.addEventListener('click', function () { // titleTwo.classList.toggle('cat-acc-two--active'); // }); // } // if (titleThree) { // titleThree.addEventListener('click', function () { // titleThree.classList.toggle('cat-acc-three--active'); // }); // } // if (titleFive) { // titleFive.addEventListener('click', function () { // titleFive.classList.toggle('cat-acc-five--active'); // }); // } // if (titleSix) { // titleSix.addEventListener('click', function () { // titleSix.classList.toggle('cat-acc-six--active'); // }); // } // if (titleSeven) { // titleSeven.addEventListener('click', function () { // titleSeven.classList.toggle('cat-acc-seven--active'); // }); // } // if (titleEight) { // titleEight.addEventListener('click', function () { // titleEight.classList.toggle('cat-acc-eight--active'); // }); // } } function toogleSorting() { const sortingItems = document.querySelectorAll('.js_result_sorting_item'); sortingItems.forEach((item) => { item.addEventListener('click', () => { if (!item.classList.contains('result-sorting__item--active')) { sortingItems.forEach((item) => { item.classList.remove('result-sorting__item--active'); }); item.classList.add('result-sorting__item--active'); } }); }); } function swiperArticles() { var swiper = new Swiper('.swiper-catalog-articles', { slidesPerView: 2, spaceBetween: 20, navigation: { nextEl: '.swiper-button-next__catalog-articles', prevEl: '.swiper-button-prev__catalog-articles', }, breakpoints: { 780: { slidesPerView: 3, }, 1280: { slidesPerView: 4, }, }, }); } function swiperReviews() { var swiper = new Swiper('.swiper-catalog-reviews', { slidesPerView: 1.5, spaceBetween: 20, breakpoints: { 870: { slidesPerView: 2, }, 1300: { slidesPerView: 3, }, }, navigation: { nextEl: '.swiper-button-next__catalog-reviews', prevEl: '.swiper-button-prev__catalog-reviews', }, }); } function infoShowMore() { const catalogInfo = document.querySelector('.js_catalog_info'); const showMoreBtn = document.querySelector('.js_catalog_info_more'); if (showMoreBtn) { showMoreBtn.addEventListener('click', () => { catalogInfo.style.height = 'auto'; showMoreBtn.style.display = 'none'; }); } } // о компании function swiperHistory() { var swiper = new Swiper('.swiper-about-history', { direction: 'vertical', slidesPerView: 1, loopFillGroupWithBlank: true, centeredSlides: true, spaceBetween: 40, navigation: { nextEl: '.swiper-button-next__about-history', prevEl: '.swiper-button-prev__about-history', }, }); } // Личный кабинет function accountProfile() { const changePassLink = document.querySelector('.js_profile_pass'); const profileData = document.querySelector('.js_profile_data'); const profileChangePass = document.querySelector('.js_change_pass'); const snowPassNew = document.querySelector('.js_prof_pass_new'); const passwordField = document.querySelector('.js_prof_show_pass'); const myProfileTab = document.querySelector('.js_my_profile'); if (changePassLink) { changePassLink.addEventListener('click', () => { profileData.classList.add('profile-block-wrapper--hidden'); profileChangePass.classList.remove('change-pass-wrapper--hidden'); }); } if (snowPassNew) { snowPassNew.addEventListener('click', function () { console.log(passwordField.type); if (passwordField.type === 'password') { passwordField.type = 'text'; } else { passwordField.type = 'password'; } }); } if (profileChangePass) { myProfileTab.addEventListener('click', () => { if (!profileChangePass.classList.contains('change-pass-wrapper--hidden')) { profileChangePass.classList.add('change-pass-wrapper--hidden'); profileData.classList.remove('profile-block-wrapper--hidden'); } }); } } function accountOrders() { const acc = document.querySelectorAll('.js_open_accordion'); let i; for (i = 0; i < acc.length; i++) { acc[i].addEventListener('click', function () { this.classList.toggle('orders-acc__btn--active'); if (this.classList.contains('orders-acc__btn--active')) { this.textContent = 'Свернуть'; } else { this.textContent = 'Посмотреть заказ'; } let panel = this.nextElementSibling; panel.style.display = 'block'; if (panel.style.maxHeight) { panel.style.display = 'none'; panel.style.maxHeight = null; } else { panel.style.maxHeight = panel.scrollHeight + 'px'; } }); } } function contactsSwiper() { var swiper = new Swiper('.swiper-acc-contacts', { slidesPerView: 3, spaceBetween: 20, scrollbar: { el: '.spec-scrollbar', hide: false, draggable: true, }, }); } function compareTable() { const tabs = document.querySelectorAll('.compare-tab'); const tabsItems = document.querySelectorAll('.compare-tabs__item'); tabs.forEach((tab) => { tab.addEventListener('click', function () { let currentBtn = tab; let tabId = currentBtn.getAttribute('data-t'); console.log('tabid', tabId); let currentTab = document.querySelector(tabId); console.log('currentTab', currentTab); if (!currentBtn.classList.contains('active')) { tabs.forEach((tab) => { tab.classList.remove('active'); }); tabsItems.forEach((tab) => { tab.classList.remove('compare-tabs__item--active'); }); currentBtn.classList.add('active'); currentTab.classList.add('compare-tabs__item--active'); } }); }); } const accMaps = document.querySelector('.acc-maps-wrapper'); if (accMaps) { ymaps.ready(function () { let center = [55.607504069131686, 38.11306499999998]; let map = new ymaps.Map('acc-page-one', { center: center, zoom: 16, }); let placemark = new ymaps.Placemark( center, {}, { iconLayout: 'default#image', iconImageHref: './img/svg/map-placemark.svg', iconImageSize: [69, 87], iconImageOffset: [-20, -70], }, ); map.controls.remove('geolocationControl'); // удаляем геолокацию map.controls.remove('searchControl'); // удаляем поиск map.controls.remove('trafficControl'); // удаляем контроль трафика map.controls.remove('typeSelector'); // удаляем тип map.controls.remove('fullscreenControl'); // удаляем кнопку перехода в полноэкранный режим map.controls.remove('zoomControl'); // удаляем контрол зуммирования map.controls.remove('rulerControl'); // удаляем контрол правил map.geoObjects.add(placemark); }); } function exitAccount() { const openModalLink = document.querySelector('.js_exit_acc'); const closeModalBtn = document.querySelector('.js_acc_exit_cancel'); const modal = document.querySelector('.js_modal_acc_exit'); const tabs = document.querySelectorAll('.tab'); const firstItemList = document.querySelector('.account-tabs li:first-child'); const accTabs = document.querySelectorAll('.tabs__item'); const openModal = function () { document.body.style.overflow = 'hidden'; modal.classList.add('active'); }; const closeInside = function () { accTabs.forEach((item) => { if (item.classList.contains('tabs__item-active')) { item.classList.remove('tabs__item-active'); } }); modal.classList.remove('active'); document.body.style.overflow = null; openModalLink.classList.remove('active'); firstItemList.click(); }; if (openModalLink) { openModalLink.addEventListener('click', () => { tabs.forEach((tab) => { tab.classList.remove('active'); }); openModalLink.classList.add('active'); }); openModalLink.addEventListener('click', openModal); } if (closeModalBtn) { closeModalBtn.addEventListener('click', closeInside); } } // каталог подфильтры function catalogFilters() { priceRange(); powerRange(); diametrRange(); deepRange(); runRange(); function priceRange() { let rangeMin = 100; const range = document.querySelector('.range-selected'); const rangeInput = document.querySelectorAll('.range-input input'); const rangePrice = document.querySelectorAll('.range-price input'); rangeInput.forEach((input) => { input.addEventListener('input', (e) => { let minRange = parseInt(rangeInput[0].value); let maxRange = parseInt(rangeInput[1].value); if (maxRange - minRange < rangeMin) { if (e.target.className === 'min') { rangeInput[0].value = maxRange - rangeMin; } else { rangeInput[1].value = minRange + rangeMin; } } else { rangePrice[0].value = minRange; rangePrice[1].value = maxRange; range.style.left = (minRange / rangeInput[0].max) * 100 + '%'; range.style.right = 100 - (maxRange / rangeInput[1].max) * 100 + '%'; } }); }); rangePrice.forEach((input) => { input.addEventListener('input', (e) => { let minPrice = rangePrice[0].value; let maxPrice = rangePrice[1].value; if (maxPrice - minPrice >= rangeMin && maxPrice <= rangeInput[1].max) { if (e.target.className === 'min') { rangeInput[0].value = minPrice; range.style.left = (minPrice / rangeInput[0].max) * 100 + '%'; } else { rangeInput[1].value = maxPrice; range.style.right = 100 - (maxPrice / rangeInput[1].max) * 100 + '%'; } } }); }); } function powerRange() { let rangeMin = 100; const range = document.querySelector('.js_range_selected_power'); const rangeInput = document.querySelectorAll('.js_range_input_power input'); const rangePrice = document.querySelectorAll('.js_range_price_power input'); rangeInput.forEach((input) => { input.addEventListener('input', (e) => { let minRange = parseInt(rangeInput[0].value); let maxRange = parseInt(rangeInput[1].value); if (maxRange - minRange < rangeMin) { if (e.target.className === 'min') { rangeInput[0].value = maxRange - rangeMin; } else { rangeInput[1].value = minRange + rangeMin; } } else { rangePrice[0].value = minRange; rangePrice[1].value = maxRange; range.style.left = (minRange / rangeInput[0].max) * 100 + '%'; range.style.right = 100 - (maxRange / rangeInput[1].max) * 100 + '%'; } }); }); rangePrice.forEach((input) => { input.addEventListener('input', (e) => { let minPrice = rangePrice[0].value; let maxPrice = rangePrice[1].value; if (maxPrice - minPrice >= rangeMin && maxPrice <= rangeInput[1].max) { if (e.target.className === 'min') { rangeInput[0].value = minPrice; range.style.left = (minPrice / rangeInput[0].max) * 100 + '%'; } else { rangeInput[1].value = maxPrice; range.style.right = 100 - (maxPrice / rangeInput[1].max) * 100 + '%'; } } }); }); } function diametrRange() { let rangeMin = 1; const range = document.querySelector('.js_range_selected_dia'); const rangeInput = document.querySelectorAll('.js_range_input_dia input'); const rangePrice = document.querySelectorAll('.js_range_price_dia input'); rangeInput.forEach((input) => { input.addEventListener('input', (e) => { let minRange = parseInt(rangeInput[0].value); let maxRange = parseInt(rangeInput[1].value); if (maxRange - minRange < rangeMin) { if (e.target.className === 'min') { rangeInput[0].value = maxRange - rangeMin; } else { rangeInput[1].value = minRange + rangeMin; } } else { rangePrice[0].value = minRange; rangePrice[1].value = maxRange; range.style.left = (minRange / rangeInput[0].max) * 100 + '%'; range.style.right = 100 - (maxRange / rangeInput[1].max) * 100 + '%'; } }); }); rangePrice.forEach((input) => { input.addEventListener('input', (e) => { let minPrice = rangePrice[0].value; let maxPrice = rangePrice[1].value; if (maxPrice - minPrice >= rangeMin && maxPrice <= rangeInput[1].max) { if (e.target.className === 'min') { rangeInput[0].value = minPrice; range.style.left = (minPrice / rangeInput[0].max) * 100 + '%'; } else { rangeInput[1].value = maxPrice; range.style.right = 100 - (maxPrice / rangeInput[1].max) * 100 + '%'; } } }); }); } function deepRange() { let rangeMin = 1; const range = document.querySelector('.js_range_selected_deep'); const rangeInput = document.querySelectorAll('.js_range_input_deep input'); const rangePrice = document.querySelectorAll('.js_range_price_deep input'); rangeInput.forEach((input) => { input.addEventListener('input', (e) => { let minRange = parseInt(rangeInput[0].value); let maxRange = parseInt(rangeInput[1].value); if (maxRange - minRange < rangeMin) { if (e.target.className === 'min') { rangeInput[0].value = maxRange - rangeMin; } else { rangeInput[1].value = minRange + rangeMin; } } else { rangePrice[0].value = minRange; rangePrice[1].value = maxRange; range.style.left = (minRange / rangeInput[0].max) * 100 + '%'; range.style.right = 100 - (maxRange / rangeInput[1].max) * 100 + '%'; } }); }); rangePrice.forEach((input) => { input.addEventListener('input', (e) => { let minPrice = rangePrice[0].value; let maxPrice = rangePrice[1].value; if (maxPrice - minPrice >= rangeMin && maxPrice <= rangeInput[1].max) { if (e.target.className === 'min') { rangeInput[0].value = minPrice; range.style.left = (minPrice / rangeInput[0].max) * 100 + '%'; } else { rangeInput[1].value = maxPrice; range.style.right = 100 - (maxPrice / rangeInput[1].max) * 100 + '%'; } } }); }); } function runRange() { let rangeMin = 1; const range = document.querySelector('.js_range_selected_run'); const rangeInput = document.querySelectorAll('.js_range_input_run input'); const rangePrice = document.querySelectorAll('.js_range_price_run input'); rangeInput.forEach((input) => { input.addEventListener('input', (e) => { let minRange = parseInt(rangeInput[0].value); let maxRange = parseInt(rangeInput[1].value); if (maxRange - minRange < rangeMin) { if (e.target.className === 'min') { rangeInput[0].value = maxRange - rangeMin; } else { rangeInput[1].value = minRange + rangeMin; } } else { rangePrice[0].value = minRange; rangePrice[1].value = maxRange; range.style.left = (minRange / rangeInput[0].max) * 100 + '%'; range.style.right = 100 - (maxRange / rangeInput[1].max) * 100 + '%'; } }); }); rangePrice.forEach((input) => { input.addEventListener('input', (e) => { let minPrice = rangePrice[0].value; let maxPrice = rangePrice[1].value; if (maxPrice - minPrice >= rangeMin && maxPrice <= rangeInput[1].max) { if (e.target.className === 'min') { rangeInput[0].value = minPrice; range.style.left = (minPrice / rangeInput[0].max) * 100 + '%'; } else { rangeInput[1].value = maxPrice; range.style.right = 100 - (maxPrice / rangeInput[1].max) * 100 + '%'; } } }); }); } } // страница Новости - новость function swiperNewsItem() { var swiper = new Swiper('.news-item-swiper', { slidesPerView: 3, spaceBetween: 50, navigation: { nextEl: '.swiper-button-next__news-item', prevEl: '.swiper-button-prev__news-item', }, }); } // страница Корзина function cartCounter() { const buttons = document.querySelectorAll('.js_btn_counter'); buttons.forEach((button) => { button.addEventListener('click', () => { const targetId = button.dataset.target; const targetInput = document.querySelector(targetId); const action = button.dataset.action; if (action === 'increment') { targetInput.value = parseInt(targetInput.value) + 1; } else if (action === 'decrement') { targetInput.value = parseInt(targetInput.value) - 1; } }); }); } function modalCartOrder() { const openModalLink = document.querySelector('.js_order_link'); const closeModalBtn = document.querySelector('.js-modal-parts__close'); const modal = document.querySelector('.js_modal_order'); const openModal = function () { modal.classList.add('active'); document.body.style.overflow = 'hidden'; }; const closeModal = function () { modal.classList.remove('active'); document.body.style.overflow = null; }; if (openModalLink) { openModalLink.addEventListener('click', openModal); } if (closeModalBtn) { closeModalBtn.addEventListener('click', closeModal); } document.addEventListener('keydown', function (event) { if (event.code === 'Escape' && modal.classList.contains('active')) { closeModal(); } }); } function modalCartOrderSucc() { // const openModalLink = document.querySelector('.js_test'); const closeModalBtn = document.querySelector('.js_modal_order_succ_close'); const modal = document.querySelector('.js_modal_order_succ'); const openModal = function () { modal.classList.add('active'); document.body.style.overflow = 'hidden'; }; const closeModal = function () { modal.classList.remove('active'); document.body.style.overflow = null; }; // if (openModalLink) { // openModalLink.addEventListener('click', openModal); // } if (closeModalBtn) { closeModalBtn.addEventListener('click', closeModal); } document.addEventListener('keydown', function (event) { if (event.code === 'Escape' && modal.classList.contains('active')) { closeModal(); } }); } function swiperArticlesPage() { var swiper = new Swiper('.swiper-articles', { slidesPerView: 4, spaceBetween: 20, navigation: { nextEl: '.swiper-button-next__catalog-reviews', prevEl: '.swiper-button-prev__catalog-reviews', }, }); } // Лицензии и сертификаты function fancyboxSlider() { const certificates = document.querySelector('.js_certificates'); if (certificates) { Fancybox.bind('[data-fancybox="gallery"]', {}); } } //Вакансии function openForm() { const openFormLink = document.querySelectorAll('.js_job_open'); const formBlock = document.querySelectorAll('.vacancies-item-bottom'); openFormLink.forEach((item) => { item.addEventListener('click', () => { let currentLink = item; let formBlockId = currentLink.getAttribute('data-link'); let currentBlock = document.querySelector(formBlockId); currentBlock.style.display = 'block'; currentLink.style.display = 'none'; }); }); } // страница контакты function contactsPageSwiper() { var swiper = new Swiper('.swiper-contacts-page', { slidesPerView: 4, spaceBetween: 20, scrollbar: { el: '.spec-scrollbar', hide: false, draggable: true, }, navigation: { nextEl: '.swiper-button-next__catalog-reviews', prevEl: '.swiper-button-prev__catalog-reviews', }, }); } const contactPage = document.querySelector('.js_cnt_map_wrapper'); if (contactPage) { ymaps.ready(function () { let center = [55.60358306912159, 38.129899499999965]; let map = new ymaps.Map('contacts-page-map-one', { center: center, zoom: 17, }); let placemark = new ymaps.Placemark( center, {}, { iconLayout: 'default#image', iconImageHref: './img/svg/map-placemark.svg', iconImageSize: [69, 87], iconImageOffset: [-40, -90], }, ); // map.controls.remove('geolocationControl'); // удаляем геолокацию map.controls.remove('searchControl'); // удаляем поиск map.controls.remove('trafficControl'); // удаляем контроль трафика map.controls.remove('typeSelector'); // удаляем тип map.controls.remove('fullscreenControl'); // удаляем кнопку перехода в полноэкранный режим // map.controls.remove('zoomControl'); // удаляем контрол зуммирования map.controls.remove('rulerControl'); // удаляем контрол правил map.geoObjects.add(placemark); }); } if (contactPage) { ymaps.ready(function () { let center = [55.607504069131686, 38.11306499999998]; let map = new ymaps.Map('contacts-page-map-two', { center: center, zoom: 16, }); let placemark = new ymaps.Placemark( center, {}, { iconLayout: 'default#image', iconImageHref: './img/svg/map-placemark.svg', iconImageSize: [69, 87], iconImageOffset: [-40, -90], }, ); // map.controls.remove('geolocationControl'); // удаляем геолокацию map.controls.remove('searchControl'); // удаляем поиск map.controls.remove('trafficControl'); // удаляем контроль трафика map.controls.remove('typeSelector'); // удаляем тип map.controls.remove('fullscreenControl'); // удаляем кнопку перехода в полноэкранный режим // map.controls.remove('zoomControl'); // удаляем контрол зуммирования map.controls.remove('rulerControl'); // удаляем контрол правил map.geoObjects.add(placemark); }); } if (contactPage) { ymaps.ready(function () { let center = [55.77317006896182, 37.6776425]; let map = new ymaps.Map('contacts-page-map-three', { center: center, zoom: 17, }); let placemark = new ymaps.Placemark( center, {}, { iconLayout: 'default#image', iconImageHref: './img/svg/map-placemark.svg', iconImageSize: [69, 87], iconImageOffset: [-40, -90], }, ); // map.controls.remove('geolocationControl'); // удаляем геолокацию map.controls.remove('searchControl'); // удаляем поиск map.controls.remove('trafficControl'); // удаляем контроль трафика map.controls.remove('typeSelector'); // удаляем тип map.controls.remove('fullscreenControl'); // удаляем кнопку перехода в полноэкранный режим // map.controls.remove('zoomControl'); // удаляем контрол зуммирования map.controls.remove('rulerControl'); // удаляем контрол правил map.geoObjects.add(placemark); }); } if (contactPage) { ymaps.ready(function () { let center = [51.55085957238009, 46.01793399999996]; let map = new ymaps.Map('contacts-page-map-four', { center: center, zoom: 17, }); let placemark = new ymaps.Placemark( center, {}, { iconLayout: 'default#image', iconImageHref: './img/svg/map-placemark.svg', iconImageSize: [69, 87], iconImageOffset: [-40, -90], }, ); // map.controls.remove('geolocationControl'); // удаляем геолокацию map.controls.remove('searchControl'); // удаляем поиск map.controls.remove('trafficControl'); // удаляем контроль трафика map.controls.remove('typeSelector'); // удаляем тип map.controls.remove('fullscreenControl'); // удаляем кнопку перехода в полноэкранный режим // map.controls.remove('zoomControl'); // удаляем контрол зуммирования map.controls.remove('rulerControl'); // удаляем контрол правил map.geoObjects.add(placemark); }); } function contactspageMap() { const blocks = document.querySelectorAll('.js_cnt_block'); const maps = document.querySelectorAll('.js_cnt_map'); blocks.forEach((block) => { block.addEventListener('click', () => { let currentBlock = block; let blockId = currentBlock.getAttribute('data-tab'); let currentMap = document.querySelector(blockId); if (!currentBlock.classList.contains('contacts-page-block--active')) { blocks.forEach((block) => { block.classList.remove('contacts-page-block--active'); }); maps.forEach((map) => { map.classList.remove('active'); }); currentBlock.classList.add('contacts-page-block--active'); currentMap.classList.add('active'); } }); }); } function swiperDemohall() { var swiper = new Swiper('.swiper-demohall', { slidesPerView: 4, spaceBetween: 20, navigation: { nextEl: '.swiper-button-next__catalog-reviews', prevEl: '.swiper-button-prev__catalog-reviews', }, }); } //Корпоративгая жизнь function fancyboxSliderCorp() { const corpLife = document.querySelector('.js_corp_life'); if (corpLife) { Fancybox.bind('[data-fancybox="gallery"]', {}); } }