$(document).ready(function () { // 杩斿洖椤堕儴 const backTop = document.querySelector("#backToTop"); if (backTop) { window.addEventListener("scroll", function () { const n = document.documentElement.scrollTop; backTop.style.opacity = n >= 300 ? 1 : 0; }); backTop.addEventListener("click", function () { document.documentElement.scrollTop = 0; }); } // 鑿滃崟 $(".auto-dropdown").hover( function () { $(this).addClass("open"); }, function () { $(this).removeClass("open"); } ); //搴曢儴绀句氦 $("#uiSocial .items .item").mouseenter(function () { $(this).css("height", "160px"); setHL(this, 160); setHR(this, 160); }); $("#uiSocial .items .item").mouseleave(function () { // 榧犳爣绂诲紑鏃跺皢鎵€鏈塪iv鐨勯珮搴﹁繕鍘 // $("#uiSocial .items .item").css("height", "40px"); }); setImagesCenter(); if (isMobileBrowser() || isWechatBrowser()) { resizeImages(); } }); //宸︿晶楂樹綆閫掑噺 function setHL(cur, height) { var pre = cur.previousElementSibling; if (pre !== null) { var h = height - 40; if (h < 40) { h = 40; } pre.style.height = h + "px"; setHL(pre, h); } } //鍙充晶楂樺害閫掑噺 function setHR(cur, height) { var pre = cur.nextElementSibling; if (pre !== null) { var h = height - 40; if (h < 40) { h = 40; } pre.style.height = h + "px"; setHR(pre, h); } } // 瀹氫箟涓€涓嚱鏁扮敤鏉ヨ皟鏁村浘鐗囧ぇ灏 function resizeImages() { $("#docContent img").each(function () { $(this).removeAttr("width"); $(this).removeAttr("height"); $(this).attr("style", "max-width: 100%; display: block; margin-left: auto; margin-right: auto;"); }); } function setImagesCenter() { $("#docContent img").each(function () { $(this).attr("style", "display: block; margin-left: auto; margin-right: auto;"); }); } // 鍒ゆ柇鏄惁鏄墜鏈烘祻瑙堝櫒璁块棶 function isMobileBrowser() { return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( navigator.userAgent ); } // 鍒ゆ柇鏄惁鏄井淇℃祻瑙堝櫒璁块棶 function isWechatBrowser() { return /MicroMessenger/i.test(navigator.userAgent); }