var menuMobile = { el: $('#menu-mobile'), sectionA: $('.section-a'), textPage: $('.text-page'), open: function() { /*var html = $('html'); html.css('overflow', 'hidden'); html.css('position', 'relative'); html.css('height', '100%');*/ var body = $('body'); body.css('overflow', 'hidden'); body.css('position', 'relative'); body.css('height', '100%'); //menuMobile.sectionA.css('filter', 'blur(5px)'); menuMobile.sectionA.find('header').css('opacity', '0'); menuMobile.sectionA.find('header').css('pointer-events', 'none'); menuMobile.sectionA.find('.main-block').css('opacity', '0'); menuMobile.textPage.css('opacity', '0'); $('#menu-button').removeClass('animate'); $('.buttons-mobile').find('.phone-button').removeClass('animate'); $('header').find('.logo-mobile').removeClass('animate'); $('#menu-mobile').show(); }, close: function() { /*var html = $('html'); html.css('overflow', 'visible'); html.css('position', 'static'); html.css('height', 'auto');*/ var body = $('body'); body.css('overflow', 'visible'); body.css('position', 'static'); body.css('height', 'auto'); //menuMobile.sectionA.css('filter', 'none'); menuMobile.sectionA.find('header').css('opacity', '1'); menuMobile.sectionA.find('header').css('pointer-events', 'auto'); menuMobile.sectionA.find('.main-block').css('opacity', '1'); menuMobile.textPage.css('opacity', '1'); $('#menu-button').addClass('animate'); $('.buttons-mobile').find('.phone-button').addClass('animate'); $('header').find('.logo-mobile').addClass('animate'); $('#menu-mobile').hide(); } }; var credit = { price: 100, period: 1, changeCredits: function () { let price = credit.price * 1000; let result = Intl.NumberFormat().format(Math.round(price / credit.period)); $('#result-count').html(result); } }; function submitModal(form) { if (window.locked) { return 0; } window.locked = true; var modal = $(form); var checkbox = modal.find('.checkbox'); if (!checkbox.prop('checked')) { alertErr('Нужно согласие на обработку данных'); window.locked = false; return false; } $.ajax({ type: 'POST', url: '/submit', data: $(form).serialize(), dataType: 'json', success: function(res) { if (res.result) { if ($(form).hasClass('form-samples')) { let address = 'http://камертон-ремонт.рф/'; let link = document.createElement('a'); let href = address + 'Samples.zip'; link.setAttribute('href', href); link.setAttribute('download', 'Samples.zip'); link.style.display = 'none'; document.body.appendChild(link); link.click(); document.body.removeChild(link); } var name = $(form).find('input[name="name"]').val(); if (name && name.length) { name = name.replace('script', ''); } if (name && name.length) { modal.find('.submit-name').html(', ' + name); Cookies.set('lead_name', name, { expires: 1 }); } else { Cookies.set('lead_name', '', { expires: 1 }); } location.href = '/spasibo'; window.locked = false; } else { //alertErr(res.display); $(form).find('.phone').addClass('error'); $(form).find('.phone').focus(); window.locked = false; } }, error: function() { window.locked = false; } }); } function openMoreBlocks() { $('#more-button').hide(); $('#wrapper-block').show(); $('#more-blocks').css('display', 'flex'); } function alertErr(err) { swal("Ошибка", err, "error"); setTimeout(function () { swal.close(); }, 5000); } $(function() { $('a[href^="#"]').on("click", function (n) { n.preventDefault(); var a = $(this).attr("href"), r = $(a).offset().top; $("html, body").animate({scrollTop: r+40}, 1e3); }); $('#more-button').on('click', openMoreBlocks); $('#menu-button').on('click', menuMobile.open); $('#close-menu-button').on('click', menuMobile.close); $('#menu-mobile').find('.link').on('click', menuMobile.close); $('.section-e').find('.field-checkbox').on('change', function(evt) { var length = $('.section-e').find('.field-checkbox:checked').length; $('.section-e').find('.field-label').removeClass('error'); if (length == 3) { $('.section-e').find('.field-checkbox:not(:checked) + .field-label').addClass('disable'); } else { $('.section-e').find('.field-label').removeClass('disable'); } if(length > 3) { this.checked = false; $('.section-e').find('.field-checkbox:not(:checked) + .field-label').addClass('disable'); //alertErr('Больше 3 услуг выбрать нельзя'); } else { $('.section-e').find('.checked-count').html(length); } }); $('.section-d').find('.consult-button').on('click', function() { $('.section-d').find('.calc-inner').hide(); $('.section-d').find('.consult-block').show(); var r = $('#consult-block').offset().top; $("html, body").animate({scrollTop: r}, 1e3); }); $('.phone').mask('+7 (999) 999-99-99', { completed: function() { this.closest('form').find('.modal-submit').addClass('active'); } } ); $('.projects-slider').owlCarousel({ loop: true, nav: false, items: 1, margin: 35, center: true, autoWidth: true }); $('.mockups-slider').owlCarousel({ loop: true, nav: false, items: 1, margin: 35, center: true, autoWidth: true }); $('.section-e').find('.next-button').on('click', function() { if ($('input[name=services]:checked').length < 3) { //alertErr('Выберите 3 услуги'); $('.section-e').find('.field-checkbox:not(:checked) + .field-label').addClass('error'); return; } $('.section-e').find('.title-main').hide(); $('.section-e').find('.subtitle').hide(); $('.section-e').find('.fields-block').hide(); $('.section-e').find('.order-block').show(); var r = $('#order-block').offset().top; $("html, body").animate({scrollTop: r}, 1e3); }); }); window.validateNumericInput = function(e) { return e.charCode >= 48 && e.charCode <= 57; }; window.validateFloatInput = function(e) { return e.charCode === 46 || e.charCode >= 48 && e.charCode <= 57; };