/** * JS-Funktionen fuer die Suche der Mobilversion * * Created at: 30.06.2014 * * @author STO * @package jQuery */ $('#mobile_navigation_suche').live('click',function(e){ e.preventDefault(); if($(this).hasClass('active')) { $('#main_search').css('display', 'none').animate({'opacity':'0'},300,function(){}); } else { $('#main_search').css('display', 'block').animate({'opacity':'1'},300,function(){}); } $(this).toggleClass('active'); }); /* Navaigtions-Handling * Delayed Opening */ (function() { var open_timer, open_timer_sub, open_status = false, open_status_sub = false, close_timer, nextobject; function bind_dropdown(){ $('.main_navigation_link').on({ mouseenter: function(){ if ($(window).width() > 799) { var that = $(this); nextobject = that; if (!open_status) { open_status = true; open_timer = setTimeout(function(){ window.open_navigation(that); },450); } } }, mouseleave: function(){ if ($(window).width() > 799) { clearTimeout(open_timer); clearTimeout(open_timer_sub); // $('.main_navigation_link').removeClass('active'); // $('.sub_navigation_link').removeClass('active'); close_timer = setTimeout(function(){ window.close_navigation(); },400); open_status = false; } } }); $('.sub_navigation_link').on({ mouseenter: function(){ if ($(window).width() > 799) { var that = $(this); if (!open_status_sub) { open_timer_sub = setTimeout(function(){ window.open_subnavigation(that); },380); open_status_sub = true; } } }, mouseleave: function(){ if ($(window).width() > 799) { open_status_sub = false; clearTimeout(open_timer_sub); } } }); //focus Functions $('.main_navigation_link').on({ focusin: function(){ var that = $(this); window.open_navigation(that); }, focusout:function(){ var that = $(this); window.close_navigation(that); } }); $('.sub_navigation_link').on({ focusin: function(){ var that = $(this); window.open_subnavigation(that); }, focusout:function(){ var that = $(this); window.close_subnavigation(that); } }); } function unbind_dropdown(){ $('.main_navigation_link').unbind(); $('.sub_navigation_link').unbind(); } function open_navigation(el){ $(el).addClass('active'); if ($('.activated').length > 0) { $('.activated').addClass('out'); }; } function close_navigation(){ $('.main_navigation_link').removeClass('active'); $('.sub_navigation_link').removeClass('active'); if (open_status) { clearTimeout(open_timer); window.open_navigation(nextobject); } else { $('.activated').removeClass('out'); } } function open_subnavigation(el){ if ($(el).parent().parent().parent().hasClass('active')) { open_navigation($(el).parent().parent().parent().hasClass('active')); }; $('.sub_navigation_link').removeClass('active'); $(el).addClass('active'); } window.bind_dropdown = bind_dropdown; window.unbind_dropdown = unbind_dropdown; window.open_navigation = open_navigation; window.close_navigation = close_navigation; window.open_subnavigation = open_subnavigation; })();