index.js 5.46 KB
income();
function income() {
    let switchBlock = document.querySelectorAll('.switch-status');
    for(let i = 0; i<switchBlock.length;i++) {
        switchBlock[i].onclick = function () {
            if(this.classList.contains('text')) {
                if(!(this.classList.contains('active'))) {
                    switchBlock[0].classList.remove('active')
                    switchBlock[2].classList.remove('active')
                    this.classList.add('active')
                    if(i==0) {
                        switchBlock[1].classList.remove('right')
                    } else if (i == 2) {
                        switchBlock[1].classList.add('right')
                    }

                }
            }
            if(this.classList.contains('switch')) {
                if(switchBlock[0].classList.contains('active')) {
                    this.classList.add('right')
                    switchBlock[0].classList.remove('active')
                    switchBlock[2].classList.add('active')
                    this.parentNode.setAttribute('status',2)
                } else if(switchBlock[2].classList.contains('active')) {
                    this.classList.remove('right')
                    switchBlock[0].classList.add('active')
                    switchBlock[2].classList.remove('active')
                    this.parentNode.setAttribute('status',0)
                }
            }
            if(i != 1) {
                this.parentNode.setAttribute('status',i)
            }

        }

    }



}
$(function() {
    sliderSolution();
    function sliderSolution() {
        let sliderBlock = document.querySelectorAll('.index-solution-slider');
        if(sliderBlock.length) {
            $(".index-solution-slider__row").owlCarousel(
                {
                    navigation: true,
                    navigationText: [],
                    autoPlay: false,
                    rewindNav:false,
                    items: 4,
                    // itemsDesktopSmall: [
                    //     900,
                    //     3
                    // ],
                    // itemsTablet: [
                    //     600,
                    //     3
                    // ],
                    // itemsMobile: [
                    //     500,
                    //     2
                    // ]
                });
        }
    }

    priceSlider1()
    function priceSlider1(){
        let $price_interval = $('#price_interval');
        if($price_interval.length){
            let block = $('.calc-range-1');
            let min = block.data('min');
            let max = block.data('max');
            let from = block.data('from');


            $price_interval.ionRangeSlider({
                grid: true,
                step: 5,
                grid_num: 10,
                min: min,
                max: max,
                from: from,
                hide_min_max: true,
                hide_from_to: true,
                onChange: function (e) {
                    // $filter_prices_min.val(e.from);
                    // $filter_prices_max.val(e.to);

                },
                onFinish: function(e) {
                    // var from = $filter_prices_min.val();
                    // var to = $filter_prices_max.val();
                }
            });



            // 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();
            //     //сюда
            // })


        }
    }
    priceSlider2()
    function priceSlider2(){
        let $price_interval = $('#price_interval2');
        if($price_interval.length){
            let block = $('.calc-range-2');
            let min = block.data('min');
            let max = block.data('max');
            let from = block.data('from');


            $price_interval.ionRangeSlider({
                grid: true,
                step: 100,
                grid_num: 5,
                min: min,
                max: max,
                from: from,
                hide_min_max: true,
                hide_from_to: true,
                onChange: function (e) {
                    // $filter_prices_min.val(e.from);
                    // $filter_prices_max.val(e.to);

                },
                onFinish: function(e) {
                    // var from = $filter_prices_min.val();
                    // var to = $filter_prices_max.val();
                }
            });



            // 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();
            //     //сюда
            // })


        }
    }

    });