//Header openCatalog(); // кнопка каталог concatcUs(); // кнопка Заказать звонок chooseCity(); // выбрать город modalAuth(); // авторизация modalRestorePass(); // восстановить пароль modalRestorePassSuccess(); //восстановить пароль - успешно modalRestoreError(); // восстановить пароль - ошибка modalReg(); // регистрация //Footer footerSpoiler(); // спойлер моб версия //Главная страница swiperMain(); // swiper главная страница первый экран swiperMainMob(); // swiper первый экран до 780px swiperCatalog(); // swiper главная страница каталог catalogTabsHandler(); // переключатель табов каталога catalogButtonsHandler(); // в разделе каталог добавление в избранное и сравнить swiperMachines(); // swiper раздел Machines swiperPartners(); // swiper раздел Нам доверяют cookiePopup(); // показ Куки //Страница Карточка товара productPageSwiper(); // swiper первый экран productTabs(); // табы с описанием товара offerSwiper(); // swiper Выгодное предложение swiperProjects(); // swiper Реализованные проекты swiperViewed(); // swiper Недавно просматривали swiperModels(); // swiper Образцы изделей таб-3 telMask(); // Imask // telefonMask(); // маска телефона в форме swiperTab5(); // swiper Аксуссуары таб-5 swiperTab6(); // swiper Оснастка таб-6 swiperTab7(); // swiper Похожая техника таб-7 addToCart(); // открыть модальное окно Товар добален в корзину getConsult(); // открыть модальное окно - Заказать консультацию tableHover(); // таблица Характеристики выделение цветом //Модальное окно - Карточка товара кратко modalProductTabs(); // переключение табов modalViewed(); // раздел Недавно просматривали //Модальные окна orderParts(); // Модальное окно - Заказать запчасти addedToCart(); // настройка модального окна - Товар добавлен в корзину //Страница поиск результат resultPagination(); //Страница каталог toggleList(); // выподающий список toogleSorting(); // сортировка swiperArticles(); // swiper раздел Статьи по разделу swiperReviews(); // swiper Отзывы партнеров //Страница о компании swiperHistory(); // swiper история развития //Личный кабинет accountProfile(); // таб мой профиль accountOrders(); // мои заказы compareTable(); // переключение табов раздел сравнение contactsSwiper(); // раздел контакты // contactsMap(); // карта раздел контакты exitAccount(); // Выйти из аккаунта // Страница каталог подфильтры // catalogFilters(); //Header function openCatalog() { const catalogBtn = document.querySelector('.js_catalog_btn'); const modal = document.querySelector('.js_modal_catalog'); if (catalogBtn) { catalogBtn.addEventListener('click', (e) => { e.preventDefault(); catalogBtn.classList.toggle('catalog-open'); modal.classList.toggle('modal-catalog--hidden'); }); } document.addEventListener('keydown', function (event) { if (event.code === 'Escape' && !modal.classList.contains('modal-catalog--hidden')) { modal.classList.add('modal-catalog--hidden'); } }); } function concatcUs() { const openModalLink = document.querySelector('.js_header_button_call'); const closeModalBtn = document.querySelector('.js_modal_contact_close'); const modal = document.querySelector('.js_modal_contact'); const overlay = document.querySelector('.js_modal_contact_overlay'); const openModal = function () { modal.classList.remove('modal-contact--hidden'); overlay.classList.remove('modal-contact-overlay--hidden'); document.body.style.overflow = 'hidden'; }; const closeModal = function () { modal.classList.add('modal-contact--hidden'); overlay.classList.add('modal-contact-overlay--hidden'); document.body.style.overflow = null; }; if (openModalLink) { openModalLink.addEventListener('click', openModal); } if (closeModalBtn) { closeModalBtn.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.remove('modal-auth--hidden'); overlay.classList.remove('modal-auth-overlay--hidden'); document.body.style.overflow = 'hidden'; }; const closeModal = function () { modal.classList.add('modal-auth--hidden'); overlay.classList.add('modal-auth-overlay--hidden'); 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('modal-auth--hidden')) { 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 overlay = document.querySelector('.js_modal_restore_overlay'); const openModal = function () { modal.classList.remove('modal-restore--hidden'); overlay.classList.remove('modal-restore-overlay--hidden'); document.body.style.overflow = 'hidden'; }; const closeModal = function () { modal.classList.add('modal-restore--hidden'); overlay.classList.add('modal-restore-overlay--hidden'); 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('modal-restore--hidden')) { closeModal(); } }); } function modalRestorePassSuccess() { // const openModalLink = document.querySelector(''); 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 overlay = document.querySelector('.js_modal_restore_succ_overlay'); const openModal = function () { modal.classList.remove('modal-restore-succ--hidden'); overlay.classList.remove('modal-restore-succ-overlay--hidden'); document.body.style.overflow = 'hidden'; }; const closeModal = function () { modal.classList.add('modal-restore-succ--hidden'); overlay.classList.add('modal-restore-succ-overlay--hidden'); 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('modal-restore-succ--hidden')) { 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 overlay = document.querySelector('.js_modal_restore_error_overlay'); const openModal = function () { modal.classList.remove('modal-restore-error--hidden'); overlay.classList.remove('modal-restore-error-overlay--hidden'); document.body.style.overflow = 'hidden'; }; const closeModal = function () { modal.classList.add('modal-restore-error--hidden'); overlay.classList.add('modal-restore-error-overlay--hidden'); document.body.style.overflow = null; }; // if (openModalLink) { // openModalLink.addEventListener('click', openModal); // } if (closeModalBtn || closeModalInnerBack) { closeModalBtn.addEventListener('click', closeModal); closeModalInnerBack.addEventListener('click', closeModal); } document.addEventListener('keydown', function (event) { if (event.code === 'Escape' && !modal.classList.contains('modal-restore-error--hidden')) { closeModal(); } }); } function modalReg() { // const openModalLink = document.querySelector(''); const closeModalBtn = document.querySelector('.js_modal_reg_close'); const closeModalInner = document.querySelector('.js_back_inner'); const modal = document.querySelector('.js_modal_reg'); const overlay = document.querySelector('.js_modal_reg_overlay'); 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.remove('modal-reg--hidden'); overlay.classList.remove('modal-reg-overlay--hidden'); // document.body.style.overflow = 'hidden'; }; const closeModal = function () { modal.classList.add('modal-reg--hidden'); overlay.classList.add('modal-reg-overlay--hidden'); // 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', closeModal); } document.addEventListener('keydown', function (event) { if (event.code === 'Escape' && !modal.classList.contains('modal-reg--hidden')) { closeModal(); } }); 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'; } }); } } //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'); const viewedAcc = document.querySelector('.js_account_viewed'); tabs.forEach((tab) => { tab.addEventListener('click', function () { let currentBtn = tab; let tabId = currentBtn.getAttribute('data-tab'); let currentTab = document.querySelector(tabId); if (viewedAcc) { if (tabId === '.js-tab_3') { viewedAcc.classList.remove('account-viewed--hidden'); } else { viewedAcc.classList.add('account-viewed--hidden'); } } 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 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 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 telefonMask() { // const phoneInputs = document.querySelectorAll('.js_input_phone'); // phoneInputs.forEach((input) => { // setPhoneMask(input); // }); // function setPhoneMask(phoneInput) { // // маска для ввода номера телфона // function setCursorPosition(pos, elem) { // elem.focus(); // if (elem.setSelectionRange) elem.setSelectionRange(pos, pos); // else if (elem.createTextRange) { // var range = elem.createTextRange(); // range.collapse(true); // range.moveEnd('character', pos); // range.moveStart('character', pos); // range.select(); // } // } // // function mask(event) { // // var matrix = '+7 (___) ___-__-__', // // i = 0, // // def = matrix.replace(/\D/g, ''), // // val = this.value.replace(/\D/g, ''); // // if (def.length >= val.length) val = def; // // this.value = matrix.replace(/./g, function (a) { // // return /[_\d]/.test(a) && i < val.length // // ? val.charAt(i++) // // : i >= val.length // // ? '' // // : a; // // }); // // if (event.type == 'blur') { // // if (this.value.length == 2) this.value = ''; // // } else setCursorPosition(this.value.length, this); // // } // function mask(event) { // var matrix = '+7 (___) ___-__-__', // i = 0, // def = matrix.replace(/\D/g, ''), // val = this.value.replace(/\D/g, ''); // if (def.length >= val.length) val = def; // this.value = matrix.replace(/./g, function (a) { // return /[_\d]/.test(a) && i < val.length // ? val.charAt(i++) + (i == 4 || i == 7 ? '-' : '') // : i >= val.length // ? '' // : a; // }); // if (event.type == 'blur') { // if (this.value.length == 2) this.value = ''; // } else setCursorPosition(this.value.length, this); // } // var numberPhone = phoneInput; // if (numberPhone) { // numberPhone.addEventListener('input', mask, false); // numberPhone.addEventListener('focus', mask, false); // numberPhone.addEventListener('blur', mask, false); // } // } // } function offerSwiper() { var swiper = new Swiper('.swiper-catalog-item', { pagination: { el: '.swiper-pagination', clickable: true, }, }); } function swiperProjects() { var swiper = new Swiper('.swiper-projects', { slidesPerView: 3, spaceBetween: 30, navigation: { nextEl: '.swiper-button-next_projects', prevEl: '.swiper-button-prev_projects', }, }); } function swiperModels() { var swiper = new Swiper('.swiper-models', { slidesPerView: 3, spaceBetween: 20, navigation: { nextEl: '.swiper-button-next_models', prevEl: '.swiper-button-prev_models', }, scrollbar: { el: '.spec-scrollbar', hide: false, draggable: true, }, }); } function swiperViewed() { var swiper = new Swiper('.swiper-viewed', { slidesPerView: 4, spaceBetween: 20, 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 closeModalBtn = document.querySelector('.js_modal_added_close'); const closeInModalBtn = document.querySelector('.js_modal_added_button'); const modal = document.querySelector('.js_modal_added'); const overlay = document.querySelector('.js-modal_added_overlay'); const openModal = function () { modal.classList.remove('modal-added--hidden'); overlay.classList.remove('modal-added-overlay--hidden'); // document.body.style.overflow = 'hidden'; }; const closeModal = function () { modal.classList.add('modal-added--hidden'); overlay.classList.add('modal-added-overlay--hidden'); // document.body.style.overflow = null; }; if (openModalLink) { openModalLink.addEventListener('click', openModal); } if (closeModalBtn || closeInModalBtn) { closeModalBtn.addEventListener('click', closeModal); closeInModalBtn.addEventListener('click', closeModal); } } function getConsult() { const openModalLink = document.querySelector('.js-cart__info-links-consult'); const closeModalBtn = document.querySelector('.js_modal_parts_close'); const modal = document.querySelector('.js_modal_consult'); const overlay = document.querySelector('.js_modal-parts--overlay'); const openModal = function () { modal.classList.remove('modal-parts__hidden'); overlay.classList.remove('modal-parts__overlay__hidden'); document.body.style.overflow = 'hidden'; }; const closeModal = function () { modal.classList.add('modal-parts__hidden'); overlay.classList.add('modal-parts__overlay__hidden'); document.body.style.overflow = null; }; if (openModalLink) { openModalLink.addEventListener('click', openModal); } if (closeModalBtn) { closeModalBtn.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 closeModalBtn = document.querySelector('.js-modal-parts__close'); const modal = document.querySelector('.js_modal-parts'); const overlay = document.querySelector('.js_modal-parts--overlay'); const openModalParts = function () { modal.classList.remove('modal-parts__hidden'); overlay.classList.remove('modal-parts__overlay__hidden'); document.body.style.overflow = 'hidden'; }; const closeModalParts = function () { modal.classList.add('modal-parts__hidden'); overlay.classList.add('modal-parts__overlay__hidden'); document.body.style.overflow = null; }; if (openModalLink) { openModalLink.addEventListener('click', openModalParts); } if (closeModalBtn) { closeModalBtn.addEventListener('click', closeModalParts); } } // модальное окно - Заказать консультацию // модальное окно - Товар добавлен в корзину 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 resultPagination() { // const pagination = document.querySelector('.result-pagination'); // const prevBtn = pagination.querySelector('.result-prev'); // const nextBtn = pagination.querySelector('.result-next'); // const pages = pagination.querySelectorAll('.result-content-page'); // const numPages = 24;xw // const numVisiblePages = 3; // let currentPage = 1; } // каталог 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'); 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: 4, spaceBetween: 20, navigation: { nextEl: '.swiper-button-next__catalog-articles', prevEl: '.swiper-button-prev__catalog-articles', }, }); } function swiperReviews() { var swiper = new Swiper('.swiper-catalog-reviews', { slidesPerView: 3, spaceBetween: 20, navigation: { nextEl: '.swiper-button-next__catalog-reviews', prevEl: '.swiper-button-prev__catalog-reviews', }, }); } // о компании 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 (myProfileTab) { 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'); } }); }); } // function contactsMap() { ymaps.ready(function () { let center = [55.607504069131686, 38.11306499999998]; let map = new ymaps.Map('map', { 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 overlay = document.querySelector('.js_modal_acc_exit_overlay'); const tabs = document.querySelectorAll('.tab'); const openModal = function () { modal.classList.remove('modal-acc-exit--hidden'); overlay.classList.remove('modal-acc-exit-overlay--hidden'); document.body.style.overflow = 'hidden'; }; const closeModal = function () { modal.classList.add('modal-acc-exit--hidden'); overlay.classList.add('modal-acc-exit-overlay--hidden'); openModalLink.classList.remove('active'); document.body.style.overflow = null; }; 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', closeModal); } } // каталог подфильтры // function catalogFilters() { // function controlFromInput(fromSlider, fromInput, toInput, controlSlider) { // const [from, to] = getParsed(fromInput, toInput); // fillSlider(fromInput, toInput, '#C6C6C6', '#25daa5', controlSlider); // if (from > to) { // fromSlider.value = to; // fromInput.value = to; // } else { // fromSlider.value = from; // } // } // function controlToInput(toSlider, fromInput, toInput, controlSlider) { // const [from, to] = getParsed(fromInput, toInput); // fillSlider(fromInput, toInput, '#C6C6C6', '#25daa5', controlSlider); // setToggleAccessible(toInput); // if (from <= to) { // toSlider.value = to; // toInput.value = to; // } else { // toInput.value = from; // } // } // function controlFromSlider(fromSlider, toSlider, fromInput) { // const [from, to] = getParsed(fromSlider, toSlider); // fillSlider(fromSlider, toSlider, '#C6C6C6', '#F2994A', toSlider); // if (from > to) { // fromSlider.value = to; // fromInput.value = to; // } else { // fromInput.value = from; // } // } // function controlToSlider(fromSlider, toSlider, toInput) { // const [from, to] = getParsed(fromSlider, toSlider); // fillSlider(fromSlider, toSlider, '#C6C6C6', '#F2994A', toSlider); // setToggleAccessible(toSlider); // if (from <= to) { // toSlider.value = to; // toInput.value = to; // } else { // toInput.value = from; // toSlider.value = from; // } // } // function getParsed(currentFrom, currentTo) { // const from = parseInt(currentFrom.value, 10); // const to = parseInt(currentTo.value, 10); // return [from, to]; // } // function fillSlider(from, to, sliderColor, rangeColor, controlSlider) { // if (to) { // const rangeDistance = to.max - to.min; // const toPosition = to.value - to.min; // } // if (from) { // const fromPosition = from.value - to.min; // } // if (controlSlider) { // controlSlider.style.background = `linear-gradient( // to right, // ${sliderColor} 0%, // ${sliderColor} ${(fromPosition / rangeDistance) * 100}%, // ${rangeColor} ${(fromPosition / rangeDistance) * 100}%, // ${rangeColor} ${(toPosition / rangeDistance) * 100}%, // ${sliderColor} ${(toPosition / rangeDistance) * 100}%, // ${sliderColor} 100%)`; // } // } // function setToggleAccessible(currentTarget) { // if (currentTarget) { // const toSlider = document.querySelector('.js_to'); // if (Number(currentTarget.value) <= 0) { // toSlider.style.zIndex = 2; // } else { // toSlider.style.zIndex = 0; // } // } // } // const fromSlider = document.querySelector('.js_from'); // const toSlider = document.querySelector('.js_to'); // const fromInput = document.querySelector('.js_input_from'); // const toInput = document.querySelector('.js_input_to'); // fillSlider(fromSlider, toSlider, '#C6C6C6', '#F2994A', toSlider); // setToggleAccessible(toSlider); // fromSlider.oninput = () => controlFromSlider(fromSlider, toSlider, fromInput); // toSlider.oninput = () => controlToSlider(fromSlider, toSlider, toInput); // fromInput.oninput = () => controlFromInput(fromSlider, fromInput, toInput, toSlider); // toInput.oninput = () => controlToInput(toSlider, fromInput, toInput, toSlider); // }