script.js 23.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748
$(document).ready(function(){
    footer();
    socialBlock();
    footerHover();
    headerPhones();
    firstMenuHover();
    openMobMenu();
    closeMobMenu();
    callMobile();
    menuCatalog();
    addOverlayMenu();
    citySelectHome();
    sizeTable();
    descriptionCard();
    formComments();

    function footer(){
        footerBottom();
        resizeFooterBottom();

        function footerBottom(){
            var heightHeader = $('.section-box-header').height()
            var heightFooter = $('.section-box-footer').height()
            var windowHeight = $(window).height()
            $('.section-box-content').css({minHeight:windowHeight-heightHeader-heightFooter})
        }

        function resizeFooterBottom(){
            $(window).resize(function(){
                footerBottom();
            })
        }


    }

    function mobOverlayAdd() {
        $('body').append('<div class="mob-overlay"></div>')
    }
    function mobOverlayRemove() {
        $('.mob-overlay').remove()
    }

    function socialBlock(){
        $('ul.blog-social-ico li').click(function(){
            $('ul.blog-social-ico li').removeClass('active')
            $(this).addClass('active')
            var socialIconIndex = $(this).index()+1;
            if(socialIconIndex ==1){
                $('.blog-social-navi-arrow').css({marginLeft:9});
            }
            else if (socialIconIndex ==2) {
                $('.blog-social-navi-arrow').css({marginLeft: 53});
            }

            var socialHide = $('.blog-social-hide li');
            $('.blog-social-hide li').css({display:'none'});
            $(socialHide[socialIconIndex-1]).toggle(200);
        })
    }

    function footerHover() {
        $('.menu-list-second-footer li').hover(function () {
            $('.menu-list-second-footer li').removeClass('active')
            $(this).addClass('active')
        }, function () {
            $('.menu-list-second-footer li').removeClass('active')
        })
    }

    function headerPhones() {
        function removeHiddeOperatorPhones() {
            $('.hidden-phones-h_list').removeClass('active')
        }
        $('.phones-h_list').click(function () {
            $('.hidden-phones-h_list').addClass('active')


        })

        $('.hidden-phones-h_list li').click(function () {
            var imgPgone = $(this).find('div').clone()
            var txtPhone = $(this).find('p').html()
            $('.phones-h-num').empty()
            $('.phones-h-num').html(txtPhone)
            removeHiddeOperatorPhones()
            $('.phones-h_list div:first-child').remove()
            $('.phones-h_list div').before(imgPgone)
            $('.hidden-phones-h_list li').removeClass('hidden_')
            $(this).addClass('hidden_')
        })
        $('.phones-header-wr').hover(function () {

        }, function () {
            removeHiddeOperatorPhones()
        })
        $('.callback_h').click(function () {
            removeHiddeOperatorPhones()
        })

    }

    function firstMenuHover() {
        $('.first-menu-wr ul li a').hover(function () {
            if($(this).find('span').length>0) {
                $(this).find('span').addClass('active')
            } else {
                $(this).addClass('active')
            }
        },function () {
            $(this).find('span').removeClass('active')
            $(this).removeClass('active')
        })
    }

    function openMobMenu() {
        $('.menu_mob').click(function () {
            mobOverlayAdd()
            $('body').addClass('off-scroll')
            $('#menu-mob-hidden').addClass('open')
            setTimeout(function () {
                $('#menu-mob-hidden').addClass('visible')
            },10)
        })
    }

    function closeCallMobileHide() {
        $('.call-mobile-wr').removeClass('visible')
        setTimeout(function () {
            $('.call-mobile-wr').removeClass('open')
        },200)
    }

    function callMobile() {
        $('.call-button-mobile').click(function () {
            if($('.call-button-mobile').hasClass('close')){
                mobOverlayRemove()
                closeCallMobileHide()
                $('.call-button-mobile').removeClass('close')
                $('.call-mobile-wr').removeClass('open')
                $('body').removeClass('off-scroll')
                $('.call-button-mobile.close').click(function () {


                })
            } else {
                $('body').addClass('off-scroll')
                mobOverlayAdd()
                $(this).addClass('close')
                $('.call-mobile-wr').addClass('visible')
                setTimeout(function () {
                    $('.call-mobile-wr').addClass('open')
                },20)
            }
        })


    }

    function closeMobMenu() {
        $('body').on('click','.mob-overlay',function () {
            mobOverlayRemove()
            if($('#menu-mob-hidden').hasClass('visible')) {
                $('#menu-mob-hidden').removeClass('visible')
                setTimeout(function () {
                    $('#menu-mob-hidden').removeClass('open')
                },200)
                $('body').removeClass('off-scroll')
            }
            if($('.call-button-mobile').hasClass('close')) {
                $('.call-button-mobile').removeClass('close')
                closeCallMobileHide()
            }

        })
        $('.close-menu-mob .close_mob').click(function () {
            mobOverlayRemove()
            $('#menu-mob-hidden').removeClass('visible')
            setTimeout(function () {
                $('#menu-mob-hidden').removeClass('open')
            },200)
            $('body').removeClass('off-scroll')
        })
    }

    function addOverlayMenu() {
        $('body').append('<div id="overlay-menu"></div>')
    }

    function menuCatalog() {
        var buttonDestktop = '.catalog_';
        var buttonTablet = '.catalog_mob.tablet';
        var buttonMobile = '.catalog_mob.mob';
        var menuCatalog = $('.catalog-menu-wr');
       $(''+buttonDestktop+','+buttonTablet+'').click(function (e) {
           e.preventDefault()
            if($(this).hasClass('homepage_notclick')) {
                var posCatalogMenu = $('.catalog-menu').offset().top
                $('body').animate( { scrollTop: posCatalogMenu-40 }, 500 );

            } else {
                menuCatalog.toggleClass('opens')

                if(menuCatalog.hasClass('opens')){
                    $(''+buttonDestktop+'').addClass('open')
                    $(''+buttonTablet+'').addClass('active')
                    $('.catalog-menu li').removeClass('activ-li')


                } else {
                    $(''+buttonDestktop+'').removeClass('open')
                    $(''+buttonTablet+'').removeClass('active')
                }
            }


       })


        $(buttonMobile).click(function () {
            mobOverlayAdd()
            $('body').addClass('off-scroll')

            menuCatalog.addClass('mobile_catalog_menu')

            setTimeout(function () {
                menuCatalog.addClass('op_mb_ct')
            },10)

            if(menuCatalog.hasClass('mobile_catalog_menu')){


                function hideCatMob() {
                    menuCatalog.removeClass('op_mb_ct')
                    setTimeout(function () {
                        menuCatalog.removeClass('mobile_catalog_menu')
                        $('.catalog-menu li').removeClass('act_mb')
                        mobOverlayRemove()
                        $('body').removeClass('off-scroll')
                    },200)
                }
                $('.mob-catalog-close').click(function () {
                    hideCatMob()
                })
                $('.mob-overlay').click(function () {

                    hideCatMob()


                })
                $('.catalog-menu li').click(function () {
                    $('.catalog-menu li').removeClass('act_mb')
                    if($(this).hasClass('act_mb')){
                    } else {
                        $(this).addClass('act_mb')
                    }


                })
            } else {

            }

        })




        $(window).resize(function () {
            if(($(window).width())>768){
                menuCatalog.removeClass('mobile_catalog_menu')
            } else {
                // menuCatalog.addClass('mobile_catalog_menu');  //проверить
            }
        })
        
        openSecondMenu();
        function openSecondMenu() {
            var timeout;
            $('.catalog-menu li').hover(function () {
                if($('.catalog-menu-wr').hasClass('mobile_catalog_menu')){

                } else {
                    var this_ = $(this)



                    if($(this).parent().hasClass('catalog-menu')){
                        timeout = setTimeout(function () {

                            $('#overlay-menu').addClass('show')
                            $('.catalog-menu li').removeClass('activ-li')
                            this_.addClass('activ-li')
                            $('.catalog-menu').addClass('openSecondLi')
                        },300)
                    }
                }


            }, function () {

                clearTimeout(timeout)
            })
        }


    $('.mob_lang a').click(function () {
        $('.mob_lang a').removeClass('active');
        $(this).addClass('active');
    })

    $('.lang_header a').click(function () {
        $('.lang_header a').removeClass('active');
        $(this).addClass('active');
    })

    }


    hideMenuCatalog()
    function hideMenuCatalog() {

        function hideClickHoverMenu() {
            if( $('.catalog-menu-wr').hasClass('homepage_notclose')) {
                $('.catalog_').removeClass('open')
                $('.catalog_mob.tablet').removeClass('active')
                $('#overlay-menu').removeClass('show')
                $('.catalog-menu li').removeClass('activ-li')
                $('.catalog-menu').removeClass('openSecondLi')
            } else {
                $('.catalog-menu-wr').removeClass('opens')
                $('.catalog_').removeClass('open')
                $('.catalog_mob.tablet').removeClass('active')
                $('#overlay-menu').removeClass('show')
                $('.catalog-menu li').removeClass('activ-li')
                $('.catalog-menu').removeClass('openSecondLi')
            }
        }

        $('#overlay-menu').on('click', function () {
            hideClickHoverMenu()
        })

        var timeoutOverlay
        $('#overlay-menu').hover(function () {

            timeoutOverlay = setTimeout(function () {
                hideClickHoverMenu()
            },300)
        }, function () {
            clearTimeout(timeoutOverlay)
        })

    }




    sidebarChecked()
    clearFilter()
    filterMobile()
    closeFilterMobile()
    sortList()
    hoverCatalog()
    cityDeliveryCard()
    moreVariants()
    
    function sidebarChecked() {
        $('.sidebar input.custom-check + label a').click(function () {
            var checkSidebar = $(this).parent().parent().find('.custom-check')
            if(checkSidebar.is(':checked')) {
                checkSidebar.prop("checked", false);
            } else {
                checkSidebar.prop("checked", true);
            }
        })
    }

    function clearFilter() {
        $('.resetFilters span').click(function () {
            var clearUrl = window.location.pathname;
            window.location = clearUrl;
        })
    }

    function filterMobile() {
        $('.filter_mobile_').click(function (e) {
            e.preventDefault();
            $(this).css({opacity:0})
            $('.sidebar-transform').addClass('visible_')
            $('.sidebar-transform').animate({opacity: 1, left: 0}, 300)

            $('body').addClass('hidden_scroll-y')
        })
    }

    function closeFilterMobile() {
        $('.close_filters').click(function () {
            $('.sidebar-transform').animate({opacity: 0, left: '-100%'}, 300)
            $('.filter_mobile_').css({opacity:1})

            setTimeout(function () {
                $('.sidebar-transform').removeClass('visible_')
            },290)

            $('body').removeClass('hidden_scroll-y')
        })

    }

    function sortList() {
        $('.sort-cat>a').click(function (e) {
            e.preventDefault()
           $('.sort-cat').toggleClass('active')
        })

        $('.sort-cat ul li a').click(function () {
            $('.sort-cat ul li').css({display:'block'})
            $(this).parent().css({display:'none'})
            $('.sort-cat>a').html($(this).text())
            $('.sort-cat').removeClass('active')
        })

        var timeoutSort
        $('.sort-cat').hover(function () {
            clearTimeout(timeoutSort)
        },function () {
            timeoutSort = setTimeout(function () {
                $('.sort-cat').removeClass('active')
            },320)

        })
    }

    function cityDeliveryCard() {
        $('.city-sel-deliv>a').click(function (e) {
            e.preventDefault()
            $('.city-sel-deliv').toggleClass('active')
        })

        $('.city-sel-deliv ul li a').click(function () {
            $('.city-sel-deliv ul li').css({display:'block'})
            $(this).parent().css({display:'none'})
            $('.city-sel-deliv>a').html($(this).text())
            $('.city-sel-deliv').removeClass('active')
        })

        var timeoutSort
        $('.city-sel-deliv').hover(function () {
            clearTimeout(timeoutSort)
        },function () {
            timeoutSort = setTimeout(function () {
                $('.city-sel-deliv').removeClass('active')
            },320)

        })
    }
    
    function hoverCatalog() {
        var timerBorder;
        var timerMove;
        $('.catalog-wr').hover(function () {
            var this_ = $(this)
            var slider = this_.parents('.slider-wr')
            var width = $(window).width()
            if(slider.length>0) {

                // $(this).parents('.owl-stage').find('.owl-item.active:nth-child(4)')
                var tst = $(this).parents('.owl-stage').find('.owl-item.active')

                var countSliders = 0
                if(width>=751 && width<1183){
                    countSliders = 2
                } else if (width>=1183){
                    countSliders = 3
                }


                if(($(tst[countSliders]).index())==($(this).parents('.owl-item').index())){
                    this_.addClass('hover hover_left')
                } else  {
                    this_.addClass('hover')
                }





            } else {

                var num = ($(this).index())+1
                if (num%3) {
                    this_.addClass('hover')
                } else {
                    this_.addClass('hover hover_left')
                }

            }

            setTimeout(function () {
                this_.find('.additional_wr').addClass('startAnim')
            },10)
            timerMove = setTimeout(function () {
                this_.find('.addit_wr').addClass('move')
            },200)

            timerBorder = setTimeout(function () {
                this_.addClass('hover-border')
            },200)


        },function () {
            var this_ = $(this)
            var slider = this_.parents('.slider-wr')
            this_.find('.additional_wr').removeClass('startAnim')
            this_.removeClass('hover hover-border')
            setTimeout(function () {
                this_.removeClass('hover hover_left')
                this_.find('.addit_wr').removeClass('move')
            },220)

            clearTimeout(timerBorder)
            clearTimeout(timerMove)




        })
    }

    var catalog = $('.catalog-wrapp-all')
    
    if(catalog.length>0){
        var banner = $('.banners').html()
        var bannerNum = $('.catalog-wrapp-all .catalog-wr:nth-child(4)')
        var bannerHeight = bannerNum.css('height')



        var winWidth = ($(window).width())+17

        var bannerWidth = bannerNum.css('width')
        bannerWidth= bannerWidth.replace('px','')
        bannerWidth= +bannerWidth
        if($('html').hasClass('mobil') || $('html').hasClass('tablet')) {

        } else  {

            // if(winWidth>767 && winWidth<992){
            //     console.log(winWidth)
            //     $('.catalog-wrapp-all .catalog-wr:nth-child(5)').css({marginLeft:bannerWidth})
            // }

        }


        $(window).resize(function () {
            var winWidth = ($(window).width())+17
            var bannerWidth = bannerNum.css('width')
            bannerWidth= bannerWidth.replace('px','')
            bannerWidth= +bannerWidth
            if($('html').hasClass('mobil') || $('html').hasClass('tablet')) {

            } else {
                // if(winWidth>767 && winWidth<992){
                //     console.log(winWidth)
                //     $('.catalog-wrapp-all .catalog-wr:nth-child(5)').css({marginLeft:bannerWidth})
                // } else {
                //     $('.catalog-wrapp-all .catalog-wr:nth-child(5)').attr('style','')
                // }
            }

        })


        addBanners()


        function addBanners() {

            bannerNum.after(banner)

            $('.catalog-wrapp-all .banner_').css({height:bannerHeight})
            $(window).resize(function () {
                bannerHeight = bannerNum.css('height')
                $('.catalog-wrapp-all .banner_').css({height:bannerHeight})
            })
        }
    }

    function citySelectHome() {
        $('.title_city-sel span.addCity').click(function () {
            $(this).toggleClass('active')
            if($(this).hasClass('active')) {
                $(this).parents('.city-sel').addClass('active')
                $('#hidden_shops').removeClass('_off')
            } else {
                $('#hidden_shops').addClass('_off')
                $(this).parents('.city-sel').removeClass('active')
            }
        })

        $('#hidden_shops li').click(function () {
            $('#hidden_shops li').removeClass('active')
            $(this).addClass('active')

            var cityName = $(this).find('span.s_').html()
            $('span.addCity').empty().html(cityName)

            var cityPhones = $(this).find('div.phones_content').html()
            $('#shops_phones').animate({opacity:0},450, function () {
                $(this).animate({opacity:1},250).empty().html(cityPhones)
            })
            // $('#shops_phones').empty().html(cityPhones)

            $('.title_city-sel span.addCity').removeClass('active')
            $('.city-sel').removeClass('active')
            $('#hidden_shops').addClass('_off')
        })

        var timeoutCitySel
        $('.city-sel').hover(function () {
            clearTimeout(timeoutCitySel)
        },function () {
            timeoutCitySel = setTimeout(function () {
                $('.title_city-sel span.addCity').removeClass('active')
                $('.city-sel').removeClass('active')
                $('#hidden_shops').addClass('_off')
            },320)

        })
    }
    
    function moreVariants() {
        $('.more_card').click(function () {
            var this_height = ($(this).parents('.options_bl').parents('.style').height())
            $(this).parents('.options_bl').parents('.style').css({height:this_height})
            $('.options_bl').removeClass('open_bl')
            $(this).parents('.options_bl').addClass('open_bl')
        })

        $('.size_growth li a').click(function (e) {
            e.preventDefault();
            $('.size_growth li a').removeClass('active');
            $(this).addClass('active');
            var this_index = $(this).parent().index()
            var ul = $('.size_growth-list')
            ul.removeClass('active')
            $(ul[this_index]).addClass('active')
        })

        $('.colors-img ul li a').click(function (e) {
            e.preventDefault()
            $('.colors-img ul li a').removeClass('active')
            $(this).addClass('active')
        })

        $('.size_growth-list li a').click(function (e) {
            e.preventDefault()
            $('.size_growth-list li').removeClass('active')
            $(this).parent().addClass('active')
        })

        $('.weather_list li a').click(function (e) {
            e.preventDefault()
            $('.weather_list li').removeClass('active')
            $(this).parent().addClass('active')
        })

        //закрытие
        $('.shadow_bl div').click(function () {
            $(this).parents('.options_bl').removeClass('open_bl')
            $(this).parents('.options_bl').parents('.style').css({height:'auto'})
        })

    }

    function sizeTable() {
        $('.size_table').click(function (e) {
            e.preventDefault();
            var dataLink = $(this).attr('data-link')
            $('body').append('<div id="overlay-size-tb"></div><div style="top:'+$(window).scrollTop()+'px" id="size-img"><a href="#"><img  src="'+dataLink+'"><span></span></a></div>')
        })
        $('body').on('click','#size-img a', function (e) {
            e.preventDefault()
        })
        function closeSizeTb() {
            $('#size-img').remove()
            $('#overlay-size-tb').remove()
        }
        $('body').on('click','#size-img a span', function (e) {
            closeSizeTb()
        })
        $('body').on('click','#size-img', function (e) {
            closeSizeTb()
        })
        $('body').on('click','#overlay-size-tb', function (e) {
            closeSizeTb()
        })

    }

    function descriptionCard() {
        $('.desk_name').click(function (e) {
            e.preventDefault()
            $('ul.description_list li').removeClass('active')
            $(this).parent().addClass('active')
            var this_index = $(this).parent().index()
            var blocks = $('.desk_list-wr')
            blocks.removeClass('active')
            $(blocks[this_index]).addClass('active')
        })


        $('.btn_mobil_show_desk').click(function (e) {
            e.preventDefault();
            if(($(this).parents('.desk_list-wr')).hasClass('active-mobile')) {
                $(this).parents('.desk_list-wr').removeClass('active-mobile')
            } else  {
                $('.desk_list-wr').removeClass('active-mobile')
                $(this).parents('.desk_list-wr').addClass('active-mobile')
            }

        })
    }

    function formComments() {
        $('.btn_scroll_to_comment').click(function (e) {
            e.preventDefault();
            var commentScroll = $('.form-comm-wr').offset().top-30;
            $('body,html').animate({scrollTop:commentScroll},500, function () {
                $('#commentmodel-username').focus()
            })
        })
    }

    // var w = screen.width,
    //     h = screen.height;
    //  alert(w + 'x' + h + '('+$(window).width()+'x'+$(window).height()+')')


     // alert($(window).width()+'x'+$(window).height())

});