//menu jQuery(function ($) { $("ul.menu-top > li.children > a").each(function () { var $this = $(this); var li = $this.parent('li'); var sub = li.find("ul.sub"); var timout = 0; var isOpen = sub.is(":visible"); function clean() { if (timout) clearTimeout(timout); timout = 0; } //set first child as target $this.attr('href', sub.find("a:first").attr('href')); li.bind('mouseover.menu', function (e) { e.preventDefault(); if ($("a.menu-mobile").is(':visible')) return; if (!isOpen) { isOpen = true; sub.stop(true, true).slideDown(300, function () { li.addClass('open'); }); } clean(); }).bind('mouseout.menu', function (e) { e.preventDefault(); if ($("a.menu-mobile").is(':visible')) return; clean(); if (isOpen) { timout = setTimeout(function () { isOpen = false; sub.stop(true, true).slideUp(350, function () { li.removeClass('open'); }); }, 200); } }); var isTouchable = false; $this.bind('touchstart.menu click.menu', function (e) { //mobile if (e.type == "touchstart") { isTouchable = true; } if (isTouchable) e.preventDefault(); //dont click on mobile/table if ($("a.menu-mobile").is(':visible') || isTouchable) { e.preventDefault(); if (isOpen) { isOpen = false; sub.stop(true, true).slideUp(350, function () { li.removeClass('open'); }); } else { isOpen = true; sub.stop(true, true).slideDown(300, function () { li.addClass('open'); }); } } }).bind('close.menu', function () { //custom close event if (isOpen) { isOpen = false; li.removeClass('open'); sub.stop(true, true).slideUp('fast'); } }).bind('open.menu', function () { //custom close event if (!isOpen) { isOpen = true; li.addClass('open'); sub.stop(true, true).slideDown('fast'); } }); }); //fix visibility on resize var size_timer = null; $(window).bind('resize', function () { if (size_timer) { clearTimeout(size_timer); size_timer = null; } size_timer = setTimeout(function () { $("ul.menu-top > li.children > a").trigger('close.menu'); $(".menu .menu-top:visible").css("display", null); }, 100); }); //mobilni cast $("a.menu-mobile").bind('click.menu', function (e) { e.preventDefault(); $("ul.menu-top > li.children > a").trigger('close.menu'); if ($(".menu .menu-top:visible").length > 0) { $(".menu .menu-top:visible").slideUp('slow', function () { $(this).css('display', null); //itz hidden by css so dont override it }); } else { $("ul.menu-top > li.children.activechild > a").trigger('open.menu'); $(".menu .menu-top:hidden").slideDown('slow'); } }); //end mobilni cast }); //autofocus formular jQuery(function ($) { var form_errors = jQuery(".fb_invalid input"); if (form_errors.length > 0) { jQuery('html, body').animate({ scrollTop: form_errors.first().offset().top - 40 }, 1000); } var form_send = jQuery("h3.send"); if (form_send.length > 0) { jQuery('html, body').animate({ scrollTop: form_send.first().offset().top - 40 }, 1000); } //formular - remove errors on input change $("span.error").each(function () { var $this = $(this); $this.prev().bind('change', function () { $this.remove(); }); }); }); //eshop produkty tentotnc jQuery(function ($) { $(".box-eshop ul.categories li").bind('click.eshop', function (e) { e.preventDefault(); var $cat = $(this); if (!$cat.hasClass("selected")) { $(".box-eshop ul.categories li").removeClass("selected"); $cat.addClass("selected"); var cat = "for-category-" + $cat.attr("data-category"); $("ul.products li." + cat).stop(true, true).fadeIn('slow'); $("ul.products li:not(." + cat + ")").stop(true, true).hide(); } }); $(".box-eshop ul.categories li:first").trigger('click'); });