// javascript document var top002898={ main:function(){ $("#m"+m).addclass("aon"); $(function ($) { $(window).on("resize", function (e) { if($(window).width()>1025){ //清除由移动端到pc的样式 $("body").removeclass("menu-show"); $(".open-menu").removeclass("on"); $(".top-menu li .sub").removeattr("style"); top002898.pcmenu(); } else{ $(".top-menu li").unbind(); top002898.wapmenu(); } }).trigger("resize"); }); top002898.openthings(".open-search","","",".top-search .box",".top-search .box"); //打开移动导航 top002898.openthings(".open-menu","body","menu-show",".top-menu"); }, pcmenu:function(){ $(".top-menu li").each(function(){ var _this=$(this).find(".sub") var rel=_this.attr("data-type") if(rel=='v-icon-fullbg'){ if(_this.find("dt").length>=1){ $(this).addclass("has-sub") } } if(rel=='tab'){ if(_this.find(".one-cate").find("dt").length>=1){ $(this).addclass("has-sub pr"); } } }); //一级菜单下拉 $(".top-menu li.has-sub").mousedelay(false).hover(function(){ $(this).addclass("aon").siblings().removeclass("aon"); var _this=$(this).find(".sub"), rel=_this.attr("data-type") _this.slidedown('fast'); _this.parent().siblings().find(".sub").slideup('fast'); if(rel=='v-icon-fullbg'){ var w=$(window).width(), liw=_this.parent("li").width(), pl=$(this).position().left, dlw=_this.find(".sub-inner dl").width(), cssl=pl-(dlw/2)+(liw/2); //console.log(dlw) if(cssl+dlw>w){ _this.addclass("dl-right") } else{ _this.css("padding-left",cssl); } } if(rel=='tab'){ $(".two-cate .scrollinfo").mcustomscrollbar({scrollbarposition:"outside"});//添加滚动条 //一级也可添加滚动条 $(".one-cate .scrollinfo").mcustomscrollbar({scrollbarposition:"outside"}); var cate=_this.find(".one-cate").find("dt") cate.hover(function(){ var list=$(this).find(".two-cate-list").html() $(this).parents(".one-cate").next(".two-cate").find(".inner").html(list); $(this).addclass("on").siblings().removeclass("on"); }); //初始 cate.eq(0).addclass("on").siblings().removeclass("on"); _this.find(".two-cate").find(".inner").html(cate.eq(0).find(".two-cate-list").html()); //判断右侧位置是否够放置 var centerw=$(".top002898 > .auto").outerwidth(), //居中内容宽度 方便得出左右宽度 pl=$(this).position().left, conw=$(this).find(".sub").width()/2, ww=$(window).width(), rw=ww-pl-((ww-centerw)/2)-$(this).outerwidth(); //console.log(rw) if(pl+conw>ww){ $(this).addclass("po-r"); $(this).find(".sub").css("right",-rw); } //end } },function(){ $(this).removeclass("aon"); $(this).find(".sub").slideup('fast'); $("#m"+m).addclass("aon"); }); //end }, wapmenu:function(){ $(".top-menu li").each(function(){ var dt_num=$(this).find(".sub").find("dt").length if(dt_num>=1){ $(this).find("span").find(".op").remove(); $(this).find("span").append(""); var op= $(this).find("span").find(".op") op.click(function(){ $(this).toggleclass("click"); $(this).parents("li").find(".sub").slidetoggle(); $(this).parents("li").siblings().find(".sub").slideup(); $(this).parents("li").siblings().find(".op").removeclass("click"); }); } }); $(".one-cate dt").each(function(){ var item_num=$(this).find(".two-cate-list").find(".item").length if(item_num>=1){ $(this).find(".one-cate-name").find(".op-item").remove(); $(this).find(".one-cate-name").append(""); var op= $(this).find(".one-cate-name").find(".op-item") op.click(function(){ $(this).toggleclass("click"); $(this).parents("dt").find(".two-cate-list").slidetoggle(); $(this).parents("dt").siblings().find(".two-cate-list").slideup(); $(this).parents("dt").siblings().find(".op-item").removeclass("click"); }); } }); }, openthings:function(a,b,bcss,c,d){ $(a).click(function(e) { $(this).toggleclass("on"); $(b).toggleclass(bcss); $(d).fadetoggle(); $(document).on("click", function() { $(b).removeclass(bcss); $(a).removeclass("on"); $(d).fadeout(); }); e.stoppropagation(); }); $(c).on("click", function(e) { e.stoppropagation(); }); } }