var istouch = modernizr.touchevents, ismobile = false, w_width = jquery(window).width(), w_height = jquery(window).height(), $mtop = jquery(".mtop"), $mtoph = $mtop.height(); var menu = { trigger: ".menu-handler", init: function () { menu.bind(); }, bind: function () { $(document).on("click", menu.trigger, menu.open); $(document).on("click", ".navmobile dd p a", function (e) { var menucur = $(this); var menudd = $(this).parents("p").parents("dd"); if (menudd.find(".msubnav").size() > 0) { if (menucur.hasclass("cur")) { menudd.find(".msubnav").stop(false, false).slideup(); menucur.removeclass("cur"); } else { jquery(".navmobile dd p a").removeclass("cur"); jquery(".msubnav").stop(false, false).slideup(); menudd.find(".msubnav").stop(false, false).slidedown(); menucur.addclass("cur"); e.preventdefault(); } } }); $(document).on("click", "#bg-menu", menu.open) }, open: function () { if ($("body").is(".open")) { $("body").removeclass("open"); $(".menu-handler").removeclass("active"); $("#bg-menu").fadeto("fast", 0, function () { $("#bg-menu").hide(); }); } else { $("#bg-menu").fadeto("fast", 0.4); $("body").addclass("open"); $(".menu-handler").addclass("active"); } } }; var _mousemove; var _click; var _mousedown; var _mouseup; if (modernizr.touchevents) { _mousemove = "touchmove"; _click = "touchend"; _mousedown = "touchstart"; _mouseup = "touchend"; } else { _mousemove = "mousemove"; _click = "click"; _mousedown = "mousedown"; _mouseup = "mouseup"; }; function pagebox() { w_width = jquery(window).width(); w_height = jquery(window).height(); if (w_width <= 1024) { ismobile = true; } else if (w_width > 1024) { ismobile = false; jquery('.pbanner .pimg').css('transform', "translate(0px,0px)"); }; $mtoph = $mtop.height(); }; function setimgmax(img, imgw, imgh, tw, th) { var twidth = tw || w_width; var theight = th || w_height; var coe = imgh / imgw; var coe2 = theight / twidth; if (coe < coe2) { var imgwidth = theight / coe; img.css({ height: theight, width: imgwidth, left: -(imgwidth - twidth) / 2, top: 0 }); } else { var imgheight = twidth * coe; img.css({ height: imgheight, width: twidth, left: 0, top: -(imgheight - theight) / 2 }); }; }; pagebox(); jquery(window).resize(function () { pagebox(); }); window.onload = function () { $('.loadingbg').fadeout(); if (jquery(".teamibox").length >= 1) { jquery(".teamibox dd.item a").height(jquery(".teamibox dd.item2 img").innerheight()); jquery(".teamibox dd.item1 a").height(jquery(".teamibox dd.item2 img").innerheight() * 2); } } $(".searchtxt").keyup(function (event) { var keyvalue = event.which; var vakes = $(this).val(); if (keyvalue == 13) { if (vakes == '') { $(this).focus(); return; } window.location = 'search.aspx?keyword=' + encodeuricomponent(vakes); } }) $('.searchbtn').click(function () { var vakes = $(".searchtxt").val(); if (vakes == '') { $(".searchtxt").focus(); return; } window.location = 'search.aspx?keyword=' + encodeuricomponent(vakes); }); //点赞 var isajax2 = true; function praise(id, obj) { var isajx = jquery(obj).attr("isajx"); if (isajax2 && isajx == "0") { jquery.ajax({ type: "post", url: "tools/updatehite.ashx?t=" + math.random(), data: { action: "updatehite", id: id }, datatype: "html", cache: true, beforesend: function () { isajax2 = false; }, success: function (data) { var num = jquery(obj); if (data == "true") { num.html(number(num.html()) + 1).addclass("red"); jquery(obj).attr("isajx", "1"); } else alert('抱歉,提交失败'); isajax2 = true; }, error: function () { alert("请求错误"); isajax2 = true; } }) } else { alert('亲,你已经点赞过了 不要重复咯'); } } jquery(function () { menu.init(); jquery(".gropbox .searchtxt").focus(function () { jquery(this).stop(false, false).animate({ width: "130" }, 300); }); jquery(".gropbox .searchtxt").blur(function () { jquery(this).stop(false, false).animate({ width: "100" }, 300); }); setpopup(jquery(".tool .a4"), "官方微信"); setpopup(jquery(".weixin"), "官方微信"); function setpopup(obj, title) { obj.click(function () { var str = '
'; $("body").append(str); jquery(".popupblack").fadein(); jquery(".popup").animate({ margintop: "-127" }, 400); $(".popup .close").click(function () { $(".popupblack").remove(); }); jquery(".popupblack").click(function () { $(".popupblack").remove(); }); return false; }); } jquery(".blacktop").bind("click", function () { jquery('html, body').stop().animate({ scrolltop: 0 }, 800, 'easeinoutexpo'); }); jquery(".tool .a3").mouseenter(function () { jquery(this).find(".con").stop(false, false).animate({ right: 0 }); }).mouseleave(function () { jquery(this).find(".con").stop(false, false).animate({ right: -126 }); }); //pc nav jquery("#nav li").hover(function () { if (jquery(this).find(".subnav").length > 0) { $(this).children("a").addclass("hov"); $(this).children(".subnav").stop(false, false).animate({ "top": "75px", opacity: "show" }, 280); }; }, function () { $(this).children("a").removeclass("hov"); $(this).children(".subnav").stop(false, false).animate({ "top": "92px", opacity: "hide" }, 280); }); jquery(".msubnav a,.subnav a").click(function () { var anchorcur = jquery(this).attr("href").split("#")[1]; if (anchorcur && jquery("#" + anchorcur).length == 1) { navitem = 0; setscroll("#" + anchorcur); } }); function gethash() { var hash = location.href.split("#")[1]; if (hash) { jquery("html,body").animate({ scrolltop: jquery("#" + hash).offset().top - $mtoph }, 0); } }; gethash(); function setscroll(anchorcur) { jquery("html,body").animate({ scrolltop: jquery(anchorcur).offset().top - $mtoph }, 800, 'easeinoutexpo'); }; var $pbanner = jquery(".pbanner"); if ($pbanner.length > 0) { $pbanner.addclass("trans-1 pbanneract"); settimeout(function () { $pbanner.removeclass('trans-1'); }, 1300); }; jquery(window).scroll(function () { var scrollvar = $(window).scrolltop(); $('.pbanner .pbox').css({ 'opacity': (500 - scrollvar) / 500 }); if (scrollvar < w_height && !ismobile) { jquery('.pbanner .pimg').css('transform', "translate(0px," + (scrollvar) / 2.5 + "px)"); }; }); });