( function( $ ) { var $window = $(window), $document = $(document), $body = $('body'), windowWidth; /* functions */ var isTouch = function() { return (('ontouchstart' in window) || (navigator.MaxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0)); } var viewportWidth = function () { var a = window, b = "inner"; "innerWidth" in window || (b = "client", a = document.documentElement || document.body); return a[b + "Width"] } windowWidth = viewportWidth(); $window.resize(function(){ windowWidth = viewportWidth(); }); var docWidth = $document.width(); $window.resize(function(){ var currDocWidth = $document.width(); if(currDocWidth != docWidth){ docWidth = currDocWidth; } }); // DROP MENU var menuTimeout, openTimeout, closeTime = 300; $(".js-menu-link").on("mouseenter", function(){ if(windowWidth < 1025){ return false; } var $this = $(this); if(openTimeout){ clearTimeout(openTimeout); } openTimeout = setTimeout(function(){ $(".js-has-dropdown").children().removeClass("active"); if(menuTimeout){ clearTimeout(menuTimeout); } $this.parent().children().addClass("active"); }, 150); }); $(".js-has-dropdown").on('mouseleave', function(){ if(!isTouch()){ if(windowWidth < 1025){ return false; } clearTimeout(menuTimeout); clearTimeout(openTimeout); menuTimeout = setTimeout(function(){ $(".js-has-dropdown").find(".active").removeClass("active touch-active"); return true; }, closeTime); } }); $(".js-menu-dropdown").on("mouseenter", function(){ if(windowWidth < 1025){ return false; } if($(this).hasClass("active")){ clearTimeout(menuTimeout); clearTimeout(openTimeout); } }); /* menu on big touch */ $(".js-menu-link").on("click", function(){ if(isTouch() && viewportWidth() > 1024){ if(!$(this).hasClass("touch-active")){ $(".js-menu-link").removeClass("active touch-active"); $(this).addClass("active touch-active"); return false; } } }); $document.click(function (e) { if($(e.target).closest('.js-menu-link').length || $(e.target).closest('.js-menu-dropdown').length || $(e.target).closest('.menu-components').length){ return; } $(".js-menu-link").removeClass("active touch-active"); $(".js-menu-dropdown").removeClass("active"); }); /* MOBILE MENU DROP */ var menuBtn = $(".js-menu-btn"), closeMenuBtn = $(".js-menu-close"), dhxMenu = $(".dhx-menu"); menuBtn.on("click", function(e){ e.preventDefault(); dhxMenu.addClass("dhx-menu--visible"); dhxMenu.width(); dhxMenu.addClass("dhx-menu--opened"); setTimeout(function(){ $body.addClass("body-hidden"); }, 400) }); closeMenuBtn.on("click", function(e){ e.preventDefault(); dhxMenu.removeClass("dhx-menu--opened"); $body.removeClass("body-hidden"); setTimeout(function(){ dhxMenu.removeClass("dhx-menu--visible"); }, 500); }); $(".js-menu-back").on("click", function(e){ if(windowWidth < 1025) { e.preventDefault(); var $this = $(this), menuToShow = $this.parent(); menuParent = menuToShow.closest(".no-visible"); menuToShow.addClass("m-menu-hidden"); menuParent.removeClass("no-visible"); } }); $(".js-m-open").on("click", function(e){ if(windowWidth < 1025) { e.preventDefault(); var $this = $(this), menuToHide = $this.closest(".m-dropdown"), menuToOpen = $this.parent().find("> .js-m-dropdown"); menuToHide.addClass("no-visible"); menuToOpen.removeClass("m-menu-hidden"); //setTimeout(function(){ menuToHide.scrollTop(0); //}, 300); } }); // var rand = function(min, max) { return Math.floor(Math.random() * (max - min + 1) + min); } var iconFall = function(){ var icons = $(".js-page-404-icon"), iconsLength = icons.length, i = 0, classes = ["active-one", "active-two", "active-three", "active-four", "active-five"]; icons.attr("class", "page-404__i js-page-404-icon"); var arcMoove = setInterval(function(){ if(i >= iconsLength){ clearInterval(arcMoove); setTimeout(function(){ iconFall(); }, 2300); } var randClass = classes[rand(0,4)]; $(icons[i]).addClass(randClass); i++; }, 400); } if($(".js-page-404-icon").length){ iconFall(); } } )( jQuery );