$.fn.countTo = function(a) { a = a || {}; return $(this).each(function() { var c = $.extend({}, $.fn.countTo.defaults, { from: $(this).data("from"), to: $(this).data("to"), speed: $(this).data("speed"), refreshInterval: $(this).data("refresh-interval"), decimals: $(this).data("decimals") }, a); var h = Math.ceil(c.speed / c.refreshInterval), i = (c.to - c.from) / h; var j = this, f = $(this), e = 0, g = c.from, d = f.data("countTo") || {}; f.data("countTo", d); if (d.interval) { clearInterval(d.interval) } d.interval = setInterval(k, c.refreshInterval); b(g); function k() { g += i; e++; b(g); if (typeof(c.onUpdate) == "function") { c.onUpdate.call(j, g) } if (e >= h) { f.removeData("countTo"); clearInterval(d.interval); g = c.to; if (typeof(c.onComplete) == "function") { c.onComplete.call(j, g) } } } function b(m) { var l = c.formatter.call(j, m, c); f.html(l) } }) }; $.fn.countTo.defaults = { from: 0, to: 0, speed: 1000, refreshInterval: 100, decimals: 0, formatter: formatter, onUpdate: null, onComplete: null }; function formatter(b, a) { return b.toFixed(0) } function count(a) { var b = $(this); a = $.extend({}, a || {}, b.data("countToOptions") || {}); b.countTo(a) }; $(function () { $(".search-submit").click(function (event) { let url = $(".wp-search form").prop("action"); $(this).removeAttr("name"); event.preventDefault(); var val = $.trim($(".search-title").val()); if (val !== "") { if (url.indexOf("&keyword=") > -1) { url = url.substr(0, url.indexOf("&keyword=")); } val = encodeURI(encodeURI(val)); url = url + "&keyword=" + val; $(".wp-search form").prop("action", url); $(".wp-search").find("form").submit(); } else { alert("请输入关键词"); } return false; }); /*导航*/ /*$.fn.sudyNav = function(){}; $(".wp-menu li").hover(function() { $(this).siblings().find('.sub-menu').stop(true,true).slideUp(150) $(this).children('.sub-menu').stop(true,true).slideDown(200); $(this).addClass('hover'); }, function() { $(this).children('.sub-menu').stop(true,true).slideUp(150); $(this).removeClass('hover'); }); $(".wp-menu li").each(function(){ $(this).children(".menu-switch-arrow").appendTo($(this).children(".menu-link")); });*/ /*媒体链接*/ $(".shares li").each(function () { $(this).children("a").hover(function () { $(this).parent().find(".con").stop(true, true).fadeIn(); }, function () { $(this).parent().find(".con").stop(true, true).fadeOut(); }); }); $(".menu").click(function () { $(this).toggleClass("close") $(".fixbox.navbox1").toggleClass("open"); $(".fixbox.navbox").toggleClass("open"); $("#head1").toggleClass("open"); if ($(this).hasClass("close")) { $(this).find("span").text("关闭"); } else { $(this).find("span").text("菜单"); } }) $(".menu2").click(function () { $(this).toggleClass("close") $(".fixbox.navbox2").toggleClass("open"); $("#head2").toggleClass("open"); $(".control2").toggleClass("open"); $(".control.nav-top").toggleClass("zIndex1") }) $(".search_ico").click(function () { $("#head1").toggleClass("open1"); $(".fixbox.search").addClass("open"); $(".control.nav-top").addClass("zIndex1") }) $(".closebox").click(function () { $("#head1").removeClass("open1"); $(".fixbox.search").removeClass("open"); $(".control.nav-top").removeClass("zIndex1") }) $(".menu-switch-arrow").on("click", function () { $(this).parent().children('.sub-menu').slideToggle(250) .parent().siblings(".menu-item,.sub-item").children('.sub-menu').slideUp(250); }); $("a").each(function () { if ($(this).attr("href") != undefined) { if ($(this).attr("href").indexOf("/_s32") != -1&&$(this).attr("href").indexOf("_t1009") == -1) { $(this).attr("href", $(this).attr("href").replace("/_s32", "/_s32/_t1009")) } } }) if ($(window).width() < 999) { $(window).mousewheel(function (event, delta, deltaX, deltaY) { if ($(window).scrollTop() >300) { $("#head1").addClass("fixhead") }else{ $("#head1").removeClass("fixhead") } }) } }); fontSize(); $(window).resize(function () { fontSize(); }); function fontSize() { var size; var winW = window.innerWidth; if (winW <= 3800 && winW > 999) { size = Math.round(winW / 19.2); } else if (winW <= 999) { size = 65; } else { size = 100; } $('html').css({ 'font-size': size + 'px' }) }