var sto_nav; var $win = $(window).width(); var tools = { scrollDiy: function () { $(".ejscroll").mCustomScrollbar({ scrollButtons: { enable: false } }); }, htmlsize: function () { var dw = 750; var ww = $(window).width(); console.log("w", ww) var maxw = 1920; var minw = 320; if ($(window).width() > maxw) { ww = maxw; } else if ($(window).width() < minw) { ww = minw; } $("html").css({ fontSize: Math.floor((ww / dw) * 100) }); }, // debounce: function (fn, delay = 200) { // let timer = null // return function (...args) { // if (timer) { // clearTimeout(timer) // timer = null // } // timer = setTimeout(() => { // fn.apply(this, args) // clearTimeout(timer) // timer = null // }, delay) // } // }, fHeader: function (tar) { if (tar && tar != "") { $(tar).mousewheel(function (event, delta, deltaX, deltaY) { if (delta > 0 && $(tar).scrollTop() >= 0) { $(".body_page").addClass("showdiv") } else { $(".body_page").removeClass("showdiv") } }); } }, navHover: function (tar) { if (!$(tar)) { return } $(tar).hover(function () { if ($(this).index() == 0) { return; } clearTimeout(sto_nav); $(".ejnav_child .item").removeClass("active"); $(tar).removeClass("active"); var ol = $(this).parents(".deMenu").offset().left; var al = $(this).offset().left + $(this).outerWidth() * 0.5; var fl = al - ol; var c = $(this).parents(".deMenu").find(".ejnav_child").find(".item").eq($(this).index()); var cl = fl - c.outerWidth() * 0.5; // if (c.find("").size() == 0) { // c.hide(); // } if (cl < 0) { c.css("left", 0); } else if (cl + c.outerWidth() > $(this).parents(".deMenu").outerWidth()) { c.css("right", 0); } else { c.css("left", cl); } $(this).addClass("active"); c.addClass("active"); }, function () { sto_nav = setTimeout(function () { $(".ejnav_child .item").removeClass("active"); $(tar).removeClass("active"); }, 100); }); }, childHover: function (tar) { $(tar).hover( function () { clearTimeout(sto_nav); }, function () { $(tar).removeClass("active"); $(".ejMenuBox a").removeClass("active"); } ); }, cultureList: function (tar) { if (tar && tar != "") { $(tar).hover( function () { $(this).siblings().removeClass("active") $(this).addClass("active") } ); } }, viewMap: function (tar, target, type, f) { if (tar && tar != "") { $(tar).on(type, function () { if ($(target).hasClass("active")) { $(target).removeClass("active") if (f) { $(tar).find("i").hide() $(tar).find("i.viewBtn").show() $(".body_home.showdiv .topHeader").removeClass("addBg") } } else { $(target).addClass("active") if (f) { $(tar).find("i").hide() $(tar).find("i.closeBtn").show() $(".body_home.showdiv .topHeader").addClass("addBg") } } }) } }, removeClass: function (tar, target, type) { if (tar && tar != "") { $(tar).on(type, function () { $(target).removeClass("active") }) } }, // 搜索方法 singleSearch: function (tar) { if (tar && tar.length != 0) { var defHref = tar.attr("href"); tar.on("click", function (e) { if ($("#textfield").val() == "" || $("#textfield").val() == null) { $("#textfield").val(""); } //核心代码,拼接参数 var args = "siteIds=" + window.btoa(tar.attr("data-siteIds")) + "&excludeCategoryId=" + window.btoa(tar.attr("data-excludeCategoryId")) + "&dataUrl=" + window.btoa(tar.attr("data-url")) + "&keyword=" + encodeURI(encodeURI($.trim($("#textfield").val()))); //核心代码,拼接参数 end tar.attr("href", defHref + '#' + args); $("#searchword").val(""); // window.open(tar.attr("href")); $(".rqSearchBox,.closeSearchBox").hide(); $(".showSearchBox").css("display", "inline-block") // $(".hr-search-mask").show(); $("#textfield").val(""); }); $("#textfield").keyup(function (e) { if (e.keyCode == 13) { if ($("#textfield").val() == "" || $("#textfield").val() == null) { $("#textfield").val(""); } else { tar.trigger("click"); window.open(tar.attr("href")); } } }); } }, fLink: function (tar) { if (tar && tar != "") { $(tar).hover(function () { $(".flinkListBox").addClass("active") }, function () { $(".flinkListBox").removeClass("active") }) } }, clickNav: function (tar) { if (tar && tar != "") { tar.on("click", function () { tar.find(".item_a1").removeClass("active") if ($(this).find(".item_child") && $(this).find(".item_child").hasClass("active")) { $(this).find(".item_child").removeClass("active") } else { $(this).find(".item_child").addClass("active") } }) } }, mNavBox: function (tar, t2, fl) { if (tar && tar != "") { tar.on("click", function () { if (fl) { t2.addClass("active") } else { t2.removeClass("active") } }) } }, showActive: function (tar) { if (tar && tar != "") { $(".mNavBox .m_a3").each(function () { if ($(this).hasClass("active")) { $(this).parents(".mItem").find(".m_a2").addClass("active") } }) } }, mNavClick: function (tar) { if (tar && tar != "") { tar.each(function () { $(this).on("click", function () { if ($(this).hasClass("active")) { $(this).removeClass("active") } else { tar.removeClass("active") $(this).addClass("active") } }) }) } }, mTopHandle: function () { $(".msearchBtn").click(function () { $(this).hide(); $(".msearchCloseBtn").show() $(".ejSearchBox").addClass("active") }) $(".msearchCloseBtn").click(function () { $(this).hide() $(".msearchBtn").show() $(".ejSearchBox").removeClass("active") }) }, mgroup: function (tar, t2) { if (tar && tar != "") { tar.on("click", function () { if (t2.hasClass("active")) { t2.removeClass("active") } else { t2.addClass("active") } }) } }, mHandleNav: function (tar) { if (tar && tar != "") { tar.on("click", function () { var pTop = tar.offset().top - $(window).scrollTop() if ($(".mNavList").hasClass("active")) { $(".mNavList,.ejpupBpx").removeClass("active") $(".ejpupBpx").css({ "top": 0 }) $("html,body").css({ "height": "auto", "overflow": "auto" }) } else { $(".mNavList,.ejpupBpx").addClass("active") $(".ejpupBpx").css({ "top": pTop + 40 }) $("html,body").css({ "height": "100%", "overflow": "hidden" }) } }) } } } var tool750 = { fCodeFn: function (c, t) { c.hover(function () { c.find(t).css({ "opacity": 1, "transform": "none", "visibility": "visible" }) }, function () { c.find(t).css({ "opacity": 0, "transform": "translateY(-50px)", "visibility": "hidden" }) }) }, footerNav: function () { $(".ejFooterMian_in .item .navName").on("click", function () { $(this).siblings("ul").toggle() }) }, fCodeHover: function () { $(".fFollowUs .list .item").each(function () { tool750.fCodeFn($(this), ".imgs") }) } } tools.htmlsize(); $(window).resize(tools.htmlsize); $(function () { $(".counter").each(function () { $(this).numberRock({ lastNumber: $(this).text(), duration: 5000, easing: 'swing', }) }) tools.htmlsize(); tools.navHover(".ejMenuBox a") tools.childHover(".ejnav_child .item") tools.cultureList(".ej_culture_mission_in .item") tools.viewMap(".pcMenuBtn", ".ejMap", "click", false) tools.viewMap(".searchBtn", ".ejSearchBox", "click", true) tools.removeClass(".closeMap", ".ejMap", "click") tools.singleSearch($("#submitbuttom")) tools.fLink(".flinkList") tools.fHeader(".deBox") tools.scrollDiy() tools.clickNav($(".ejMenuList_in .item")) tools.showActive($(".mNavBox")) tools.mNavClick($(".mNavBox .m_a1")) tools.mNavClick($(".mNavBox .m_a2")) tools.mNavBox($(".mheader .icon-tubiao-shezhi"), $(".mNavBox"), true) tools.mNavBox($(".mCloseNavBtn"), $(".mNavBox"), false) tools.mgroup($(".groupInput"), $(".groupList")) tools.mTopHandle() if ($win <= 750) { tool750.footerNav() tools.mHandleNav($(".mPageName")) tool750.fCodeHover() tool750.fCodeFn($(".ejShare .list .item").eq(0), ".codeBox") } })