let scripts = function () { $('.js-toggle').on('click', function () { $(this).toggleClass('active'); }); $('.js-parent-toggle').on('click', function () { $(this).parent().toggleClass('active'); }); $('.js-parent-remove').on('click', function () { $(this).parent().remove(); }); $('.js-menu-toggle').on('click', function () { window.scrollTo(0, 0); $('#body').toggleClass('menu-is-actived'); }); $('.js-cookies-close').on('click', function () { $('#body').removeClass('cookies-is-actived'); }); $('.js-works-edit').on('click', function () { $(this).parent().parent().parent().addClass('active'); }); $('.js-works-remove').on('click', function () { $(this).parent().parent().parent().parent().remove(); }); $('[data-tab]').on('click', function () { $('[data-tab]').removeClass('active'); $('[data-body]').removeClass('showed'); $(this).addClass('active'); var id = $(this).data('tab'); $('[data-body=' + id + ']').addClass('showed'); }); $('.js-password-show').on('click', function () { $(this).parent().addClass('active'); $(this).parent().parent().find('input').attr('type', 'text'); }); $('.js-password-hide').on('click', function () { $(this).parent().removeClass('active'); $(this).parent().parent().find('input').attr('type', 'password'); }); let checkScrollTop = function () { if ($(document).scrollTop() == 0) { $('#body').removeClass('begin'); } else { $('#body').addClass('begin'); } } checkScrollTop(); $(document).on('scroll', function () { checkScrollTop(); }); let closeAll = function () { $('.js-toggle').removeClass('active'); $('.js-parent-toggle').parent().removeClass('active'); $('#body').removeClass('menu-is-actived'); $('#body').removeClass('cookies-is-actived'); } $(document).keyup(function (e) { if (e.key === "Escape") { closeAll(); } }); $('.js-scroll-to').bind('click', function (e) { let anchor = $(this); $('html,body').stop().animate({ scrollTop: $(anchor.attr('href')).offset().top }, 300); e.preventDefault(); }); if ($('[type=tel]').is('[type=tel]')) { $('[type=tel]').mask('+7 (999) 999-99-99'); } if ($('.js-select2').is('.js-select2')) { $('.js-select2').select2(); } const starRating = document.querySelectorAll(".js-stars"); if (starRating.length) { starRating.forEach(item => { new StarRating(item); }); } const checkboxes = document.querySelectorAll(".checkbox"); if (checkboxes.length) { checkboxes.forEach(checkbox => { const input = checkbox.querySelector("input"); checkbox.addEventListener("input", () => { if (input.checked) { input.setAttribute("checked", ""); } else { input.removeAttribute("checked"); } }); }); } const fullPicker = document.querySelectorAll(".js-picker"); if (fullPicker.length) { fullPicker.forEach(picker => { new Picker(picker, { controls: true, format: 'HH:mm', headers: true, text: { title: 'Выберите первое время обновления', cancel: 'Отменить', confirm: 'Сохранить', hour: 'Часы', minute: 'Минуты', }, }); }); } function controlAutoraiseToggle() { const toggle = document.querySelector('.js_autoraise_toggle'); const prompts = document.querySelectorAll('.js_autoraise_prompt'); if (toggle && prompts.length) { toggle.addEventListener('change', () => { if (toggle.checked) { prompts[0].classList.add('hidden'); prompts[1].classList.remove('hidden'); } else { prompts[0].classList.remove('hidden'); prompts[1].classList.add('hidden'); } }); } } controlAutoraiseToggle(); function controlAutoraiseSelect() { const inputs = document.querySelectorAll('.js-picker'); if (inputs.length && $('.js_autoraise_select').length) { $('.js_autoraise_select').on('select2:select', function (e) { const optionVal = +e.params.data.id; console.log(optionVal); inputs.forEach((input, i) => { if (i < optionVal) { input.disabled = false; } else { if (!input.classList.contains('time-send-tg')) { input.disabled = true; } } }); }); } } controlAutoraiseSelect(); }; let swipers = function () { if ($('.js-employer-swiper').is('.js-employer-swiper')) { let slider = new Swiper('.js-employer-swiper', { autoplay: { delay: 5000, }, pagination: { el: '.swiper-pagination', clickable: true }, breakpoints: { 768: { slidesPerView: 2, }, 992: { slidesPerView: 3, }, 1280: { slidesPerView: 4, }, } }); } if ($('.js-news-swiper').is('.js-news-swiper')) { let slider = new Swiper('.js-news-swiper', { spaceBetween: 20, pagination: { el: '.swiper-pagination', clickable: true }, navigation: { prevEl: '.js-news-swiper-button-prev', nextEl: '.js-news-swiper-button-next', }, breakpoints: { 768: { slidesPerView: 2, }, 992: { slidesPerView: 3, }, } }); } }; document.addEventListener("DOMContentLoaded", () => { scripts(); swipers(); }); $(window).resize(function () { swipers(); });