///
var serarchurl="../other/search.html?t="
$(function () {
//判断低版本浏览器;
//手机导航
$(document).on("click", ".menu-bon,.ph-mask", function () {
$("body").toggleClass("menu-open");
if(!$("body").hasClass("menu-open")){
$(".header").attr("class","header")
}
});
$(document).on("touchmove",".ph-mask",function(e){
e.stopPropagation();
e.preventDefault();
})
//pc端下拉菜单
var setn, setn1;
$(document).on("click","#menubon li a",function(e){
var $th=$(this);
console.log($th.parent().hasClass("on"))
if(!$th.parent().hasClass("on")&& !$th.parent().hasClass("m0")&& !$th.parent().hasClass("m5")){
e.stopPropagation();
e.preventDefault();
}
})
$(document).on("mouseenter", "#menubon li", function () {
var i = $(this).index(),
$th=$(this)
clearTimeout(setn1);
clearTimeout(setn);
$("header").attr("class", "header");
$("header").addClass("menu" + i);
setTimeout(function(){
$th.addClass("on").siblings().removeClass("on");
},1)
});
$(document).on("mouseleave", "#menubon li", function () {
var i = $(this).index();
$(this).removeClass("on");
setn = setTimeout(function () {
$("header").attr("class", "header");
}, 300);
});
$(document).on("mouseenter", "#nav-child", function () {
var i = $(this).index();
clearTimeout(setn);
});
$(document).on("mouseleave", "#nav-child", function () {
var i = $(this).index();
setn1 = setTimeout(function () {
$("header").attr("class", "header");
}, 300);
});
//手机版搜索展开
$(document).on("touchstart",".wx a.a3",function(){
$("body").toggleClass("open-search");
})
//
//搜索跳转
$("#searchbutton").on("click",function(){
var $vl=$("#searchtext").val();
window.location.href=serarchurl+$vl;
})
$("#searchtext").on("focus",function(){
$(document).on("keydown",gotoenter)
})
$("#searchtext").on("blur",function(){
$(document).off("keydown",gotoenter)
})
function gotoenter(event){
var $vl=$("#searchtext").val();
if(event.keyCode==13)
{
if($vl!=""){
window.location.href=serarchurl+$vl;
}
return false;
}
}
//左侧滚动
var comleft=$("#com-left-box")//
if(comleft.is(":visible")){
$(".com-right-box").css({"min-height":$(".com-left-box").outerHeight()})
var comleft_top=comleft.offset().top,
comleft_left=comleft.offset().left,
comleft_height=comleft.height(),
footer_top=$(".footer").offset().top;
}
$(window).resize(function(){
if(comleft.is(":visible")){
$(".com-right-box").css({"min-height":$(".com-left-box").outerHeight()})
comleft_top=comleft.offset().top;
comleft_left=comleft.offset().left;
comleft_height=comleft.height();
footer_top=$(".footer").offset().top;
}
})
//返回顶部
$(window).scroll(function(){
var tp=$(window).scrollTop();
if(tp>200){
$(".top-button").addClass("on")
}else{
$(".top-button").removeClass("on")
}
if(tp>50){
$("html").addClass("open_scroll")
}else{
$("html").removeClass("open_scroll")
}
//左侧滚动
if(comleft.is(":visible")){
if(tp>comleft_top+90 && tpfooter_top-comleft_height-10){
comleft.addClass("fixd2").css({"left":0})
}else{
comleft.removeClass("fixd2")
}
}
})
$(document).on("click",".top-button",function(){
$("body,html").animate({scrollTop:0},100)
})
//设置内容页字号
$(document).on("click","#fontsize i",function(){
var $th=$(this),
$ind=$th.index(),
$obj=$(".news-content");
$th.addClass("current").siblings().removeClass("current")
switch($ind){
case 0:
$obj.css({"font-size":"12px"})
break;
case 1:
$obj.css({"font-size":"14px"})
break;
case 2:
$obj.css({"font-size":"16px"})
break;
}
})
//公共选项卡
$(document).on("mouseenter", ".tab-box .tab-a", function () {
$(this).addClass("on").siblings().removeClass("on");
var ii = $(this).index();
$(this).parents(".tab-box").find(".tab-b").eq(ii).addClass("on").siblings().removeClass("on");
})
//设置编辑器table包裹
$(".com-content table").wrap("")
})
//跳转定位
function scrollgoto(e,obj){
$(e).parent().addClass("on").siblings().removeClass("on")
var $pos=$("#"+obj).offset().top-90;
$("body,html").animate({scrollTop:$pos},100)
}