$(document).ready(function() { footerBottom(); seoTxt(); scrollUp(); callMobile(); modalForms(); pagination(); openMobMenuNew(); closeMobMenu(); searchMobile(); priceSlider(); priceSliderFixInputTxt(); filtersBlockShowTabletMobile(); mobTags(); phoneMask(); mobMenu(); $(document).on('click', '.remove_ico', confirmRemove); $(document).on('click', '.remove_confirm a', removeBasket); $(document).on('click', '.quantity-wr span', changeBasket); $(document).on('change', '.quantity-wr input', setBasket); $(document).on('keypress', '.quantity-wr input', setControl); $(document).on('click', '.selected-size-basket span', showBasketSize); $(document).on('click', '.hidden-size-basket ul li', setBasketSize); $('body').on('click', '.btn-bye-card', function(e) { // console.log('ololo'); e.preventDefault(); var id = $(this).data('id'); var count = $("#product-count").val(); basket.add(id, count); }); $('body').on('click', '.btn_buy_basket', function(e) { // console.log('ololo'); e.preventDefault(); var id = $(this).data('id'); basket.add(id, 1); }); if ($('#price_interval').length) { priceSlider(); priceSliderFixInputTxt(); } $(document).on('click', '.basket-modal-bg #modal_close, #modal_close-2, #overlay', closeHideBasket); function confirmRemove(e) { e.preventDefault(); $(this) .parent() .addClass('confirm'); } function removeBasket(e) { e.preventDefault(); if ($(this).hasClass('remove-yes')) { var variant = $(this).parents('tr.variant_tr').data('variant'); //удаление ячейки "tr" в корзине basket.remove(variant).done(function(data) { updateStaticBasket(data.modal); if(data.basket.length == 0) { $("div#basket_content").html('
Ваша корзина пуста
'); } }); $(this).parents('.confirm').parent().remove() } else { $(this) .parents('.confirm').removeClass('confirm') } } function changeBasket(e) { e.preventDefault(); var variant = $(this).parents('tr.variant_tr').data('variant'); var input = $(this).parent().parent().find('input'); var oldVal = input.val(); if ($(this).hasClass('minus')) { console.log('minus'); if (oldVal > 1) { basket.add(variant, -1).done(function(data) { updateStaticBasket(data.modal); }); } } else { console.log('pluse'); basket.add(variant, 1).done(function(data) { updateStaticBasket(data.modal); }); } } var event = new Event('basketChange'); function updateStaticBasket(modal) { // Вызываем событие document.dispatchEvent(event); basketContent = $('.basket_page'); if(basketContent.length) { basketContent.html($(modal).find('.basket_content').html()); } if ($("#basket_modal").hasClass('checkout_basket')){ $("#modal_close-2").remove(); } } function setBasket(e) { e.preventDefault(); var variant = $(this).parents('tr.variant_tr').data('variant'); var count = $(this).val(); basket.set(variant, count).done(function(data) { updateStaticBasket(data.modal); }); } function setControl(e) { if (e.which == 13) { $(this) .trigger('change'); return false; } else if (!(e.which == 8 || (e.which > 47 && e.which < 58))) { return false; } } function closeHideBasket() { $('#overlay').fadeOut(400); $('.basket_modal').animate({opacity: 0, top: '0'}, 200,function(){ $(this).css('display', 'none'); $('#overlay').fadeOut(400); }); } function showBasketSize() { $(this).parent().parent().toggleClass('active'); } function setBasketSize() { $(this).parent().find('li').removeClass('active'); $(this).addClass('active'); var thisSize = +($(this).html()); $(this).parent().parent().parent().removeClass('active').find('.selected-size-basket span').html(thisSize); } function footerBottom(){ var heightHeader = document.getElementById('header_').offsetHeight var heightFooter = document.getElementById('footer_').offsetHeight var windowHeight = window.innerHeight document.getElementById('content_').style.minHeight = windowHeight-heightHeader-heightFooter+'px'; } function mobOverlayAdd() { if($('body').find('.mob-overlay').length > 0) { } else { $('body').append('
') } $('.mob-overlay').fadeIn(300); } function mobOverlayRemove() { $('.mob-overlay').fadeOut(300); $('body').removeClass('show-block-mobile'); setTimeout(function () { $('body').removeClass('body-fixed'); },510) } function openMobMenuNew() { $('.menu_mob').click(function () { mobOverlayAdd() $('body').addClass('body-fixed show-block-mobile'); }) } function closeCallMobileHide() { $('.call-mobile-wr').removeClass('visible') setTimeout(function () { $('.call-mobile-wr').removeClass('open') },200) } function closeMobMenu() { $('body').on('click','.mob-overlay',function () { mobOverlayRemove(); }) $('.close-mobile-menu').click(function () { mobOverlayRemove(); }) } var txt1 = $('.all_unnecessary_text').data('show'); var txt2 = $('.all_unnecessary_text').data('hide'); function seoTxt() { $('.all_unnecessary_text').click(function (e) { e.preventDefault() $('.unnecessary_text').toggleClass('show') $(this).toggleClass('show') if($(this).hasClass('show')) { $(this).html(txt2) } else { $(this).html(txt1); } }) var mobSeo = false; if($(window).width()<=767) { mobSeo = true; $('.unnecessary_text').toggleClass('show') $('.all_unnecessary_text').toggleClass('show') if($('.all_unnecessary_text').hasClass('show')) { $('.all_unnecessary_text').html(txt2) } else { $('.all_unnecessary_text').html(txt1); } } else { if(mobSeo) { mobSeo = false; $('.unnecessary_text').toggleClass('show') $('.all_unnecessary_text').toggleClass('show') if($('.all_unnecessary_text').hasClass('show')) { $('.all_unnecessary_text').html(txt2) } else { $('.all_unnecessary_text').html(txt1); } } } } seoTxtHideShowRessize(); function seoTxtHideShowRessize() { if($(window).width()<=767) { $('.unnecessary_text').removeClass('show') $('.all_unnecessary_text').removeClass('show') if($('.all_unnecessary_text').hasClass('show')) { $('.all_unnecessary_text').html(txt2) } else { $('.all_unnecessary_text').html(txt1); } } else { $('.unnecessary_text').addClass('show') $('.all_unnecessary_text').addClass('show') if($('.all_unnecessary_text').hasClass('show')) { $('.all_unnecessary_text').html(txt2) } else { $('.all_unnecessary_text').html(txt1); } } } function scrollUp() { $('.btn_up').click(function () { $('body, html').animate({scrollTop:0}, 500); }) btnScroll() function btnScroll() { btnScrollPos() function btnScrollPos() { var containerPos = $('.container').offset().left; console.log($('.container').offset().left) $('.btn_up').css({right:containerPos}) } btnScrollShowHide() function btnScrollShowHide() { var windowHeight = $(window).height() if($(this).scrollTop() < windowHeight) { $('.btn_up').removeClass('visible') } else { $('.btn_up').addClass('visible') } var scrpos = $(this).scrollTop() var documentHeight = $(document).height() var fHe = ($('.section-box-footer').height())-39 var fPos = $('.section-box-footer').offset().top var docFooterHeight = documentHeight-fHe-windowHeight if(($(this).scrollTop())>=docFooterHeight){ $('.btn_up').css({bottom:(fHe+16)-((documentHeight-scrpos)-($(window).height()))}) } else { $('.btn_up').css({bottom:16}) } } $(window).resize(function () { btnScrollPos() btnScrollShowHide() }) $(window).scroll(function () { btnScrollShowHide() }) $('.btn_scroll').click(function () { $('body,html').animate( { scrollTop: 0 }, 500 ); }) } } function callMobile() { //new $('.btn_call').click(function() { if($(this).hasClass('close')) { mobOverlayRemove(); closeCallMobileHide(); $('.btn_call') .removeClass('close'); $('.call-mobile-wr').removeClass('open'); } else { $('.btn_call').addClass('close'); $('.btn_call_close').addClass('visible'); mobOverlayAdd(); $('.call-mobile-wr').addClass('visible'); setTimeout( function() { $('.call-mobile-wr').addClass('open') }, 20 ) } }) } function searchMobile() { $('.search-i').click(function () { $('.hidden-search-form').addClass('show') }) $('.close-mob-search').click(function () { $('.hidden-search-form').removeClass('show') }) } function priceSlider(){ var $price_interval = $('#price_interval'); var $filter_prices_min = $('#filter-prices-min'); var $filter_prices_max = $('#filter-prices-max'); if($price_interval.length){ var block = $('#price_block'); var link = block.data('url'); var min = block.data('min'); var max = block.data('max'); var from = block.data('from'); var to = block.data('to'); $('#btn_ok span').click(function () { var from = $filter_prices_min.val(); var to = $filter_prices_max.val(); $.pjax({url: link.replace('{from}', from).replace('{to}', to), container: "#list-container",timeout:5000, scrollTo: 0}) }); var slider = $price_interval.data("ionRangeSlider"); $filter_prices_min.change(function () { var newVal = $(this).val(); slider.update({ from: newVal }); }); $filter_prices_max.change(function () { var newVal = $(this).val(); slider.update({ to: newVal }); filterShowInSilder(); //сюда }) } } function priceSliderFixInputTxt() { $('.price_inputs input').keypress(function(e) { if (!(e.which==8 ||(e.which>47 && e.which<58))) return false; }); $('.price_inputs input').focusout(function () { var thisVal = +($(this).val()); var thisMin = +($(this).attr('min')); var thisMax = +($(this).attr('max')); if(thisValthisMax) { $(this).val(thisMax); } }) } function filtersBlockShowTabletMobile() { $('body').on('click','.mob-filters-btn', function () { if($('body').find('#overlay-filters').length > 0){ } else { $('body').append('') } $('body').addClass('body-fixed show-block-filters'); $('#overlay-filters').fadeIn(300); }) $('body').on('click','#overlay-filters, .close-fiters-mob', function () { $('#overlay-filters').fadeOut(300); $('body').removeClass('show-block-filters'); setTimeout(function () { $('body').removeClass('body-fixed'); },510) }) } function mobTags() { $('.mob-tags-vis').click(function () { if($(this).parent().hasClass('active')){ $(this).parent().removeClass('active') } else { $(this).parent().addClass('active') } }) } function phoneMask() { var phoneInput = '.phones_mask input'; $(phoneInput).keypress(function(e) { if (!(e.which==8 ||(e.which>47 && e.which<58))) return false; }); } function mobMenu() { $('ul.mobi-menu-primary-ul li').each(function () { $(this).find('.sub-menu-hidden-mob').prev().addClass('has-list'); }) $('.has-list').click(function (e) { e.preventDefault(); var this_ = $(this); if (this_.parent().hasClass('active-mob')) { this_.parent().removeClass('active-mob'); } else { this_.parent().addClass('active-mob'); } }) } $(window).resize(function () { // heightSliderCol(); footerBottom(); if(window.innerWidth>=992){ mobOverlayRemove() $('#menu-mob-hidden').removeClass('visible') setTimeout(function () { $('#menu-mob-hidden').removeClass('opens') },200) $('body').removeClass('off-scroll') $('body').removeClass('hidden_scroll-y') $('.mob_filters_wr').attr('style','') } seoTxtHideShowRessize(); }) function modalForms() { $('body').on('click','.modal-link', function (e) { e.preventDefault(); e.stopPropagation(); mobOverlayRemove() $('#menu-mob-hidden').removeClass('visible') setTimeout(function () { $('#menu-mob-hidden').removeClass('opens') },200) $('body').removeClass('off-scroll') mobOverlayRemove() closeCallMobileHide() $('.btn_call').removeClass('close') $('.call-mobile-wr').removeClass('open') $('body').removeClass('off-scroll') var idForm = $(this).data('form'); var pos = ($(window).scrollTop()) + 30; if($(this).hasClass('fixed-modal')){ pos = 30; $('#'+idForm).css({position:'fixed'}) } if($(this).hasClass('pos-top')){ pos = 30; } $('#overlay').removeClass('overlay_cloned'); $('#overlay').fadeIn(400, function(){ $('#'+idForm) .css('display', 'block') .animate({opacity: 1, top: pos}, 200); }); }) } closeForms(); function closeForms() { $('#modal_close, #overlay').click( function(){ $('.forms_, .basket_modal').animate({opacity: 0, top: '0'}, 200,function(){ $(this).css('display', 'none'); $(this).prev("#overlay").css('display', 'none'); $('#overlay').fadeOut(400); }); $('#success_form').animate({opacity: 0, top: '0'}, 200,function(){ $(this).css('display', 'none'); $(this).prev("#overlay").css('display', 'none'); $(this).css({top:'50%'}); }); }); } //после удачной отправки формы запускать success() // success() function success(message) { document.querySelector('#success_form .txt-success').innerHTML = message; var pos = ($(window).scrollTop()) + 30; $('.forms_').animate({opacity: 0, top: '0'}, 200,function(){ $(this).css('display', 'none'); }); setTimeout(function () { $('#overlay').fadeIn(400); $('#success_form').css('display', 'block').animate({opacity: 1, top: pos}, 700); },400) } function pagination() { $('body').on('click','.pagination li.active',function (e) { e.preventDefault(); }) } window.success = success; }); var fileInput = document.getElementById('customer-file'); //var removeFileSelector = document.getElementsByClassName('remove-file-img')[ 0 ]; if (fileInput !== null){ fileInput.addEventListener('change', function(event) { var file = event.target.files[ 0 ]; // if (validateFiles(file)) { // displayImage(file); // } else { // new PNotify({ // title: "", // text: "Ошибка. Файл должен быть картинкой, не более 3Мб", // type: 'info', // styling: 'brighttheme' // }); // } displayImage(file); }); } //removeFileSelector.addEventListener('click', function(event) { // event.preventDefault(); // document.getElementsByClassName('cab-file-wrapp')[ 1 ].classList.remove('vis_'); // imageFile = null; //}); function validateFiles(file) { if (types.indexOf(file.type) !== -1 && file.size < maxFileSize) { return true; } else { return false; } } function displayImage(file) { var fr = new FileReader(); fr.onload = (function(file) { return function() { var selector = document.querySelector(".img-file"); selector.querySelector('img') .setAttribute('src', this.result); selector.style.display = 'block'; } })(file); fr.readAsDataURL(file); }