core/1/js/tilda-zero-scale-1.0.min.js

1 line
5.5 KiB
JavaScript
Executable File

function t396_scaleBlock(e){var t,o,p=t396_isOnlyScalableBrowser(),w=t396_detectResolution(e),l=document.getElementById("rec"+e),_=l?l.querySelectorAll(".t396__elem"):[],u=l?l.querySelector(".t396__artboard"):null;u&&(l=u.clientWidth,o=t396_ab__getFieldValue(u,"height"),o=Math.floor(o*window.tn_scale_factor),t=t396_ab__getFieldValue(u,"height_vh"),window.tn_scale_offset=(l*window.tn_scale_factor-l)/2,t&&(l=t396_ab__getFieldValue(u,"height"),o=(t=t396_ab__getHeight(u))<=(l=l*window.tn_scale_factor)?l:t),u.classList.add("t396__artboard_scale"),u.insertAdjacentHTML("beforeend",'<style class="t396__scale-style">.t-rec#rec'+e+" { overflow: visible; }#rec"+e+" .t396__carrier,#rec"+e+" .t396__filter,#rec"+e+" .t396__artboard {height: "+o+"px !important;width: 100vw !important;max-width: 100%;}</style>")),Array.prototype.forEach.call(_,function(e){var t=e.querySelector(".tn-atom"),o=t396_elem__getFieldValue(e,"container"),l=e.getAttribute("data-elem-type");if("grid"===o)if(p){t&&(r=t.parentNode,(s=document.createElement("div")).classList.add("tn-atom__scale-wrapper"),s.style.transform="scale("+window.tn_scale_factor+")",r&&r.removeChild(t),s.appendChild(t),r&&r.appendChild(s)),"none"===e.style.backdropFilter&&(e.style.backdropFilter="");o=getComputedStyle(e).backdropFilter,o=(o&&t&&s&&(e.style.backdropFilter="none",s.style.backdropFilter=o),e.querySelector(".t-bgimg"));o&&"fixed"===window.getComputedStyle(o).backgroundAttachment&&(e.removeChild(o.parentNode),e.appendChild(o),n=t396_elem__getFieldValue(e,"height"),n=t396_elem__getHeight(e,n),n=t396_elem__convertPosition__Local__toAbsolute(e,"height",n),c=t396_elem__getFieldValue(e,"width"),c=t396_elem__getWidth(e,c),c=t396_elem__convertPosition__Local__toAbsolute(e,"width",c),d=parseFloat(t396_elem__getFieldValue(e,"top")),m=parseFloat(t396_elem__getFieldValue(e,"left")),e.style.top=d*window.tn_scale_factor+"px",e.style.left=m*window.tn_scale_factor+"px",e.style.height=n*window.tn_scale_factor+"px",e.style.width=c*window.tn_scale_factor+"px",e.setAttribute("data-scale-off","yes"))}else{e.style.zoom=window.tn_scale_factor;var o=/Macintosh/.test(navigator.userAgent)&&"ontouchend"in document&&744<=screen.width,o=("text"===l&&o&&(t.style.removeProperty("font-size"),e.style.removeProperty("zoom"),e.style.removeProperty("top"),e.style.removeProperty("left"),e.style.removeProperty("width"),_=parseInt(window.getComputedStyle(t).fontSize,10),c=t396_elem__getFieldValue(e,"width"),c=t396_elem__getWidth(e,c),c=t396_elem__convertPosition__Local__toAbsolute(e,"width",c),d=parseFloat(t396_elem__getFieldValue(e,"top")),d=t396_elem__convertPosition__Local__toAbsolute(e,"top",d),m=parseFloat(t396_elem__getFieldValue(e,"left")),m=t396_elem__convertPosition__Local__toAbsolute(e,"left",m),t.style.fontSize=_*window.tn_scale_factor+"px",e.style.top=d*window.tn_scale_factor+"px",e.style.left=m*window.tn_scale_factor+"px",e.style.width=c*window.tn_scale_factor+"px",e.setAttribute("data-scale-off","yes")),"button"===l&&o&&!t.classList.contains("t396_manual-scaled-text")&&(e.style.removeProperty("zoom"),o=window.getComputedStyle(t),_=parseInt(o.fontSize,10),t.classList.add("t396_manual-scaled-text"),t.style.fontSize=_*window.tn_scale_factor+"px",e.style.zoom=window.tn_scale_factor),e.querySelector("iframe")),_=e.getAttribute("data-animate-style"),a=e.getAttribute("data-animate-sbs-event"),i=u.classList.contains("t396_resizechange");if(o&&!_&&!a&&!i){e.style.removeProperty("zoom");var r,s,n=t396_elem__getFieldValue(e,"height"),c=(n=t396_elem__getHeight(e,n),n=t396_elem__convertPosition__Local__toAbsolute(e,"height",n),t396_elem__getFieldValue(e,"width")),d=(c=t396_elem__getWidth(e,c),c=t396_elem__convertPosition__Local__toAbsolute(e,"width",c),parseFloat(t396_elem__getFieldValue(e,"top"))),m=(d=t396_elem__convertPosition__Local__toAbsolute(e,"top",d),d=(d*=window.tn_scale_factor)+(n*window.tn_scale_factor-n)/2,parseFloat(t396_elem__getFieldValue(e,"left")));for(m=t396_elem__convertPosition__Local__toAbsolute(e,"left",m),m=(m*=window.tn_scale_factor)+(c*window.tn_scale_factor-c)/2,e.style.top=d+"px",e.style.left=m+"px",(r=t.parentNode)&&r.classList.contains("tn-atom__scale-wrapper")&&(r=r.parentNode),(s=document.createElement("div")).classList.add("tn-atom__scale-wrapper"),s.style.transform="scale("+window.tn_scale_factor+")";r.firstChild;)r.removeChild(r.firstChild);s.appendChild(t),r&&r.appendChild(s),e.setAttribute("data-scale-off","yes")}"shape"===l&&(n=t396_elem__getFieldValue(e,"height"),n=t396_elem__getHeight(e,n),n=t396_elem__convertPosition__Local__toAbsolute(e,"height",n),c=t396_elem__getFieldValue(e,"width"),c=t396_elem__getWidth(e,c),c=t396_elem__convertPosition__Local__toAbsolute(e,"width",c),d=parseFloat(t396_elem__getFieldValue(e,"top")),d=t396_elem__convertPosition__Local__toAbsolute(e,"top",d),m=parseFloat(t396_elem__getFieldValue(e,"left")),m=t396_elem__convertPosition__Local__toAbsolute(e,"left",m),a=(o=window.getComputedStyle(t)).borderWidth,i="none"!==o.backgroundImage,_=e.getAttribute("data-animate-sbs-event"),!(n<=2||c<=2)||"0px"!==a||i||_||(e.style.removeProperty("zoom"),s=c*window.tn_scale_factor,l=n*window.tn_scale_factor,o=d*window.tn_scale_factor,a=m*window.tn_scale_factor,e.style.width=parseFloat(s)+"px",e.style.height=parseFloat(l)+"px",e.style.top=Math.round(o)+"px",e.style.left=Math.round(a)+"px",e.setAttribute("data-scale-off","yes"))),"text"===e.getAttribute("data-elem-type")&&w<1200&&t&&(t.style.webkitTextSizeAdjust="auto"),t&&(t.style.transformOrigin="center")}})}window.t396_initialScale||(window.t396_initialScale=function(){});