(function($,plugin){var data={},id=1,etid=plugin+'etid';$.fn[plugin]=function(speed,group){id++;group=group||this.data(etid)||id;speed=speed||200;if(group===id)this.data(etid,group);this._hover=this.hover;this.hover=function(over,out){over=over||$.noop;out=out||$.noop;this._hover(function(event){var elem=this;cleartimeout(data[group]);data[group]=settimeout(function(){over.call(elem,event)},speed)},function(event){var elem=this;cleartimeout(data[group]);data[group]=settimeout(function(){out.call(elem,event)},speed)});return this};return this};$.fn[plugin+'pause']=function(){cleartimeout(this.data(etid));return this};$[plugin]={get:function(){return id++},pause:function(group){cleartimeout(data[group])}}})(jquery,'mousedelay'); /* /*by wanhu 20201020 */ var whirmenu={ main:function(type,lang,selectid){ whirmenu.public(lang,selectid); whirmenu.menutype(type); }, public:function(lang,selectid){ $("#m"+selectid).addclass("aon");//头部导航选中当前栏目 var _li=$("#menu li"); if(lang=='cn'){ var num=_li.length, w=100/num; _li.outerwidth(w+"%"); } //判断是否有下拉 _li.each(function(){ var n=$(this).find("dt").length if(n>=1){ $(this).addclass("has-sub"); } //改变选中 鼠标经过去掉当前栏目选中 $(this).hover(function(){ $(this).addclass("aon").siblings().removeclass("aon"); },function(){ $(this).removeclass("aon"); $("#m"+selectid).addclass("aon"); }); }); }, menutype:function(type){ $(function ($) { $(window).on("resize", function () { if($(window).width()>1025){ whirmenu.pc(type); } else{ whirmenu.wap(); } }).trigger("resize"); }); }, pc:function(type){ //纵向 if(type=="vertical"){ $(".has-sub").mousedelay(false).hover(function(){ $(this).find(".sub").slidedown(300); $(this).siblings().find(".sub").slideup(300); //判断下拉框内容宽度超出屏幕 var subw=$(this).find(".sub").outerwidth(), this_pleft=$(this).position().left+$(this).outerwidth(), ww=$(window).width(), right_w=ww-this_pleft //console.log(this_pleft,right_w) if(subw>=right_w){ var leftcss=subw-right_w $(this).find(".sub").css("left",-leftcss); }else{ $(this).find(".sub").css("left",""); } //判断下拉框内容宽度超出屏幕 end },function(){ $(this).find(".sub").slideup(300); }); $("#menu").mouseleave(function(){ $(this).find(".sub").slideup(300); }); } //横向 //左侧竖向菜单 子菜单竖排 if(type=='leftvertical'){ $(".has-sub").mousedelay(false).hover(function(){ $(this).find(".sub").fadein(300); $(this).siblings().find(".sub").hide(); var th=$(this).offset().top-$(document).scrolltop(); var wh=$(window).height() var dlh=$(this).find(".sub dl").height() //判断越近底部高度减少 栏目高度超出 if(th+dlh>wh){ $(this).find(".sub dl").css("padding-top",th-(th+dlh-wh)) } else{ $(this).find(".sub dl").css("padding-top",th) } },function(){ $(this).find(".sub").fadeout(300); $(this).find(".sub dl").removeattr("style"); }); } }, wap:function(){ $("#menu li,#menu").unbind(); $(".has-sub .op").remove(); $(".has-sub").find("span").append(""); $('.op').click(function(){ $(this).toggleclass("click"); $(this).parent().next(".sub").slidetoggle(); $(this).parent().parent().siblings().find(".op").removeclass("click"); $(this).parent().parent().siblings().find(".sub").slideup(); }); //打开移动端导航 $(".open-menu").unbind(); whiropen.one(".open-menu","body","menu-show","#menu"); //end } } var whiropen={ one:function(a,b,bclass,c){ $(a).click(function(e) { $(this).toggleclass("on"); $(b).toggleclass(bclass); $(document).on("click", function() { $(b).removeclass(bclass); $(a).removeclass("on"); }); e.stoppropagation(); }); $(c).on("click", function(e) { e.stoppropagation(); }); } } var whirsearch={ open:function(a,b){ $(a).click(function(e) { $(this).toggleclass("on"); $(b).stop(true, true).fadetoggle(); $(document).on("click", function() { $(b).stop(true, true).fadeout(); $(a).removeclass("on"); }); e.stoppropagation(); }); $(b).on("click", function(e) { e.stoppropagation(); }); }, search:function(a,b,c,d){ $(a).jqsearch({ txtval: c, keytxt1: "输入关键词搜索!", keytxt2: "输入的关键词字数不要过多!", keytxt3: "您输入的内容存在特殊字符!", keyid: b, //输入框id keyurl: d, //跳转链接 keyhref: "key", //链接传值 static: false //是否静态站 }); } }