(function(){ var topbot_stylehtml = { //左侧导航显示隐藏按钮 showleftbtn:function(){ var html = ''); $leftnemucont.html(html).appendTo('header'); } }, //左侧导航内容 showleftmenu:function(){ var html = '
'; if($("#cd-menu-trigger").length > 0){ $("#cd-menu-trigger").html(html); } else { var $leftnemucont = $(' '; html += ''; if($("#cd-lateral-nav").length > 0){ $("#cd-lateral-nav").html(html); } else { var $leftnemucont = $(''); $leftnemucont.html(html).appendTo('body'); } }, }; window.topbot_stylehtml = topbot_stylehtml; //将变量注册到window变量中 })() $().ready(function(){ topbot_stylehtml.showleftbtn(); topbot_stylehtml.showleftmenu(); }); (function(a){ a.fn.touchwipe=function(c){ var b={ drag:false, min_move_x:20, min_move_y:20, wipeLeft:function(){/*向左滑动*/}, wipeRight:function(){/*向右滑动*/}, wipeUp:function(){/*向上滑动*/}, wipeDown:function(){/*向下滑动*/}, wipe:function(){/*点击*/}, wipehold:function(){/*触摸保持*/}, wipeDrag:function(x,y){/*拖动*/}, preventDefaultEvents:true }; if(c){a.extend(b,c)}; this.each(function(){ var h,g,j=false,i=false,e; var supportTouch = "ontouchstart" in document.documentElement; var moveEvent = supportTouch ? "touchmove" : "mousemove", startEvent = supportTouch ? "touchstart" : "mousedown", endEvent = supportTouch ? "touchend" : "mouseup" /* 移除 touchmove 监听 */ function m(){ this.removeEventListener(moveEvent,d); h=null; j=false; clearTimeout(e) }; /* 事件处理方法 */ function d(q){ if(b.preventDefaultEvents){ q.preventDefault() }; if(j){ var n = supportTouch ? q.touches[0].pageX : q.pageX; var r = supportTouch ? q.touches[0].pageY : q.pageY; var p = h-n; var o = g-r; if(b.drag){ h = n; g = r; clearTimeout(e); b.wipeDrag(p,o); } else{ if(Math.abs(p)>=b.min_move_x){ m(); if(p>0){b.wipeLeft()} else{b.wipeRight()} } else{ if(Math.abs(o)>=b.min_move_y){ m(); if(o>0){b.wipeUp()} else{b.wipeDown()} } } } } }; /*wipe 处理方法*/ function k(){clearTimeout(e);if(!i&&j){b.wipe()};i=false;j=false;}; /*wipehold 处理方法*/ function l(){i=true;b.wipehold()}; function f(n){ //if(n.touches.length==1){ h = supportTouch ? n.touches[0].pageX : n.pageX; g = supportTouch ? n.touches[0].pageY : n.pageY; j=true; this.addEventListener(moveEvent,d,false); e=setTimeout(l,750) //} }; //if("ontouchstart"in document.documentElement){ this.addEventListener(startEvent,f,false); this.addEventListener(endEvent,k,false) //} }); return this }; })(jQuery); jQuery(document).ready(function($){ var $lateral_menu_trigger = $('#cd-menu-trigger'), $content_wrapper = $('.cd-main-content'), $navigation = $('header'); //open-close lateral menu clicking on the menu icon $lateral_menu_trigger.on('click', function(event){ event.preventDefault(); $lateral_menu_trigger.toggleClass('is-clicked'); $navigation.toggleClass('lateral-menu-is-open'); $content_wrapper.toggleClass('lateral-menu-is-open').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){ // firefox transitions break when parent overflow is changed, so we need to wait for the end of the trasition to give the body an overflow hidden $('body').toggleClass('overflow-hidden'); }); $('#cd-lateral-nav').toggleClass('lateral-menu-is-open'); //check if transitions are not supported - i.e. in IE9 if($('html').hasClass('no-csstransitions')) { $('body').toggleClass('overflow-hidden'); } }); //close lateral menu clicking outside the menu itself $content_wrapper.on('click', function(event){ if( !$(event.target).is('#cd-menu-trigger, #cd-menu-trigger span') ) { $lateral_menu_trigger.removeClass('is-clicked'); $navigation.removeClass('lateral-menu-is-open'); $content_wrapper.removeClass('lateral-menu-is-open').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){ $('body').removeClass('overflow-hidden'); }); $('#cd-lateral-nav').removeClass('lateral-menu-is-open'); //check if transitions are not supported if($('html').hasClass('no-csstransitions')) { $('body').removeClass('overflow-hidden'); } } }); $content_wrapper.touchwipe({ wipeLeft: function() { $lateral_menu_trigger.removeClass('is-clicked'); $navigation.removeClass('lateral-menu-is-open'); $content_wrapper.removeClass('lateral-menu-is-open').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){ $('body').removeClass('overflow-hidden'); }); $('#cd-lateral-nav').removeClass('lateral-menu-is-open'); //check if transitions are not supported if($('html').hasClass('no-csstransitions')) { $('body').removeClass('overflow-hidden'); } }, wipeRight:function(){ $lateral_menu_trigger.toggleClass('is-clicked'); $navigation.toggleClass('lateral-menu-is-open'); $content_wrapper.toggleClass('lateral-menu-is-open').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){ // firefox transitions break when parent overflow is changed, so we need to wait for the end of the trasition to give the body an overflow hidden $('body').toggleClass('overflow-hidden'); }); $('#cd-lateral-nav').toggleClass('lateral-menu-is-open'); //check if transitions are not supported - i.e. in IE9 if($('html').hasClass('no-csstransitions')) { $('body').toggleClass('overflow-hidden'); } }, min_move_x: 20, min_move_y: 20, preventDefaultEvents:false }); //open (or close) submenu items in the lateral menu. Close all the other open submenu items. $('.item-has-children').children('a').on('click', function(event){ event.preventDefault(); $(this).toggleClass('submenu-open').next('.sub-menu').slideToggle(200).end().parent('.item-has-children').siblings('.item-has-children').children('a').removeClass('submenu-open').next('.sub-menu').slideUp(200); }); }); $(function(){ if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) { } else if (/(Android)/i.test(navigator.userAgent)) { if (/(MicroMessenger)/i.test(navigator.userAgent)){ //安卓系统 用微信访问 } else { var html = ""+ "关闭"; $("header").append(html); } } else { }; //alert(navigator.userAgent); });