filesbox/web/dist/design/mobile/js/mobile.big.js

2 lines
1.8 KiB
JavaScript
Raw Permalink Normal View History

2024-07-26 06:10:54 +00:00
(function(o,u){function s(){var t=l.getBoundingClientRect().width;t/e>1024&&(t=1024*e);var n=t/10;l.style.fontSize=n+"px",m.rem=o.rem=n}var c,i=o.document,l=i.documentElement,r=i.querySelector('meta[name="viewport"]'),f=i.querySelector('meta[name="flexible"]'),e=0,a=0,m=u.flexible||(u.flexible={});if(r){console.warn("\u5C06\u6839\u636E\u5DF2\u6709\u7684meta\u6807\u7B7E\u6765\u8BBE\u7F6E\u7F29\u653E\u6BD4\u4F8B");var h=r.getAttribute("content").match(/initial\-scale=([\d\.]+)/);h&&(a=parseFloat(h[1]),e=parseInt(1/a))}else if(f){var d=f.getAttribute("content");if(d){var v=d.match(/initial\-dpr=([\d\.]+)/),x=d.match(/maximum\-dpr=([\d\.]+)/);v&&(e=parseFloat(v[1]),a=parseFloat((1/e).toFixed(2))),x&&(e=parseFloat(x[1]),a=parseFloat((1/e).toFixed(2)))}}if(!e&&!a){var p=o.navigator.userAgent,b=(p.match(/android/gi),!!p.match(/iphone/gi)),F=b&&!!p.match(/OS 9_3/),w=o.devicePixelRatio;e=b&&!F?w>=3&&(!e||e>=3)?3:w>=2&&(!e||e>=2)?2:1:1,e=1,a=1/e}if(l.setAttribute("data-dpr",e),!r)if(r=i.createElement("meta"),r.setAttribute("name","viewport"),r.setAttribute("content","initial-scale="+a+", maximum-scale="+a+", minimum-scale="+a+", user-scalable=no"),l.firstElementChild)l.firstElementChild.appendChild(r);else{var g=i.createElement("div");g.appendChild(r),i.write(g.innerHTML)}o.addEventListener("resize",function(){clearTimeout(c),c=setTimeout(s,300)},!1),o.addEventListener("pageshow",function(t){t.persisted&&(clearTimeout(c),c=setTimeout(s,300))},!1),i.readyState==="complete"?i.body.style.fontSize=12*e+"px":i.addEventListener("DOMContentLoaded",function(){i.body.style.fontSize=12*e+"px"},!1),s(),m.dpr=o.dpr=e,m.refreshRem=s,m.rem2px=function(t){var n=parseFloat(t)*this.rem;return typeof t=="string"&&t.match(/rem$/)&&(n+="px"),n},m.px2rem=function(t){var n=parseFloat(t)/this.rem;return typeof t=="string"&&t.match(/px$/)&&(n+="rem"),n}})(window,window.lib||(window.lib={}));