SafetyScreen-ui/node_modules/autofit.js/autofit.min.js

2 lines
5.4 KiB
JavaScript
Raw Normal View History

2025-03-29 19:33:58 +08:00
!function(t,e){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).autofit=e()}(this,(function(){"use strict";function t(t,n){var o="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!o){if(Array.isArray(t)||(o=function(t,n){if(t){if("string"==typeof t)return e(t,n);var o={}.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?e(t,n):void 0}}(t))||n&&t&&"number"==typeof t.length){o&&(t=o);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,c=!0,a=!1;return{s:function(){o=o.call(t)},n:function(){var t=o.next();return c=t.done,t},e:function(t){a=!0,l=t},f:function(){try{c||null==o.return||o.return()}finally{if(a)throw l}}}}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=Array(e);n<e;n++)o[n]=t[n];return o}function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var o=null,i="",r="",l="",c=null,a=null,u=1,s=!1,f={isAutofitRunnig:!1,init:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(!(arguments.length>1&&void 0!==arguments[1])||arguments[1])&&console.log("autofit.js is running");var e=t.dw,n=void 0===e?1920:e,u=t.dh,f=void 0===u?1080:u,y=t.el,h=void 0===y?"string"==typeof t?t:"body":y,v=t.resize,g=void 0===v||v,p=t.ignore,b=void 0===p?[]:p,S=t.transition,w=void 0===S?"none":S,A=t.delay,x=void 0===A?0:A,j=t.limit,T=void 0===j?.1:j,M=t.cssMode,q=void 0===M?"scale":M,z=t.allowScroll,H=void 0!==z&&z;o=h;var R=document.querySelector(h);if(R){var E=document.createElement("style"),L=document.createElement("style");E.lang="text/css",L.lang="text/css",E.id="autofit-style",L.id="ignoreStyle",!H&&(E.innerHTML="body {overflow: hidden;}");var N=document.querySelector("body");N.appendChild(E),N.appendChild(L),R.style.height="".concat(f,"px"),R.style.width="".concat(n,"px"),R.style.transformOrigin="0 0",!H&&(R.style.overflow="hidden"),m(n,f,R,b,T,q),c=function(){clearTimeout(a),0!=x?a=setTimeout((function(){m(n,f,R,b,T,q),s&&d(i,l,r)}),x):(m(n,f,R,b,T,q),s&&d(i,l,r))},g&&window.addEventListener("resize",c),this.isAutofitRunnig=!0,setTimeout((function(){R.style.transition="".concat(w,"s")}))}else console.error("autofit: '".concat(h,"' is not exist"))},off:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"body";try{var e;window.removeEventListener("resize",c),null===(e=document.querySelector("#autofit-style"))||void 0===e||e.remove();var n=document.querySelector("#ignoreStyle");n&&n.remove();var i=document.querySelector(o||t);i&&(i.style=""),s&&y()}catch(t){console.error("autofit: Failed to remove normally",t),this.isAutofitRunnig=!1}this.isAutofitRunnig&&console.log("autofit.js is off")},elRectification:null,scale:u};function d(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;f.isAutofitRunnig||console.error("autofit.jsautofit has not been initialized yet"),y(),!t&&console.error("autofit.jsbad selector: ".concat(t)),i=t,r=n,l=e;var o=Array.from(document.querySelectorAll(t));if(0!=o.length){for(var c=0,a=o;c<a.length;c++){var d=a[c],m=1==u?1:Number(u)*Number(n);s||(d.originalWidth=d.clientWidth,d.originalHeight=d.clientHeight),e?(d.style.width="".concat(d.originalWidth*m,"px"),d.style.height="".concat(d.originalHeight*m,"px")):(d.style.width="".concat(100*m,"%"),d.style.height="".concat(100*m,"%")),d.style.transform="scale(".concat(1/Number(u),")"),d.style.transformOrigin