function unableScroll() { var top = jQuery(document).scrollTop(); jQuery(document).on('scroll.unable',function (e) { jQuery(document).scrollTop(top); }) } function enableScroll() { jQuery(document).unbind("scroll.unable"); } $(function(){ /*language*/ var language = $('#language'); language.find('span').click(function(){ $(this).siblings('ul').stop().slideToggle('fast'); }); /*navi*/ var navi = $('#navi'); var navli = navi.find('li'); var navbtn = $('#navbtn'); if(typeof navID !='undefined' && $('#navi'+navID).length > 0){ $('#navi'+navID).addClass('cur'); } navli.each(function(){ if($(this).find('.drop a').length > 0){ $(this).prepend(''); } }); navli.find('em').click(function(){ $(this).siblings('.drop').stop().slideToggle('fast').parent().toggleClass('on').siblings().removeClass('on').children('.drop').stop().slideUp('fast'); }); navbtn.click(function(){ if($(this).hasClass('active')){ enableScroll(); $(this).removeClass('active'); navi.removeClass('active'); navi.stop().fadeOut('fast'); }else{ unableScroll(); $(this).addClass('active'); navi.stop().fadeIn('fast'); navi.addClass('active'); } }); $(window).resize(function(){ if($(this).width() > 1024){ navi.removeAttr('style'); navli.on('mouseenter mouseleave'); navli.mouseenter(function(){ $(this).addClass('on'); if($(this).find('.drop a').length > 0){ $(this).children('.drop').stop().slideDown('fast'); } }).mouseleave(function(){ $(this).removeClass('on'); if($(this).find('.drop a').length > 0){ $(this).children('.drop').stop().slideUp('fast',function(){ $(this).removeAttr('style'); }); } }); }else{ /**/ navli.off('mouseenter mouseleave'); } }).trigger('resize'); });