reframer
Version:
A declarative wrapper to iframe-resizer. Just add reframer class to any iframe. Cool!
3 lines (2 loc) • 30.9 kB
JavaScript
!function(){function e(e,n,t,i){Object.defineProperty(e,n,{get:t,set:i,enumerable:!0,configurable:!0})}var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},t={},i={},o=n.parcelRequire94c2;function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function a(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},i=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),i.forEach((function(n){r(e,n,t[n])}))}return e}function s(e){return e&&e.constructor===Symbol?"symbol":typeof e}null==o&&((o=function(e){if(e in t)return t[e].exports;if(e in i){var n=i[e];delete i[e];var o={id:e,exports:{}};return t[e]=o,n.call(o.exports,o,o.exports),o.exports}var r=new Error("Cannot find module '"+e+"'");throw r.code="MODULE_NOT_FOUND",r}).register=function(e,n){i[e]=n},n.parcelRequire94c2=o),o.register("cx66d",(function(n,t){var i,r,a;e(n.exports,"iframeResize",(function(){return i}),(function(e){return i=e})),e(n.exports,"iframeResizer",(function(){return r}),(function(e){return r=e})),e(n.exports,"iframeResizerContentWindow",(function(){return a}),(function(e){return a=e}));var s=o("gPFSL");i=s,r=s,a=o("Nnjfj")})),o.register("gPFSL",(function(e,n){!function(n){if("undefined"!=typeof window){var t,i=0,o=!1,r=!1,a="message".length,u="[iFrameSizer]",c=u.length,d=null,f=window.requestAnimationFrame,l={max:1,scroll:1,bodyScroll:1,documentElementScroll:1},m={},g=null,h={autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"bodyOffset",id:"iFrameResizer",interval:32,log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,mouseEvents:!0,resizeFrom:"parent",scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,widthCalculationMethod:"scroll",onClose:function(){return!0},onClosed:function(){},onInit:function(){},onMessage:function(){E("onMessage function not defined")},onMouseEnter:function(){},onMouseLeave:function(){},onResized:function(){},onScroll:function(){return!0}},p={};window.jQuery&&((t=window.jQuery).fn?t.fn.iFrameResize||(t.fn.iFrameResize=function(e){return this.filter("iframe").each((function(n,t){W(t,e)})).end()}):O("","Unable to bind to jQuery, it is not fully loaded.")),"function"==typeof define&&define.amd?define([],U):"object"==typeof e.exports&&(e.exports=U()),window.iFrameResize=window.iFrameResize||U()}function w(){return window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver}function b(e,n,t){e.addEventListener(n,t,!1)}function v(e,n,t){e.removeEventListener(n,t,!1)}function y(e){return u+"["+function(e){var n="Host page: "+e;return window.top!==window.self&&(n=window.parentIFrame&&window.parentIFrame.getId?window.parentIFrame.getId()+": "+e:"Nested host page: "+e),n}(e)+"]"}function T(e){return m[e]?m[e].log:o}function M(e,n){I("log",e,n,T(e))}function O(e,n){I("info",e,n,T(e))}function E(e,n){I("warn",e,n,!0)}function I(e,n,t,i){!0===i&&"object"==typeof window.console&&console[e](y(n),t)}function z(e){function n(){o("Height"),o("Width"),P((function(){A(D),R(B),w("onResized",D)}),D,"init")}function t(e){return"border-box"!==e.boxSizing?0:(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function i(e){return"border-box"!==e.boxSizing?0:(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}function o(e){var n=Number(m[B]["max"+e]),t=Number(m[B]["min"+e]),i=e.toLowerCase(),o=Number(D[i]);M(B,"Checking "+i+" is in range "+t+"-"+n),o<t&&(o=t,M(B,"Set "+i+" to min value")),o>n&&(o=n,M(B,"Set "+i+" to max value")),D[i]=""+o}function r(e){return q.substr(q.indexOf(":")+a+e)}function s(e,n){var t,i,o;t=function(){var t,i;j("Send Page Info","pageInfo:"+(t=document.body.getBoundingClientRect(),i=D.iframe.getBoundingClientRect(),JSON.stringify({iframeHeight:i.height,iframeWidth:i.width,clientHeight:Math.max(document.documentElement.clientHeight,window.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,window.innerWidth||0),offsetTop:parseInt(i.top-t.top,10),offsetLeft:parseInt(i.left-t.left,10),scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,documentHeight:document.documentElement.clientHeight,documentWidth:document.documentElement.clientWidth,windowHeight:window.innerHeight,windowWidth:window.innerWidth})),e,n)},i=32,p[o=n]||(p[o]=setTimeout((function(){p[o]=null,t()}),i))}function f(e){var n=e.getBoundingClientRect();return k(B),{x:Math.floor(Number(n.left)+Number(d.x)),y:Math.floor(Number(n.top)+Number(d.y))}}function l(e){var n=e?f(D.iframe):{x:0,y:0},t={x:Number(D.width)+n.x,y:Number(D.height)+n.y};M(B,"Reposition requested from iFrame (offset x:"+n.x+" y:"+n.y+")"),window.top!==window.self?window.parentIFrame?window.parentIFrame["scrollTo"+(e?"Offset":"")](t.x,t.y):E(B,"Unable to scroll to requested position, window.parentIFrame not found"):(d=t,g(),M(B,"--"))}function g(){!1!==w("onScroll",d)?R(B):F()}function h(e){var n={};if(0===Number(D.width)&&0===Number(D.height)){var t=r(9).split(":");n={x:t[1],y:t[0]}}else n={x:D.width,y:D.height};w(e,{iframe:D.iframe,screenX:Number(n.x),screenY:Number(n.y),type:D.type})}function w(e,n){return x(B,e,n)}var y,T,I,z,S,W,H,q=e.data,D={},B=null;"[iFrameResizerChild]Ready"===q?function(){for(var e in m)j("iFrame requested init",L(e),m[e].iframe,e)}():u===(""+q).substr(0,c)&&q.substr(c).split(":")[0]in m?(z=q.substr(c).split(":"),S=z[1]?parseInt(z[1],10):0,W=m[z[0]]&&m[z[0]].iframe,H=getComputedStyle(W),D={iframe:W,id:z[0],height:S+t(H)+i(H),width:z[2],type:z[3]},B=D.id,m[B]&&(m[B].loaded=!0),(I=D.type in{true:1,false:1,undefined:1})&&M(B,"Ignoring init message from meta parent page"),!I&&(T=!0,m[y=B]||(T=!1,E(D.type+" No settings for "+y+". Message was: "+q)),T)&&(M(B,"Received: "+q),function(){var e=!0;return null===D.iframe&&(E(B,"IFrame ("+D.id+") not found"),e=!1),e}()&&function(){var n,t=e.origin,i=m[B]&&m[B].checkOrigin;if(i&&""+t!="null"&&!(i.constructor===Array?function(){var e=0,n=!1;for(M(B,"Checking connection is from allowed list of origins: "+i);e<i.length;e++)if(i[e]===t){n=!0;break}return n}():(n=m[B]&&m[B].remoteHost,M(B,"Checking connection is from: "+n),t===n)))throw new Error("Unexpected message received from: "+t+" for "+D.iframe.id+". Message was: "+e.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return!0}()&&function(){switch(m[B]&&m[B].firstRun&&m[B]&&(m[B].firstRun=!1),D.type){case"close":N(D.iframe);break;case"message":a=r(6),M(B,"onMessage passed: {iframe: "+D.iframe.id+", message: "+a+"}"),w("onMessage",{iframe:D.iframe,message:JSON.parse(a)}),M(B,"--");break;case"mouseenter":h("onMouseEnter");break;case"mouseleave":h("onMouseLeave");break;case"autoResize":m[B].autoResize=JSON.parse(r(9));break;case"scrollTo":l(!1);break;case"scrollToOffset":l(!0);break;case"pageInfo":s(m[B]&&m[B].iframe,B),function(){function e(e,i){function o(){m[t]?s(m[t].iframe,t):n()}["scroll","resize"].forEach((function(n){M(t,e+n+" listener for sendPageInfo"),i(window,n,o)}))}function n(){e("Remove ",v)}var t=B;e("Add ",b),m[t]&&(m[t].stopPageInfo=n)}();break;case"pageInfoStop":m[B]&&m[B].stopPageInfo&&(m[B].stopPageInfo(),delete m[B].stopPageInfo);break;case"inPageLink":t=r(9).split("#")[1]||"",i=decodeURIComponent(t),(o=document.getElementById(i)||document.getElementsByName(i)[0])?(e=f(o),M(B,"Moving to in page link (#"+t+") at x: "+e.x+" y: "+e.y),d={x:e.x,y:e.y},g(),M(B,"--")):window.top!==window.self?window.parentIFrame?window.parentIFrame.moveToAnchor(t):M(B,"In page link #"+t+" not found and window.parentIFrame not found"):M(B,"In page link #"+t+" not found");break;case"reset":C(D);break;case"init":n(),w("onInit",D.iframe);break;default:0===Number(D.width)&&0===Number(D.height)?E("Unsupported message received ("+D.type+"), this is likely due to the iframe containing a later version of iframe-resizer than the parent page"):n()}var e,t,i,o,a}())):O(B,"Ignored: "+q)}function x(e,n,t){var i=null,o=null;if(m[e]){if("function"!=typeof(i=m[e][n]))throw new TypeError(n+" on iFrame["+e+"] is not a function");o=i(t)}return o}function S(e){var n=e.id;delete m[n]}function N(e){var n=e.id;if(!1!==x(n,"onClose",n)){M(n,"Removing iFrame: "+n);try{e.parentNode&&e.parentNode.removeChild(e)}catch(e){E(e)}x(n,"onClosed",n),M(n,"--"),S(e)}else M(n,"Close iframe cancelled by onClose event")}function k(e){null===d&&M(e,"Get page position: "+(d={x:window.pageXOffset!==n?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==n?window.pageYOffset:document.documentElement.scrollTop}).x+","+d.y)}function R(e){null!==d&&(window.scrollTo(d.x,d.y),M(e,"Set page position: "+d.x+","+d.y),F())}function F(){d=null}function C(e){M(e.id,"Size reset requested by "+("init"===e.type?"host page":"iFrame")),k(e.id),P((function(){A(e),j("reset","reset",e.iframe,e.id)}),e,"reset")}function A(e){function n(n){r||"0"!==e[n]||(r=!0,M(i,"Hidden iFrame detected, creating visibility listener"),function(){function e(){function e(e){function n(n){return"0px"===(m[e]&&m[e].iframe.style[n])}function t(e){return null!==e.offsetParent}m[e]&&t(m[e].iframe)&&(n("height")||n("width"))&&j("Visibility change","resize",m[e].iframe,e)}Object.keys(m).forEach((function(n){e(n)}))}function n(n){M("window","Mutation observed: "+n[0].target+" "+n[0].type),H(e,16)}function t(){var e=document.querySelector("body"),t={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0};new i(n).observe(e,t)}var i=w();i&&t()}())}function t(t){!function(n){e.id?(e.iframe.style[n]=e[n]+"px",M(e.id,"IFrame ("+i+") "+n+" set to "+e[n]+"px")):M("undefined","messageData id not set")}(t),n(t)}var i=e.iframe.id;m[i]&&(m[i].sizeHeight&&t("height"),m[i].sizeWidth&&t("width"))}function P(e,n,t){t!==n.type&&f&&!window.jasmine?(M(n.id,"Requesting animation frame"),f(e)):e()}function j(e,n,t,i,o){var r,a=!1;i=i||t.id,m[i]&&(t&&"contentWindow"in t&&null!==t.contentWindow?(r=m[i]&&m[i].targetOrigin,M(i,"["+e+"] Sending msg to iframe["+i+"] ("+n+") targetOrigin: "+r),t.contentWindow.postMessage(u+n,r)):E(i,"["+e+"] IFrame("+i+") not found"),o&&m[i]&&m[i].warningTimeout&&(m[i].msgTimeout=setTimeout((function(){!m[i]||m[i].loaded||a||(a=!0,E(i,"IFrame has not responded within "+m[i].warningTimeout/1e3+" seconds. Check iFrameResizer.contentWindow.js has been loaded in iFrame. This message can be ignored if everything is working, or you can set the warningTimeout option to a higher value or zero to suppress this warning."))}),m[i].warningTimeout)))}function L(e){return e+":"+m[e].bodyMarginV1+":"+m[e].sizeWidth+":"+m[e].log+":"+m[e].interval+":"+m[e].enablePublicMethods+":"+m[e].autoResize+":"+m[e].bodyMargin+":"+m[e].heightCalculationMethod+":"+m[e].bodyBackground+":"+m[e].bodyPadding+":"+m[e].tolerance+":"+m[e].inPageLinks+":"+m[e].resizeFrom+":"+m[e].widthCalculationMethod+":"+m[e].mouseEvents}function W(e,t){function r(e){var n=e.split("Callback");if(2===n.length){var t="on"+n[0].charAt(0).toUpperCase()+n[0].slice(1);this[t]=this[e],delete this[e],E(g,"Deprecated: '"+e+"' has been renamed '"+t+"'. The old method will be removed in the next major version.")}}var a,s,u,c,d,f,g=(""===(a=e.id)&&(e.id=(s=t&&t.id||h.id+i++,null!==document.getElementById(s)&&(s+=i++),a=s),o=(t||{}).log,M(a,"Added missing iframe ID: "+a+" ("+e.src+")")),a);g in m&&"iFrameResizer"in e?E(g,"Ignored iFrame, already setup."):(d=(d=t)||{},m[g]={firstRun:!0,iframe:e,remoteHost:e.src&&e.src.split("/").slice(0,3).join("/")},function(e){if("object"!=typeof e)throw new TypeError("Options is not an object")}(d),Object.keys(d).forEach(r,d),function(e){for(var n in h)Object.prototype.hasOwnProperty.call(h,n)&&(m[g][n]=Object.prototype.hasOwnProperty.call(e,n)?e[n]:h[n])}(d),m[g]&&(m[g].targetOrigin=!0===m[g].checkOrigin?""===(f=m[g].remoteHost)||null!==f.match(/^(about:blank|javascript:|file:\/\/)/)?"*":f:"*"),function(){switch(M(g,"IFrame scrolling "+(m[g]&&m[g].scrolling?"enabled":"disabled")+" for "+g),e.style.overflow=!1===(m[g]&&m[g].scrolling)?"hidden":"auto",m[g]&&m[g].scrolling){case"omit":break;case!0:e.scrolling="yes";break;case!1:e.scrolling="no";break;default:e.scrolling=m[g]?m[g].scrolling:"no"}}(),function(){function n(n){var t=m[g][n];1/0!==t&&0!==t&&(e.style[n]="number"==typeof t?t+"px":t,M(g,"Set "+n+" = "+e.style[n]))}function t(e){if(m[g]["min"+e]>m[g]["max"+e])throw new Error("Value for min"+e+" can not be greater than max"+e)}t("Height"),t("Width"),n("maxHeight"),n("minHeight"),n("maxWidth"),n("minWidth")}(),"number"!=typeof(m[g]&&m[g].bodyMargin)&&"0"!==(m[g]&&m[g].bodyMargin)||(m[g].bodyMarginV1=m[g].bodyMargin,m[g].bodyMargin=m[g].bodyMargin+"px"),u=L(g),(c=w())&&function(n){e.parentNode&&new n((function(n){n.forEach((function(n){Array.prototype.slice.call(n.removedNodes).forEach((function(n){n===e&&N(e)}))}))})).observe(e.parentNode,{childList:!0})}(c),b(e,"load",(function(){var t,i;j("iFrame.onload",u,e,n,!0),t=m[g]&&m[g].firstRun,i=m[g]&&m[g].heightCalculationMethod in l,!t&&i&&C({iframe:e,height:0,width:0,type:"init"})})),j("init",u,e,n,!0),m[g]&&(m[g].iframe.iFrameResizer={close:N.bind(null,m[g].iframe),removeListeners:S.bind(null,m[g].iframe),resize:j.bind(null,"Window resize","resize",m[g].iframe),moveToAnchor:function(e){j("Move to anchor","moveToAnchor:"+e,m[g].iframe,g)},sendMessage:function(e){j("Send Message","message:"+(e=JSON.stringify(e)),m[g].iframe,g)}}))}function H(e,n){null===g&&(g=setTimeout((function(){g=null,e()}),n))}function q(){"hidden"!==document.visibilityState&&(M("document","Trigger event: Visiblity change"),H((function(){D("Tab Visable","resize")}),16))}function D(e,n){Object.keys(m).forEach((function(t){(function(e){return m[e]&&"parent"===m[e].resizeFrom&&m[e].autoResize&&!m[e].firstRun})(t)&&j(e,n,m[t].iframe,t)}))}function B(){b(window,"message",z),b(window,"resize",(function(){var e;M("window","Trigger event: "+(e="resize")),H((function(){D("Window "+e,"resize")}),16)})),b(document,"visibilitychange",q),b(document,"-webkit-visibilitychange",q)}function U(){function e(e,n){n&&(!function(){if(!n.tagName)throw new TypeError("Object is not a valid DOM element");if("IFRAME"!==n.tagName.toUpperCase())throw new TypeError("Expected <IFRAME> tag, found <"+n.tagName+">")}(),W(n,e),t.push(n))}var t;return function(){var e,n=["moz","webkit","o","ms"];for(e=0;e<n.length&&!f;e+=1)f=window[n[e]+"RequestAnimationFrame"];f?f=f.bind(window):M("setup","RequestAnimationFrame not supported")}(),B(),function(i,o){switch(t=[],function(e){e&&e.enablePublicMethods&&E("enablePublicMethods option has been removed, public methods are now always available in the iFrame")}(i),void 0===o?"undefined":s(o)){case"undefined":case"string":Array.prototype.forEach.call(document.querySelectorAll(o||"iframe"),e.bind(n,i));break;case"object":e(i,o);break;default:throw new TypeError("Unexpected data type ("+(void 0===o?"undefined":s(o))+")")}return t}}}()})),o.register("Nnjfj",(function(e,n){!function(n){if("undefined"!=typeof window){var t=!0,i="",o=0,r="",a=null,s="",u=!1,c={resize:1,click:1},d=128,f=!0,l=1,m="bodyOffset",g=m,h=!0,p="",w={},b=32,v=null,y=!1,T=!1,M="[iFrameSizer]",O=M.length,E="",I={max:1,min:1,bodyScroll:1,documentElementScroll:1},z="child",x=window.parent,S="*",N=0,k=!1,R=null,F=16,C=1,A="scroll",P=A,j=window,L=function(){re("onMessage function not defined")},W=function(){},H=function(){},q={height:function(){return re("Custom height calculation function not defined"),document.documentElement.offsetHeight},width:function(){return re("Custom width calculation function not defined"),document.body.scrollWidth}},D={},B=!1;try{var U=Object.create({},{passive:{get:function(){B=!0}}});window.addEventListener("test",ee,U),window.removeEventListener("test",ee,U)}catch(e){}var V,J,X,Y,Q,K,_,G={bodyOffset:function(){return document.body.offsetHeight+pe("marginTop")+pe("marginBottom")},offset:function(){return G.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,be(G))},min:function(){return Math.min.apply(null,be(G))},grow:function(){return G.max()},lowestElement:function(){return Math.max(G.bodyOffset()||G.documentElementOffset(),we("bottom",ye()))},taggedElement:function(){return ve("bottom","data-iframe-height")}},Z={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(Z.bodyScroll(),Z.documentElementScroll())},max:function(){return Math.max.apply(null,be(Z))},min:function(){return Math.min.apply(null,be(Z))},rightMostElement:function(){return we("right",ye())},taggedElement:function(){return ve("right","data-iframe-width")}},$=(V=Te,Q=null,K=0,_=function(){K=Date.now(),Q=null,Y=V.apply(J,X),Q||(J=X=null)},function(){var e=Date.now();K||(K=e);var n=F-(e-K);return J=this,X=arguments,n<=0||n>F?(Q&&(clearTimeout(Q),Q=null),K=e,Y=V.apply(J,X),Q||(J=X=null)):Q||(Q=setTimeout(_,n)),Y});ne(window,"message",(function(n){var t={init:function(){p=n.data,x=n.source,ae(),f=!1,setTimeout((function(){h=!1}),d)},reset:function(){h?oe("Page reset ignored by init"):(oe("Page size reset by host page"),Ee("resetPage"))},resize:function(){Me("resizeParent","Parent window requested size check")},moveToAnchor:function(){w.findTarget(o())},inPageLink:function(){this.moveToAnchor()},pageInfo:function(){var e=o();oe("PageInfoFromParent called from parent: "+e),H(JSON.parse(e)),oe(" --")},message:function(){var e=o();oe("onMessage called from parent: "+e),L(JSON.parse(e)),oe(" --")}};function i(){return n.data.split("]")[1].split(":")[0]}function o(){return n.data.substr(n.data.indexOf(":")+1)}function r(){return n.data.split(":")[2]in{true:1,false:1}}function a(){var o=i();o in t?t[o]():!e.exports&&"iFrameResize"in window||"jQuery"in window&&"iFrameResize"in window.jQuery.prototype||r()||re("Unexpected message ("+n.data+")")}M===(""+n.data).substr(0,O)&&(!1===f?a():r()?t.init():oe('Ignored message of type "'+i()+'". Received before initialization.'))})),ne(window,"readystatechange",xe),xe()}function ee(){}function ne(e,n,t,i){e.addEventListener(n,t,!!B&&(i||{}))}function te(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ie(e){return M+"["+E+"] "+e}function oe(e){y&&"object"==typeof window.console&&console.log(ie(e))}function re(e){"object"==typeof window.console&&console.warn(ie(e))}function ae(){var e;!function(){function e(e){return"true"===e}var a=p.substr(O).split(":");E=a[0],o=n!==a[1]?Number(a[1]):o,u=n!==a[2]?e(a[2]):u,y=n!==a[3]?e(a[3]):y,b=n!==a[4]?Number(a[4]):b,t=n!==a[6]?e(a[6]):t,r=a[7],g=n!==a[8]?a[8]:g,i=a[9],s=a[10],N=n!==a[11]?Number(a[11]):N,w.enable=n!==a[12]&&e(a[12]),z=n!==a[13]?a[13]:z,P=n!==a[14]?a[14]:P,T=n!==a[15]?Boolean(a[15]):T}(),oe("Initialising iFrame ("+window.location.href+")"),function(){function e(){var e=window.iFrameResizer;oe("Reading data from page: "+JSON.stringify(e)),Object.keys(e).forEach(se,e),L="onMessage"in e?e.onMessage:L,W="onReady"in e?e.onReady:W,S="targetOrigin"in e?e.targetOrigin:S,g="heightCalculationMethod"in e?e.heightCalculationMethod:g,P="widthCalculationMethod"in e?e.widthCalculationMethod:P}function n(e,n){return"function"==typeof e&&(oe("Setup custom "+n+"CalcMethod"),q[n]=e,e="custom"),e}"iFrameResizer"in window&&Object===window.iFrameResizer.constructor&&(e(),g=n(g,"height"),P=n(P,"width"));oe("TargetOrigin for parent set to: "+S)}(),function(){n===r&&(r=o+"px");ue("margin",function(e,n){-1!==n.indexOf("-")&&(re("Negative CSS value ignored for "+e),n="");return n}("margin",r))}(),ue("background",i),ue("padding",s),(e=document.createElement("div")).style.clear="both",e.style.display="block",e.style.height="0",document.body.appendChild(e),le(),me(),document.documentElement.style.height="",document.body.style.height="",oe('HTML & body height set to "auto"'),oe("Enable public methods"),j.parentIFrame={autoResize:function(e){return!0===e&&!1===t?(t=!0,ge()):!1===e&&!0===t&&(t=!1,de("remove"),null!==a&&a.disconnect(),clearInterval(v)),ze(0,0,"autoResize",JSON.stringify(t)),t},close:function(){ze(0,0,"close")},getId:function(){return E},getPageInfo:function(e){"function"==typeof e?(H=e,ze(0,0,"pageInfo")):(H=function(){},ze(0,0,"pageInfoStop"))},moveToAnchor:function(e){w.findTarget(e)},reset:function(){Ie("parentIFrame.reset")},scrollTo:function(e,n){ze(n,e,"scrollTo")},scrollToOffset:function(e,n){ze(n,e,"scrollToOffset")},sendMessage:function(e,n){ze(0,0,"message",JSON.stringify(e),n)},setHeightCalculationMethod:function(e){g=e,le()},setWidthCalculationMethod:function(e){P=e,me()},setTargetOrigin:function(e){oe("Set targetOrigin: "+e),S=e},size:function(e,n){Me("size","parentIFrame.size("+(e||"")+(n?","+n:"")+")",e,n)}},function(){if(!0!==T)return;function e(e){ze(0,0,e.type,e.screenY+":"+e.screenX)}function n(n,t){oe("Add event listener: "+t),ne(window.document,n,e)}n("mouseenter","Mouse Enter"),n("mouseleave","Mouse Leave")}(),ge(),w=function(){function e(){return{x:window.pageXOffset!==n?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==n?window.pageYOffset:document.documentElement.scrollTop}}function t(n){var t=n.getBoundingClientRect(),i=e();return{x:parseInt(t.left,10)+parseInt(i.x,10),y:parseInt(t.top,10)+parseInt(i.y,10)}}function i(e){function i(e){var n=t(e);oe("Moving to in page link (#"+o+") at x: "+n.x+" y: "+n.y),ze(n.y,n.x,"scrollToOffset")}var o=e.split("#")[1]||e,r=decodeURIComponent(o),a=document.getElementById(r)||document.getElementsByName(r)[0];n!==a?i(a):(oe("In page link (#"+o+") not found in iFrame, so sending to parent"),ze(0,0,"inPageLink","#"+o))}function o(){var e=window.location.hash,n=window.location.href;""!==e&&"#"!==e&&i(n)}function r(){function e(e){function n(e){e.preventDefault(),i(this.getAttribute("href"))}"#"!==e.getAttribute("href")&&ne(e,"click",n)}Array.prototype.forEach.call(document.querySelectorAll('a[href^="#"]'),e)}function a(){ne(window,"hashchange",o)}function s(){setTimeout(o,d)}function u(){Array.prototype.forEach&&document.querySelectorAll?(oe("Setting up location.hash handlers"),r(),a(),s()):re("In page linking not fully supported in this browser! (See README.md for IE8 workaround)")}w.enable?u():oe("In page linking not enabled");return{findTarget:i}}(),Me("init","Init message from host page"),W()}function se(e){var n=e.split("Callback");if(2===n.length){var t="on"+n[0].charAt(0).toUpperCase()+n[0].slice(1);this[t]=this[e],delete this[e],re("Deprecated: '"+e+"' has been renamed '"+t+"'. The old method will be removed in the next major version.")}}function ue(e,t){n!==t&&""!==t&&"null"!==t&&(document.body.style[e]=t,oe("Body "+e+' set to "'+t+'"'))}function ce(e){var n={add:function(n){function t(){Me(e.eventName,e.eventType)}D[n]=t,ne(window,n,t,{passive:!0})},remove:function(e){var n,t,i,o=D[e];delete D[e],n=window,t=e,i=o,n.removeEventListener(t,i,!1)}};e.eventNames&&Array.prototype.map?(e.eventName=e.eventNames[0],e.eventNames.map(n[e.method])):n[e.method](e.eventName),oe(te(e.method)+" event listener: "+e.eventType)}function de(e){ce({method:e,eventType:"Animation Start",eventNames:["animationstart","webkitAnimationStart"]}),ce({method:e,eventType:"Animation Iteration",eventNames:["animationiteration","webkitAnimationIteration"]}),ce({method:e,eventType:"Animation End",eventNames:["animationend","webkitAnimationEnd"]}),ce({method:e,eventType:"Input",eventName:"input"}),ce({method:e,eventType:"Mouse Up",eventName:"mouseup"}),ce({method:e,eventType:"Mouse Down",eventName:"mousedown"}),ce({method:e,eventType:"Orientation Change",eventName:"orientationchange"}),ce({method:e,eventType:"Print",eventName:["afterprint","beforeprint"]}),ce({method:e,eventType:"Ready State Change",eventName:"readystatechange"}),ce({method:e,eventType:"Touch Start",eventName:"touchstart"}),ce({method:e,eventType:"Touch End",eventName:"touchend"}),ce({method:e,eventType:"Touch Cancel",eventName:"touchcancel"}),ce({method:e,eventType:"Transition Start",eventNames:["transitionstart","webkitTransitionStart","MSTransitionStart","oTransitionStart","otransitionstart"]}),ce({method:e,eventType:"Transition Iteration",eventNames:["transitioniteration","webkitTransitionIteration","MSTransitionIteration","oTransitionIteration","otransitioniteration"]}),ce({method:e,eventType:"Transition End",eventNames:["transitionend","webkitTransitionEnd","MSTransitionEnd","oTransitionEnd","otransitionend"]}),"child"===z&&ce({method:e,eventType:"IFrame Resized",eventName:"resize"})}function fe(e,n,t,i){return n!==e&&(e in t||(re(e+" is not a valid option for "+i+"CalculationMethod."),e=n),oe(i+' calculation method set to "'+e+'"')),e}function le(){g=fe(g,m,G,"height")}function me(){P=fe(P,A,Z,"width")}function ge(){var e;!0===t?(de("add"),e=0>b,window.MutationObserver||window.WebKitMutationObserver?e?he():a=function(){function e(e){function n(e){!1===e.complete&&(oe("Attach listeners to "+e.src),e.addEventListener("load",o,!1),e.addEventListener("error",r,!1),u.push(e))}"attributes"===e.type&&"src"===e.attributeName?n(e.target):"childList"===e.type&&Array.prototype.forEach.call(e.target.querySelectorAll("img"),n)}function n(e){u.splice(u.indexOf(e),1)}function t(e){oe("Remove listeners from "+e.src),e.removeEventListener("load",o,!1),e.removeEventListener("error",r,!1),n(e)}function i(e,n,i){t(e.target),Me(n,i+": "+e.target.src)}function o(e){i(e,"imageLoad","Image loaded")}function r(e){i(e,"imageLoadFailed","Image load failed")}function a(n){Me("mutationObserver","mutationObserver: "+n[0].target+" "+n[0].type),n.forEach(e)}function s(){var e=document.querySelector("body"),n={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0};return d=new c(a),oe("Create body MutationObserver"),d.observe(e,n),d}var u=[],c=window.MutationObserver||window.WebKitMutationObserver,d=s();return{disconnect:function(){"disconnect"in d&&(oe("Disconnect body MutationObserver"),d.disconnect(),u.forEach(t))}}}():(oe("MutationObserver not supported in this browser!"),he())):oe("Auto Resize disabled")}function he(){0!==b&&(oe("setInterval: "+b+"ms"),v=setInterval((function(){Me("interval","setInterval: "+b)}),Math.abs(b)))}function pe(e,n){var t=0;return n=n||document.body,t=null!==(t=document.defaultView.getComputedStyle(n,null))?t[e]:0,parseInt(t,10)}function we(e,n){for(var t=n.length,i=0,o=0,r=te(e),a=Date.now(),s=0;s<t;s++)(i=n[s].getBoundingClientRect()[e]+pe("margin"+r,n[s]))>o&&(o=i);return a=Date.now()-a,oe("Parsed "+t+" HTML elements"),oe("Element position calculated in "+a+"ms"),function(e){e>F/2&&oe("Event throttle increased to "+(F=2*e)+"ms")}(a),o}function be(e){return[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll()]}function ve(e,n){var t=document.querySelectorAll("["+n+"]");return 0===t.length&&(re("No tagged elements ("+n+") found on page"),document.querySelectorAll("body *")),we(e,t)}function ye(){return document.querySelectorAll("body *")}function Te(e,t,i,o){var r,a;!function(){function e(e,n){return!(Math.abs(e-n)<=N)}return r=n!==i?i:G[g](),a=n!==o?o:Z[P](),e(l,r)||u&&e(C,a)}()&&"init"!==e?!(e in{init:1,interval:1,size:1})&&(g in I||u&&P in I)?Ie(t):e in{interval:1}||oe("No change in size detected"):(Oe(),ze(l=r,C=a,e))}function Me(e,n,t,i){k&&e in c?oe("Trigger event cancelled: "+e):(e in{reset:1,resetPage:1,init:1}||oe("Trigger event: "+n),"init"===e?Te(e,n,t,i):$(e,n,t,i))}function Oe(){k||(k=!0,oe("Trigger event lock on")),clearTimeout(R),R=setTimeout((function(){k=!1,oe("Trigger event lock off"),oe("--")}),d)}function Ee(e){l=G[g](),C=Z[P](),ze(l,C,e)}function Ie(e){var n=g;g=m,oe("Reset trigger event: "+e),Oe(),Ee("reset"),g=n}function ze(e,t,i,o,r){var a;n===r?r=S:oe("Message targetOrigin: "+r),oe("Sending message to host page ("+(a=E+":"+e+":"+t+":"+i+(n!==o?":"+o:""))+")"),x.postMessage(M+a,r)}function xe(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}}()}));var u={};u=o("cx66d");var c=window,d=document,f=function(e){return d.querySelectorAll(e)},l=function(e){return d.readyState[7]?e():setTimeout(l,9,e)},m={};function g(e){var n=[];return void 0!==e&&e||(e="iframe.resizable"),"string"==typeof e?n=f(e):e.dispatchEvent?n.push(e):n=e,n}d.head.insertAdjacentHTML("beforeend","<style>iframe.resizable:not(.resizable-processed){display:none}</style>");var h=[];function p(e){var n=e.iframe,t=e.message,i=t.event,o=t.data;h.forEach((function(e){e.event==i&&e.callback({iframe:n,data:o})}))}window.meAsParent=window.meAsParent||{},meAsParent.on=function(e,n){var t=h.push({event:e,callback:n});return function(){delete h[t-1]}},meAsParent.trigger=function(e,n,t){g(t).forEach((function(t){p({iframe:t,message:{event:e,data:n}})}))},meAsParent.send=function(e,n,t){g(t).forEach((function(t){var i;null==t||null===(i=t.iFrameResizer)||void 0===i||i.sendMessage({event:e,data:n})}))};var w=[];function b(e){var n=e.event,t=e.data;w.forEach((function(e){e.event==n&&e.callback(t)}))}function v(e){var n="#"+e.id;meAsParent.trigger("beforeResize",e,n),resizer.onMessage=p,resizer.onInit=function(t){meAsParent.trigger("initialized",e,n)},u.iframeResize(resizer,n)}window.meAsChild=window.meAsChild||{},meAsChild.on=function(e,n){var t=w.push({event:e,callback:n});return function(){delete w[t-1]}},meAsChild.trigger=function(e,n){b({event:e,data:n})},meAsChild.send=function(e,n){var t=setInterval((function(){"undefined"!=typeof parentIFrame&&(clearInterval(t),parentIFrame.sendMessage({event:e,data:n}))}),10)};l((function(){new MutationObserver((function(e){e.forEach((function(e){e.addedNodes.forEach((function(e){if("iframe"==e.nodeName.toLowerCase()&&e.classList.contains("resizable")){var n=Object.assign(m,a({},e.dataset));n.id=e.id||"resizable-"+parseInt(1e16*Math.random()),e.id=n.id,v(n)}}))}))})).observe(d.body,{attributes:!1,childList:!0,subtree:!0}),f("iframe.resizable").forEach((function(e){var n=Object.assign(m,a({},e.dataset));n.id=e.id||"resizable-"+parseInt(1e16*Math.random()),e.id=n.id,v(n)})),c.top!==c.self&&(c.iFrameResizer={onMessage:b,onReady:function(){meAsChild.trigger("ready")}},Promise.resolve(o("Nnjfj")))}))}();
//# sourceMappingURL=reframer-only.min.js.map