1/* 2 iFrame Resizer (iframeSizer.contentWindow.min.js) - v4.3.9 - 2024-02-02 3 Desc: Include this file in any page being loaded into an iframe 4 to force the iframe to resize to the content size. 5 Requires: iframeResizer.min.js on host page. 6 Copyright: (c) 2024 David J. Bradshaw - [email protected] 7 License: MIT 8*/ 9!function(l){function na(){}function B(a,d,f,b){a.addEventListener(d,f,!!oa&&(b||{}))}function pa(a){return a.charAt(0).toUpperCase()+a.slice(1)}function e(a){T&&"object"==typeof window.console&&console.log(C+"["+D+"] "+a)}function u(a){"object"==typeof window.console&&console.warn(C+"["+D+"] "+a)}function La(){function a(c,g){return"function"==typeof c&&(e("Setup custom "+g+"CalcMethod"),U[g]=c,c="custom"),c}function d(c){r(0,0,c.type,c.screenY+":"+c.screenX)}function f(c,g){e("Add event listener: "+ 10g);B(window.document,c,d)}var b=qa.slice(ra).split(":");D=b[0];V=l===b[1]?V:Number(b[1]);K=l===b[2]?K:"true"===b[2];T=l===b[3]?T:"true"===b[3];A=l===b[4]?A:Number(b[4]);v=l===b[6]?v:"true"===b[6];L=b[7];p=l===b[8]?p:b[8];sa=b[9];ta=b[10];M=l===b[11]?M:Number(b[11]);E.enable=l!==b[12]&&"true"===b[12];W=l===b[13]?W:b[13];q=l===b[14]?q:b[14];X=l===b[15]?X:"true"===b[15];console.log("#Initialising iFrame ("+window.location.href+")");"iFrameResizer"in window&&Object===window.iFrameResizer.constructor&& 11(e("#Entro in FromPage"),b=window.iFrameResizer,e("Reading data from page: "+JSON.stringify(b)),Object.keys(b).forEach(Ma,b),Y="onMessage"in b?b.onMessage:Y,Z="onReady"in b?b.onReady:Z,F="targetOrigin"in b?b.targetOrigin:F,console.log("#Data: "+b),console.log("#data.targetOrigin: "+b.targetOrigin),p="heightCalculationMethod"in b?b.heightCalculationMethod:p,q="widthCalculationMethod"in b?b.widthCalculationMethod:q,p=a(p,"height"),q=a(q,"width"));e("TargetOrigin for parent set to: "+F);aa("margin", 12function(c,g){-1!==g.indexOf("-")&&(u("Negative CSS value ignored for "+c),g="");return g}("margin",L=l===L?V+"px":L));aa("background",sa);aa("padding",ta);(b=document.createElement("div")).style.clear="both";b.style.display="block";b.style.height="0";document.body.appendChild(b);ua();q=ba(q,ca,y,"width");document.documentElement.style.height="";document.body.style.height="";e('HTML \x26 body height set to "auto"');e("Enable public methods");Na.parentIFrame={autoResize:function(c){return!0===c&&!1=== 13v?(v=!0,va()):!1===c&&!0===v&&(v=!1,wa("remove"),null!==da&&da.disconnect(),clearInterval(xa)),r(0,0,"autoResize",JSON.stringify(v)),v},close:function(){r(0,0,"close")},getId:function(){return D},getPageInfo:function(c){"function"==typeof c?(ea=c,r(0,0,"pageInfo")):(ea=function(){},r(0,0,"pageInfoStop"))},moveToAnchor:function(c){E.findTarget(c)},reset:function(){ya("parentIFrame.reset")},scrollTo:function(c,g){r(g,c,"scrollTo")},scrollToOffset:function(c,g){r(g,c,"scrollToOffset")},sendMessage:function(c, 14g){r(0,0,"message",JSON.stringify(c),g)},setHeightCalculationMethod:function(c){p=c;ua()},setWidthCalculationMethod:function(c){q=c;q=ba(q,ca,y,"width")},setTargetOrigin:function(c){e("Set targetOrigin: "+c);F=c},size:function(c,g){z("size","parentIFrame.size("+((c||"")+(g?","+g:""))+")",c,g)}};!0===X&&(f("mouseenter","Mouse Enter"),f("mouseleave","Mouse Leave"));va();E=function(){function c(m){m=m.split("#")[1]||m;var k=decodeURIComponent(m);k=document.getElementById(k)||document.getElementsByName(k)[0]; 15if(l===k)e("In page link (#"+m+") not found in iFrame, so sending to parent"),r(0,0,"inPageLink","#"+m);else{k=k.getBoundingClientRect();var h=window.pageXOffset===l?document.documentElement.scrollLeft:window.pageXOffset,N=window.pageYOffset===l?document.documentElement.scrollTop:window.pageYOffset;k={x:parseInt(k.left,10)+parseInt(h,10),y:parseInt(k.top,10)+parseInt(N,10)};e("Moving to in page link (#"+m+") at x: "+k.x+" y: "+k.y);r(k.y,k.x,"scrollToOffset")}}function g(){var m=window.location.hash, 16k=window.location.href;""!==m&&"#"!==m&&c(k)}function t(){Array.prototype.forEach.call(document.querySelectorAll('a[href^\x3d"#"]'),function(m){"#"!==m.getAttribute("href")&&B(m,"click",function(k){k.preventDefault();c(this.getAttribute("href"))})})}E.enable?Array.prototype.forEach&&document.querySelectorAll?(e("Setting up location.hash handlers"),t(),B(window,"hashchange",g),setTimeout(g,fa)):u("In page linking not fully supported in this browser! (See README.md for IE8 workaround)"):e("In page linking not enabled"); 17return{findTarget:c}}();z("init","Init message from host page");Z()}function Ma(a){var d=a.split("Callback");2===d.length&&(this[d="on"+d[0].charAt(0).toUpperCase()+d[0].slice(1)]=this[a],delete this[a],u("Deprecated: '"+a+"' has been renamed '"+d+"'. The old method will be removed in the next major version."))}function aa(a,d){l!==d&&""!==d&&"null"!==d&&e("Body "+a+' set to "'+(document.body.style[a]=d)+'"')}function n(a){var d={add:function(f){function b(){z(a.eventName,a.eventType)}ha[f]=b;B(window, 18f,b,{passive:!0})},remove:function(f){var b=ha[f];delete ha[f];window.removeEventListener(f,b,!1)}};a.eventNames&&Array.prototype.map?(a.eventName=a.eventNames[0],a.eventNames.map(d[a.method])):d[a.method](a.eventName);e(pa(a.method)+" event listener: "+a.eventType)}function wa(a){n({method:a,eventType:"Animation Start",eventNames:["animationstart","webkitAnimationStart"]});n({method:a,eventType:"Animation Iteration",eventNames:["animationiteration","webkitAnimationIteration"]});n({method:a,eventType:"Animation End", 19eventNames:["animationend","webkitAnimationEnd"]});n({method:a,eventType:"Input",eventName:"input"});n({method:a,eventType:"Mouse Up",eventName:"mouseup"});n({method:a,eventType:"Mouse Down",eventName:"mousedown"});n({method:a,eventType:"Orientation Change",eventName:"orientationchange"});n({method:a,eventType:"Print",eventNames:["afterprint","beforeprint"]});n({method:a,eventType:"Ready State Change",eventName:"readystatechange"});n({method:a,eventType:"Touch Start",eventName:"touchstart"});n({method:a, 20eventType:"Touch End",eventName:"touchend"});n({method:a,eventType:"Touch Cancel",eventName:"touchcancel"});n({method:a,eventType:"Transition Start",eventNames:["transitionstart","webkitTransitionStart","MSTransitionStart","oTransitionStart","otransitionstart"]});n({method:a,eventType:"Transition Iteration",eventNames:["transitioniteration","webkitTransitionIteration","MSTransitionIteration","oTransitionIteration","otransitioniteration"]});n({method:a,eventType:"Transition End",eventNames:["transitionend", 21"webkitTransitionEnd","MSTransitionEnd","oTransitionEnd","otransitionend"]}
21);"child"===W&&n({method:a,eventType:"IFrame Resized",eventName:"resize"})}function ba(a,d,f,b){return d!==a&&(a in f||(u(a+" is not a valid option for "+b+"CalculationMethod."),a=d),e(b+' calculation method set to "'+a+'"')),a}function ua(){p=ba(p,ia,w,"height")}function va(){var a;!0===v?(wa("add"),a=0>A,window.MutationObserver||window.WebKitMutationObserver?a?za():da=function(){function d(h){function N(G){!1===G.complete&& 22(e("Attach listeners to "+G.src),G.addEventListener("load",b,!1),G.addEventListener("error",c,!1),t.push(G))}"attributes"===h.type&&"src"===h.attributeName?N(h.target):"childList"===h.type&&Array.prototype.forEach.call(h.target.querySelectorAll("img"),N)}function f(h){e("Remove listeners from "+h.src);h.removeEventListener("load",b,!1);h.removeEventListener("error",c,!1);t.splice(t.indexOf(h),1)}function b(h){f(h.target);z("imageLoad","Image loaded: "+h.target.src)}function c(h){f(h.target);z("imageLoadFailed", 23"Image load failed: "+h.target.src)}function g(h){z("mutationObserver","mutationObserver: "+h[0].target+" "+h[0].type);h.forEach(d)}var t=[],m=window.MutationObserver||window.WebKitMutationObserver,k=function(){var h=document.querySelector("body");return k=new m(g),e("Create body MutationObserver"),k.observe(h,{attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0}),k}();return{disconnect:function(){"disconnect"in k&&(e("Disconnect body MutationObserver"), 24k.disconnect(),t.forEach(f))}}}():(e("MutationObserver not supported in this browser!"),za())):e("Auto Resize disabled")}function za(){0!==A&&(e("setInterval: "+A+"ms"),xa=setInterval(function(){z("interval","setInterval: "+A)},Math.abs(A)))}function ja(a,d){return d=d||document.body,d=null===(d=document.defaultView.getComputedStyle(d,null))?0:d[a],parseInt(d,10)}function ka(a,d){for(var f,b=d.length,c=0,g=pa(a),t=Date.now(),m=0;m<b;m++)c<(f=d[m].getBoundingClientRect()[a]+ja("margin"+g,d[m]))&&(c= 25f);return t=Date.now()-t,e("Parsed "+b+" HTML elements"),e("Element position calculated in "+t+"ms"),O/2<t&&e("Event throttle increased to "+(O=2*t)+"ms"),c}function P(a){return[a.bodyOffset(),a.bodyScroll(),a.documentElementOffset(),a.documentElementScroll()]}function Aa(a,d){var f=document.querySelectorAll("["+d+"]");return 0===f.length&&(u("No tagged elements ("+d+") found on page"),document.querySelectorAll("body *")),ka(a,f)}function Ba(a,d,f,b){f=l===f?w[p]():f;b=l===b?y[q]():b;Math.abs(Q-f)<= 26M&&(!K||Math.abs(R-b)<=M)&&"init"!==a?a in{init:1,interval:1,size:1}||!(p in Ca||K&&q in Ca)?a in{interval:1}||e("No change in size detected"):ya(d):(Da(),r(Q=f,R=b,a))}function Oa(){H=Date.now();x=null;la=ma.apply(I,J);x||(I=J=null)}function z(a,d,f,b){S&&a in Pa?e("Trigger event cancelled: "+a):(a in{reset:1,resetPage:1,init:1}||e("Trigger event: "+d),("init"===a?Ba:Qa)(a,d,f,b))}function Da(){S||(S=!0,e("Trigger event lock on"));clearTimeout(Ea);Ea=setTimeout(function(){S=!1;e("Trigger event lock off"); 27e("--")},fa)}function Fa(a){Q=w[p]();R=y[q]();r(Q,R,a)}function ya(a){var d=p;p=ia;e("Reset trigger event: "+a);Da();Fa("reset");p=d}function r(a,d,f,b,c){!0===Ra&&(l===c?c=F:e("Message targetOrigin: "+c),e("Sending message to host page ("+(a=D+":"+(a+":"+d)+":"+f+(l===b?"":":"+b))+")ContentWindow_TargetOrigin: "+c),Ga.postMessage(C+a,c))}function Ha(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}if("undefined"!=typeof window){var v=!0,sa="",V=0,L="", 28da=null,ta="",K=!1,Pa={resize:1,click:1},fa=128,Ia=!0,Q=1,ia="bodyOffset",p=ia,Ja=!0,qa="",E={},A=32,xa=null,T=!1,X=!1,C="[iFrameSizer]",ra=C.length,D="",Ca={max:1,min:1,bodyScroll:1,documentElementScroll:1},W="child",Ra=!0,Ga=window.parent,F="*",M=0,S=!1,Ea=null,O=16,R=1,ca="scroll",q=ca,Na=window,Y=function(){u("onMessage function not defined")},Z=function(){},ea=function(){},U={height:function(){return u("Custom height calculation function not defined"),document.documentElement.offsetHeight},width:function(){return u("Custom width calculation function not defined"), 29document.body.scrollWidth}},ha={},oa=!1;try{var Ka=Object.create({},{passive:{get:function(){oa=!0}}});window.addEventListener("test",na,Ka);window.removeEventListener("test",na,Ka)}catch(a){}var ma,I,J,la,x,H,w={bodyOffset:function(){return document.body.offsetHeight+ja("marginTop")+ja("marginBottom")},offset:function(){return w.bodyOffset()},bodyScroll:function(){return document.body.scrollHeight},custom:function(){return U.height()},documentElementOffset:function(){return document.documentElement.offsetHeight}, 30documentElementScroll:function(){return document.documentElement.scrollHeight},max:function(){return Math.max.apply(null,P(w))},min:function(){return Math.min.apply(null,P(w))},grow:function(){return w.max()},lowestElement:function(){return Math.max(w.bodyOffset()||w.documentElementOffset(),ka("bottom",document.querySelectorAll("body *")))},taggedElement:function(){return Aa("bottom","data-iframe-height")}},y={bodyScroll:function(){return document.body.scrollWidth},bodyOffset:function(){return document.body.offsetWidth}, 31custom:function(){return U.width()},documentElementScroll:function(){return document.documentElement.scrollWidth},documentElementOffset:function(){return document.documentElement.offsetWidth},scroll:function(){return Math.max(y.bodyScroll(),y.documentElementScroll())},max:function(){return Math.max.apply(null,P(y))},min:function(){return Math.min.apply(null,P(y))},rightMostElement:function(){return ka("right",document.querySelectorAll("body *"))},taggedElement:function(){return Aa("right","data-iframe-width")}}, 32Qa=(ma=Ba,x=null,H=0,function(){var a=Date.now(),d=O-(a-(H=H||a));return I=this,J=arguments,0>=d||O<d?(x&&(clearTimeout(x),x=null),H=a,la=ma.apply(I,J),x||(I=J=null)):x=x||setTimeout(Oa,d),la});B(window,"message",function(a){function d(){return a.data.slice(a.data.indexOf(":")+1)}function f(){return a.data.split(":")[2]in{true:1,false:1}}function b(){var g=a.data.split("]")[1].split(":")[0];g in c?c[g]():("undefined"==typeof module||!module.exports)&&"iFrameResize"in window||window.jQuery!==l&&"iFrameResize"in 33window.jQuery.prototype||f()||u("Unexpected message ("+a.data+")")}var c={init:function(){qa=a.data;Ga=a.source;La();Ia=!1;setTimeout(function(){Ja=!1},fa)},reset:function(){Ja?e("Page reset ignored by init"):(e("Page size reset by host page"),Fa("resetPage"))},resize:function(){z("resizeParent","Parent window requested size check")},moveToAnchor:function(){E.findTarget(d())},inPageLink:function(){this.moveToAnchor()},pageInfo:function(){var g=d();e("PageInfoFromParent called from parent: "+g);ea(JSON.parse(g)); 34e(" --")},message:function(){var g=d();e("onMessage called from parent: "+g);Y(JSON.parse(g));e(" --")}};C===(""+a.data).slice(0,ra)&&(!1===Ia?b():f()?c.init():e('Ignored message of type "'+a.data.split("]")[1].split(":")[0]+'". Received before initialization.'))});B(window,"readystatechange",Ha);Ha()}}();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.