@iqmo/browser
Version:
Browser Stlite
2 lines (1 loc) • 14.1 kB
JavaScript
var xe={exports:{}},ke;function ot(){return ke||(ke=1,function(Re){(function(s){if(typeof window>"u")return;var b=!0,Le=10,te="",q=0,R="",H=null,ne="",L=!1,Fe={resize:1,click:1},W=128,oe=!0,A=1,B="bodyOffset",h=B,ie=!0,re="",z={},O=32,ae=null,J=!1,U=!1,F="[iFrameSizer]",ue=F.length,P="",ce={max:1,min:1,bodyScroll:1,documentElementScroll:1},_="child",se=window.parent,C="*",V=0,D=!1,de=null,x=16,k=1,fe="scroll",p=fe,Pe=window,X=function(){T("onMessage function not defined")},Y=function(){},K=function(){},Q={height:function(){return T("Custom height calculation function not defined"),document.documentElement.offsetHeight},width:function(){return T("Custom width calculation function not defined"),document.body.scrollWidth}},G={},le=!1;function me(){}try{var ge=Object.create({},{passive:{get:function(){le=!0}}});window.addEventListener("test",me,ge),window.removeEventListener("test",me,ge)}catch{}function I(e,t,n,o){e.addEventListener(t,n,le?o||{}:!1)}function De(e,t,n){e.removeEventListener(t,n,!1)}function he(e){return e.charAt(0).toUpperCase()+e.slice(1)}function je(e){var t,n,o,a=null,d=0,m=function(){d=Date.now(),a=null,o=e.apply(t,n),a||(t=n=null)};return function(){var l=Date.now();d||(d=l);var u=x-(l-d);return t=this,n=arguments,u<=0||u>x?(a&&(clearTimeout(a),a=null),d=l,o=e.apply(t,n),a||(t=n=null)):a||(a=setTimeout(m,u)),o}}function pe(e){return F+"["+P+"] "+e}function i(e){J&&typeof window.console=="object"&&console.log(pe(e))}function T(e){typeof window.console=="object"&&console.warn(pe(e))}function qe(){He(),i("Initialising iFrame ("+window.location.href+")"),Be(),Ue(),Z("background",te),Z("padding",ne),Ye(),we(),be(),_e(),Ge(),Qe(),Te(),z=Ke(),M("init","Init message from host page"),Y()}function He(){function e(n){return n==="true"}var t=re.slice(ue).split(":");P=t[0],q=s===t[1]?q:Number(t[1]),L=s===t[2]?L:e(t[2]),J=s===t[3]?J:e(t[3]),O=s===t[4]?O:Number(t[4]),b=s===t[6]?b:e(t[6]),R=t[7],h=s===t[8]?h:t[8],te=t[9],ne=t[10],V=s===t[11]?V:Number(t[11]),z.enable=s===t[12]?!1:e(t[12]),_=s===t[13]?_:t[13],p=s===t[14]?p:t[14],U=s===t[15]?U:e(t[15])}function We(e){var t=e.split("Callback");if(t.length===2){var n="on"+t[0].charAt(0).toUpperCase()+t[0].slice(1);this[n]=this[e],delete this[e],T("Deprecated: '"+e+"' has been renamed '"+n+"'. The old method will be removed in the next major version.")}}function Be(){function e(){var n=window.iFrameResizer;i("Reading data from page: "+JSON.stringify(n)),Object.keys(n).forEach(We,n),X="onMessage"in n?n.onMessage:X,Y="onReady"in n?n.onReady:Y,C="targetOrigin"in n?n.targetOrigin:C,h="heightCalculationMethod"in n?n.heightCalculationMethod:h,p="widthCalculationMethod"in n?n.widthCalculationMethod:p}function t(n,o){return typeof n=="function"&&(i("Setup custom "+o+"CalcMethod"),Q[o]=n,n="custom"),n}"iFrameResizer"in window&&Object===window.iFrameResizer.constructor&&(e(),h=t(h,"height"),p=t(p,"width")),i("TargetOrigin for parent set to: "+C)}function Je(e,t){return t.indexOf("-")!==-1&&(T("Negative CSS value ignored for "+e),t=""),t}function Z(e,t){s!==t&&t!==""&&t!=="null"&&(document.body.style[e]=t,i("Body "+e+' set to "'+t+'"'))}function Ue(){s===R&&(R=q+"px"),Z("margin",Je("margin",R))}function _e(){document.documentElement.style.height="",document.body.style.height="",i('HTML & body height set to "auto"')}function g(e){var t={add:function(n){function o(){M(e.eventName,e.eventType)}G[n]=o,I(window,n,o,{passive:!0})},remove:function(n){var o=G[n];delete G[n],De(window,n,o)}};e.eventNames&&Array.prototype.map?(e.eventName=e.eventNames[0],e.eventNames.map(t[e.method])):t[e.method](e.eventName),i(he(e.method)+" event listener: "+e.eventType)}function ve(e){g({method:e,eventType:"Animation Start",eventNames:["animationstart","webkitAnimationStart"]}),g({method:e,eventType:"Animation Iteration",eventNames:["animationiteration","webkitAnimationIteration"]}),g({method:e,eventType:"Animation End",eventNames:["animationend","webkitAnimationEnd"]}),g({method:e,eventType:"Input",eventName:"input"}),g({method:e,eventType:"Mouse Up",eventName:"mouseup"}),g({method:e,eventType:"Mouse Down",eventName:"mousedown"}),g({method:e,eventType:"Orientation Change",eventName:"orientationchange"}),g({method:e,eventType:"Print",eventNames:["afterprint","beforeprint"]}),g({method:e,eventType:"Ready State Change",eventName:"readystatechange"}),g({method:e,eventType:"Touch Start",eventName:"touchstart"}),g({method:e,eventType:"Touch End",eventName:"touchend"}),g({method:e,eventType:"Touch Cancel",eventName:"touchcancel"}),g({method:e,eventType:"Transition Start",eventNames:["transitionstart","webkitTransitionStart","MSTransitionStart","oTransitionStart","otransitionstart"]}),g({method:e,eventType:"Transition Iteration",eventNames:["transitioniteration","webkitTransitionIteration","MSTransitionIteration","oTransitionIteration","otransitioniteration"]}),g({method:e,eventType:"Transition End",eventNames:["transitionend","webkitTransitionEnd","MSTransitionEnd","oTransitionEnd","otransitionend"]}),_==="child"&&g({method:e,eventType:"IFrame Resized",eventName:"resize"})}function ye(e,t,n,o){return t!==e&&(e in n||(T(e+" is not a valid option for "+o+"CalculationMethod."),e=t),i(o+' calculation method set to "'+e+'"')),e}function we(){h=ye(h,B,E,"height")}function be(){p=ye(p,fe,S,"width")}function Te(){b===!0?(ve("add"),$e()):i("Auto Resize disabled")}function Ve(){H!==null&&H.disconnect()}function Xe(){ve("remove"),Ve(),clearInterval(ae)}function Ye(){var e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.appendChild(e)}function Ke(){function e(){return{x:window.pageXOffset===s?document.documentElement.scrollLeft:window.pageXOffset,y:window.pageYOffset===s?document.documentElement.scrollTop:window.pageYOffset}}function t(u){var c=u.getBoundingClientRect(),f=e();return{x:parseInt(c.left,10)+parseInt(f.x,10),y:parseInt(c.top,10)+parseInt(f.y,10)}}function n(u){function c(w){var N=t(w);i("Moving to in page link (#"+f+") at x: "+N.x+" y: "+N.y),v(N.y,N.x,"scrollToOffset")}var f=u.split("#")[1]||u,r=decodeURIComponent(f),y=document.getElementById(r)||document.getElementsByName(r)[0];s===y?(i("In page link (#"+f+") not found in iFrame, so sending to parent"),v(0,0,"inPageLink","#"+f)):c(y)}function o(){var u=window.location.hash,c=window.location.href;u!==""&&u!=="#"&&n(c)}function a(){function u(c){function f(r){r.preventDefault(),n(this.getAttribute("href"))}c.getAttribute("href")!=="#"&&I(c,"click",f)}Array.prototype.forEach.call(document.querySelectorAll('a[href^="#"]'),u)}function d(){I(window,"hashchange",o)}function m(){setTimeout(o,W)}function l(){Array.prototype.forEach&&document.querySelectorAll?(i("Setting up location.hash handlers"),a(),d(),m()):T("In page linking not fully supported in this browser! (See README.md for IE8 workaround)")}return z.enable?l():i("In page linking not enabled"),{findTarget:n}}function Qe(){if(U!==!0)return;function e(n){v(0,0,n.type,n.screenY+":"+n.screenX)}function t(n,o){i("Add event listener: "+o),I(window.document,n,e)}t("mouseenter","Mouse Enter"),t("mouseleave","Mouse Leave")}function Ge(){i("Enable public methods"),Pe.parentIFrame={autoResize:function(e){return e===!0&&b===!1?(b=!0,Te()):e===!1&&b===!0&&(b=!1,Xe()),v(0,0,"autoResize",JSON.stringify(b)),b},close:function(){v(0,0,"close")},getId:function(){return P},getPageInfo:function(e){typeof e=="function"?(K=e,v(0,0,"pageInfo")):(K=function(){},v(0,0,"pageInfoStop"))},moveToAnchor:function(e){z.findTarget(e)},reset:function(){Ae("parentIFrame.reset")},scrollTo:function(e,t){v(t,e,"scrollTo")},scrollToOffset:function(e,t){v(t,e,"scrollToOffset")},sendMessage:function(e,t){v(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod:function(e){h=e,we()},setWidthCalculationMethod:function(e){p=e,be()},setTargetOrigin:function(e){i("Set targetOrigin: "+e),C=e},size:function(e,t){var n=""+(e||"")+(t?","+t:"");M("size","parentIFrame.size("+n+")",e,t)}}}function Ee(){O!==0&&(i("setInterval: "+O+"ms"),ae=setInterval(function(){M("interval","setInterval: "+O)},Math.abs(O)))}function Ze(){function e(r){function y(w){w.complete===!1&&(i("Attach listeners to "+w.src),w.addEventListener("load",a,!1),w.addEventListener("error",d,!1),u.push(w))}r.type==="attributes"&&r.attributeName==="src"?y(r.target):r.type==="childList"&&Array.prototype.forEach.call(r.target.querySelectorAll("img"),y)}function t(r){u.splice(u.indexOf(r),1)}function n(r){i("Remove listeners from "+r.src),r.removeEventListener("load",a,!1),r.removeEventListener("error",d,!1),t(r)}function o(r,y,w){n(r.target),M(y,w+": "+r.target.src)}function a(r){o(r,"imageLoad","Image loaded")}function d(r){o(r,"imageLoadFailed","Image load failed")}function m(r){M("mutationObserver","mutationObserver: "+r[0].target+" "+r[0].type),r.forEach(e)}function l(){var r=document.querySelector("body"),y={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0};return f=new c(m),i("Create body MutationObserver"),f.observe(r,y),f}var u=[],c=window.MutationObserver||window.WebKitMutationObserver,f=l();return{disconnect:function(){"disconnect"in f&&(i("Disconnect body MutationObserver"),f.disconnect(),u.forEach(n))}}}function $e(){var e=0>O;window.MutationObserver||window.WebKitMutationObserver?e?Ee():H=Ze():(i("MutationObserver not supported in this browser!"),Ee())}function $(e,t){var n=0;return t=t||document.body,n=document.defaultView.getComputedStyle(t,null),n=n===null?0:n[e],parseInt(n,Le)}function et(e){e>x/2&&(x=2*e,i("Event throttle increased to "+x+"ms"))}function ee(e,t){for(var n=t.length,o=0,a=0,d=he(e),m=Date.now(),l=0;l<n;l++)o=t[l].getBoundingClientRect()[e]+$("margin"+d,t[l]),o>a&&(a=o);return m=Date.now()-m,i("Parsed "+n+" HTML elements"),i("Element position calculated in "+m+"ms"),et(m),a}function j(e){return[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll()]}function Oe(e,t){function n(){return T("No tagged elements ("+t+") found on page"),document.querySelectorAll("body *")}var o=document.querySelectorAll("["+t+"]");return o.length===0&&n(),ee(e,o)}function Se(){return document.querySelectorAll("body *")}var E={bodyOffset:function(){return document.body.offsetHeight+$("marginTop")+$("marginBottom")},offset:function(){return E.bodyOffset()},bodyScroll:function(){return document.body.scrollHeight},custom:function(){return Q.height()},documentElementOffset:function(){return document.documentElement.offsetHeight},documentElementScroll:function(){return document.documentElement.scrollHeight},max:function(){return Math.max.apply(null,j(E))},min:function(){return Math.min.apply(null,j(E))},grow:function(){return E.max()},lowestElement:function(){return Math.max(E.bodyOffset()||E.documentElementOffset(),ee("bottom",Se()))},taggedElement:function(){return Oe("bottom","data-iframe-height")}},S={bodyScroll:function(){return document.body.scrollWidth},bodyOffset:function(){return document.body.offsetWidth},custom:function(){return Q.width()},documentElementScroll:function(){return document.documentElement.scrollWidth},documentElementOffset:function(){return document.documentElement.offsetWidth},scroll:function(){return Math.max(S.bodyScroll(),S.documentElementScroll())},max:function(){return Math.max.apply(null,j(S))},min:function(){return Math.min.apply(null,j(S))},rightMostElement:function(){return ee("right",Se())},taggedElement:function(){return Oe("right","data-iframe-width")}};function Me(e,t,n,o){function a(){A=f,k=r,v(A,k,e)}function d(){function y(w,N){var nt=Math.abs(w-N)<=V;return!nt}return f=s===n?E[h]():n,r=s===o?S[p]():o,y(A,f)||L&&y(k,r)}function m(){return!(e in{init:1,interval:1,size:1})}function l(){return h in ce||L&&p in ce}function u(){i("No change in size detected")}function c(){m()&&l()?Ae(t):e in{interval:1}||u()}var f,r;d()||e==="init"?(Ie(),a()):c()}var tt=je(Me);function M(e,t,n,o){function a(){e in{reset:1,resetPage:1,init:1}||i("Trigger event: "+t)}function d(){return D&&e in Fe}d()?i("Trigger event cancelled: "+e):(a(),e==="init"?Me(e,t,n,o):tt(e,t,n,o))}function Ie(){D||(D=!0,i("Trigger event lock on")),clearTimeout(de),de=setTimeout(function(){D=!1,i("Trigger event lock off"),i("--")},W)}function Ne(e){A=E[h](),k=S[p](),v(A,k,e)}function Ae(e){var t=h;h=B,i("Reset trigger event: "+e),Ie(),Ne("reset"),h=t}function v(e,t,n,o,a){function d(){s===a?a=C:i("Message targetOrigin: "+a)}function m(){var l=e+":"+t,u=P+":"+l+":"+n+(s===o?"":":"+o);i("Sending message to host page ("+u+")"),se.postMessage(F+u,a)}d(),m()}function ze(e){var t={init:function(){re=e.data,se=e.source,qe(),oe=!1,setTimeout(function(){ie=!1},W)},reset:function(){ie?i("Page reset ignored by init"):(i("Page size reset by host page"),Ne("resetPage"))},resize:function(){M("resizeParent","Parent window requested size check")},moveToAnchor:function(){z.findTarget(a())},inPageLink:function(){this.moveToAnchor()},pageInfo:function(){var c=a();i("PageInfoFromParent called from parent: "+c),K(JSON.parse(c)),i(" --")},message:function(){var c=a();i("onMessage called from parent: "+c),X(JSON.parse(c)),i(" --")}};function n(){return F===(""+e.data).slice(0,ue)}function o(){return e.data.split("]")[1].split(":")[0]}function a(){return e.data.slice(e.data.indexOf(":")+1)}function d(){return!Re.exports&&"iFrameResize"in window||window.jQuery!==s&&"iFrameResize"in window.jQuery.prototype}function m(){return e.data.split(":")[2]in{true:1,false:1}}function l(){var c=o();c in t?t[c]():!d()&&!m()&&T("Unexpected message ("+e.data+")")}function u(){oe===!1?l():m()?t.init():i('Ignored message of type "'+o()+'". Received before initialization.')}n()&&u()}function Ce(){document.readyState!=="loading"&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}"iframeResizer"in window||(window.iframeChildListener=function(e){ze({data:e})},I(window,"message",ze),I(window,"readystatechange",Ce),Ce())})()}(xe)),xe.exports}ot();const it=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{it as i};