new_script.js 2.24 KB
$(document).ready(function () {
    showSubMenu();
    activeSubMEnu();
    allSeoTxt();
    loadNewCarousel();


    function showSubMenu() {
        var timeout;
        var timeout2;
        $('.new_catalog').hover(function () {
            var this_ = $(this)
            timeout = setTimeout(function () {
                this_.addClass('show')


                if(!$('.main-cat_ ul li.act').length) {

                    $('.main-cat_ ul li:first-child').addClass('act')


                    $('.sub-cat_ ul:first-child').addClass('active-show')
                }

            },200)

            clearTimeout(timeout2)


        },function () {
            var this_ = $(this)
            clearTimeout(timeout)
            timeout2 = setTimeout(function () {
                this_.removeClass('show')
                $('.main-cat_ ul li').removeClass('act')
                $('.sub-cat_ ul').removeClass('active-show')
            },200)

        })
    }

    function  activeSubMEnu() {
        var timeout;
        var timeout2;
        $('.main-cat_ ul li').hover(function () {
            var this_ = $(this)
            var thisIndex = this_.index()
            var subIndex = $('.sub-cat_ ul')

           timeout = setTimeout(function () {
                $('.main-cat_ ul li').removeClass('act')
                this_.addClass('act')
               $('.sub-cat_ ul').removeClass('active-show')
               $(subIndex[thisIndex]).addClass('active-show')
            },200)
            clearTimeout(timeout2)


        },function () {
            clearTimeout(timeout)
        })
    }

    function allSeoTxt() {
        var txt1 = 'Развернуть текст';
        var txt2 = 'Свернуть';
        $('.all_seo_text').click(function (e) {
            e.preventDefault()
            $('.seo-text').toggleClass('show')
            $(this).toggleClass('show')
            if($(this).hasClass('show')) {
                $(this).html(txt2)
            } else {$(this).html(txt1)}
        })
    }

    
    function  loadNewCarousel() {
        $('.home-popular li a').click(function (e) {
            e.preventDefault();
            $('.home-popular li a').parent().removeClass('active')
            $(this).parent().addClass('active')
        })
    }




})