jquery(document).ready(function($) { var timer = null, timer2 = null, currentevent = null; if ($('html').width() > 640) { currentevent = 'mousemove'; } else { currentevent = 'click'; } $('header').unbind('click', 'mousemove').bind(currentevent, function(e) { e.stoppropagation(); if ($(e.target).is('a') && $(e.target).next().hasclass('subnav')) { cleartimeout(timer); timer = null; cleartimeout(timer2); timer2 = null; $('.subnavpanel').removeclass().addclass('subnavpanel').hide(); //$('.subnav').hide(); //if ($(e.target).next().attr('data-class')) { // $('.subnavpanel').addclass($(e.target).next().attr('data-class')); //} $('.subnavpanel').show(); $('.subnav').hide(); $(e.target).next().show(); } else if ($(e.target).is('a') && !$(e.target).parents('.subnav').length) { $('.subnavpanel').removeclass().addclass('subnavpanel').hide(); $('.subnav').hide(); } else if ($(e.target).is('a') && $(e.target).parents('.subnav').length || $(e.target).is('.subnavpanel')) { cleartimeout(timer); timer = null; cleartimeout(timer2); timer2 = null; } if (currentevent == 'mousemove' && !$(e.target).is('a')) { if (timer == null) { timer = settimeout(function() { $('.subnavpanel').removeclass().addclass('subnavpanel').hide(); $('.subnav').hide(); }, 1000); } } }); if (currentevent == 'mousemove') { $('.subnav, .subnavpanel').unbind('mouseout').bind('mouseout', function(e) { e.stoppropagation(); if (timer2 == null) { timer2 = settimeout(function() { $('.subnavpanel').removeclass().addclass('subnavpanel').hide(); $('.subnav').hide(); }, 500); } }); } function setnav() { if ($('html').width() > 640){ $('nav ul').eq(0).css('height', 'auto'); $('.nav_icon').unbind('click'); $('.topmenu').not('.displaypc, .displaymobile').each(function() { $(this).attr('href', $(this).attr('data-href')); }); } else { var h = $(window).height(); var isslide = false; $('nav ul').eq(0).css('overflow', 'auto'); $('.nav_icon').click(function() { //$('html').toggleclass('slideleft'); if (!isslide) { $('body, header').animate({'left': '-79.5%'}, 500); $('header nav ul').animate({'left': '20%'}, 500); isslide = true; } else { $('body, header').animate({'left': '0'}, 500); $('header nav ul').animate({'left': '100%'}, 500); isslide = false; } }); $('.topmenu').not('.displaypc, .displaymobile').each(function() { $(this).attr('href', 'javascript:;'); }); } } setnav(); $(window).resize(function() { setnav(); }); $('#gototop').click(function() { $("body,html").animate({scrolltop: 0}, 500); }); $('.wechat_weibo').hover(function(){ $('.wechat_weibo p').show(); }, function(){ $('.wechat_weibo p').hide(); }); $('.friends').hover(function(e) { $('#friends_pop').show(); }, function(e) { $('#friends_pop').hide(); }); // deviceorientation /////////// var supportorientation=(typeof window.orientation == "number" && typeof window.onorientationchange == "object"); var updateorientation=function(){ if(supportorientation){ updateorientation=function(){ var orientation=window.orientation; switch(orientation){ case 90: case -90: $('html').addclass('viewport'); orientation="block"; //landscape break; default: $('html').removeclass('viewport'); orientation="none"; //portrait } document.getelementbyid("orientlayer").style.display = orientation; }; }else{ // updateorientation=function(){ // var orientation=(window.innerwidth > window.innerheight)? "block":"none"; // orientation == 'block' ? $('html').addclass('viewport') : $('html').removeclass('viewport'); // document.getelementbyid("orientlayer").style.display = orientation; // }; } }; updateorientation(); if(supportorientation){ window.addeventlistener("orientationchange",updateorientation,false); }else{ //window.setinterval(updateorientation,3000); } });