iframe-resizer
Advanced tools
Comparing version 4.2.0 to 4.2.1
# Version History | ||
- v4.2.1 [#723](https://github.com/davidjbradshaw/iframe-resizer/pull/723) Fix option to turn off `autoResize` from iframe, when `resizeFrom` is set to `parent` [[Dennis Kronbügel]](deBFM) | ||
- v4.2.0 Add `onClose()` event to parent. | ||
@@ -4,0 +5,0 @@ - v4.1.1 [#686](https://github.com/davidjbradshaw/iframe-resizer/pull/694) Fix IE11 regression with Object.values [[Jonathan Lehman]](jdlehman) |
@@ -656,3 +656,3 @@ /* | ||
} | ||
sendMsg(0, 0, 'autoResize', JSON.stringify(autoResize)) | ||
return autoResize | ||
@@ -659,0 +659,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
/*! iFrame Resizer (iframeSizer.contentWindow.min.js) - v4.2.0 - 2019-09-19 | ||
/*! iFrame Resizer (iframeSizer.contentWindow.min.js) - v4.2.1 - 2019-09-24 | ||
* Desc: Include this file in any page being loaded into an iframe | ||
@@ -9,3 +9,3 @@ * to force the iframe to resize to the content size. | ||
!function(d){if("undefined"!=typeof window){var n=!0,o=10,i="",r=0,a="",t=null,u="",c=!1,s={resize:1,click:1},l=128,f=!0,m=1,h="bodyOffset",g=h,p=!0,v="",y={},b=32,w=null,T=!1,E="[iFrameSizer]",O=E.length,S="",M={max:1,min:1,bodyScroll:1,documentElementScroll:1},I="child",N=!0,A=window.parent,C="*",k=0,z=!1,e=null,x=16,R=1,L="scroll",F=L,P=window,D=function(){_("onMessage function not defined")},j=function(){},q=function(){},H={height:function(){return _("Custom height calculation function not defined"),document.documentElement.offsetHeight},width:function(){return _("Custom width calculation function not defined"),document.body.scrollWidth}},W={},B=!1;try{var U=Object.create({},{passive:{get:function(){B=!0}}});window.addEventListener("test",X,U),window.removeEventListener("test",X,U)}catch(e){}var J=Date.now||function(){return(new Date).getTime()},V={bodyOffset:function(){return document.body.offsetHeight+de("marginTop")+de("marginBottom")},offset:function(){return V.bodyOffset()},bodyScroll:function(){return document.body.scrollHeight},custom:function(){return H.height()},documentElementOffset:function(){return document.documentElement.offsetHeight},documentElementScroll:function(){return document.documentElement.scrollHeight},max:function(){return Math.max.apply(null,fe(V))},min:function(){return Math.min.apply(null,fe(V))},grow:function(){return V.max()},lowestElement:function(){return Math.max(V.bodyOffset()||V.documentElementOffset(),le("bottom",he()))},taggedElement:function(){return me("bottom","data-iframe-height")}},K={bodyScroll:function(){return document.body.scrollWidth},bodyOffset:function(){return document.body.offsetWidth},custom:function(){return H.width()},documentElementScroll:function(){return document.documentElement.scrollWidth},documentElementOffset:function(){return document.documentElement.offsetWidth},scroll:function(){return Math.max(K.bodyScroll(),K.documentElementScroll())},max:function(){return Math.max.apply(null,fe(K))},min:function(){return Math.min.apply(null,fe(K))},rightMostElement:function(){return le("right",he())},taggedElement:function(){return me("right","data-iframe-width")}},Q=function(n){function o(){c=J(),u=null,a=n.apply(i,r),u||(i=r=null)}var i,r,a,u=null,c=0;return function(){var e=J();c||(c=e);var t=x-(e-c);return i=this,r=arguments,t<=0||x<t?(u&&(clearTimeout(u),u=null),c=e,a=n.apply(i,r),u||(i=r=null)):u||(u=setTimeout(o,t)),a}}(ge);Y(window,"message",function(t){var n={init:function(){v=t.data,A=t.source,ee(),f=!1,setTimeout(function(){p=!1},l)},reset:function(){p?$("Page reset ignored by init"):($("Page size reset by host page"),ye("resetPage"))},resize:function(){pe("resizeParent","Parent window requested size check")},moveToAnchor:function(){y.findTarget(i())},inPageLink:function(){this.moveToAnchor()},pageInfo:function(){var e=i();$("PageInfoFromParent called from parent: "+e),q(JSON.parse(e)),$(" --")},message:function(){var e=i();$("onMessage called from parent: "+e),D(JSON.parse(e)),$(" --")}};function o(){return t.data.split("]")[1].split(":")[0]}function i(){return t.data.substr(t.data.indexOf(":")+1)}function r(){return t.data.split(":")[2]in{true:1,false:1}}function e(){var e=o();e in n?n[e]():("undefined"==typeof module||!module.exports)&&"iFrameResize"in window||"jQuery"in window&&"iFrameResize"in window.jQuery.prototype||r()||_("Unexpected message ("+t.data+")")}E===(""+t.data).substr(0,O)&&(!1===f?e():r()?n.init():$('Ignored message of type "'+o()+'". Received before initialization.'))}),Y(window,"readystatechange",Te),Te()}function X(){}function Y(e,t,n,o){e.addEventListener(t,n,!!B&&(o||{}))}function G(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Z(e){return E+"["+S+"] "+e}function $(e){T&&"object"==typeof window.console&&console.log(Z(e))}function _(e){"object"==typeof window.console&&console.warn(Z(e))}function ee(){!function(){function e(e){return"true"===e}var t=v.substr(O).split(":");S=t[0],r=d!==t[1]?Number(t[1]):r,c=d!==t[2]?e(t[2]):c,T=d!==t[3]?e(t[3]):T,b=d!==t[4]?Number(t[4]):b,n=d!==t[6]?e(t[6]):n,a=t[7],g=d!==t[8]?t[8]:g,i=t[9],u=t[10],k=d!==t[11]?Number(t[11]):k,y.enable=d!==t[12]&&e(t[12]),I=d!==t[13]?t[13]:I,F=d!==t[14]?t[14]:F}(),$("Initialising iFrame ("+location.href+")"),function(){function e(e,t){return"function"==typeof e&&($("Setup custom "+t+"CalcMethod"),H[t]=e,e="custom"),e}"iFrameResizer"in window&&Object===window.iFrameResizer.constructor&&(function(){var e=window.iFrameResizer;$("Reading data from page: "+JSON.stringify(e)),Object.keys(e).forEach(te,e),D="onMessage"in e?e.onMessage:D,j="onReady"in e?e.onReady:j,C="targetOrigin"in e?e.targetOrigin:C,g="heightCalculationMethod"in e?e.heightCalculationMethod:g,F="widthCalculationMethod"in e?e.widthCalculationMethod:F}(),g=e(g,"height"),F=e(F,"width"));$("TargetOrigin for parent set to: "+C)}(),function(){d===a&&(a=r+"px");ne("margin",function(e,t){-1!==t.indexOf("-")&&(_("Negative CSS value ignored for "+e),t="");return t}("margin",a))}(),ne("background",i),ne("padding",u),function(){var e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.appendChild(e)}(),ae(),ue(),document.documentElement.style.height="",document.body.style.height="",$('HTML & body height set to "auto"'),$("Enable public methods"),P.parentIFrame={autoResize:function(e){return!0===e&&!1===n?(n=!0,ce()):!1===e&&!0===n&&(n=!1,ie("remove"),null!==t&&t.disconnect(),clearInterval(w)),n},close:function(){we(0,0,"close")},getId:function(){return S},getPageInfo:function(e){"function"==typeof e?(q=e,we(0,0,"pageInfo")):(q=function(){},we(0,0,"pageInfoStop"))},moveToAnchor:function(e){y.findTarget(e)},reset:function(){be("parentIFrame.reset")},scrollTo:function(e,t){we(t,e,"scrollTo")},scrollToOffset:function(e,t){we(t,e,"scrollToOffset")},sendMessage:function(e,t){we(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod:function(e){g=e,ae()},setWidthCalculationMethod:function(e){F=e,ue()},setTargetOrigin:function(e){$("Set targetOrigin: "+e),C=e},size:function(e,t){var n=(e||"")+(t?","+t:"");pe("size","parentIFrame.size("+n+")",e,t)}},ce(),y=function(){function i(e){var t=e.getBoundingClientRect(),n={x:window.pageXOffset!==d?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==d?window.pageYOffset:document.documentElement.scrollTop};return{x:parseInt(t.left,10)+parseInt(n.x,10),y:parseInt(t.top,10)+parseInt(n.y,10)}}function n(e){var n=e.split("#")[1]||e,t=decodeURIComponent(n),o=document.getElementById(t)||document.getElementsByName(t)[0];d!==o?function(e){var t=i(e);$("Moving to in page link (#"+n+") at x: "+t.x+" y: "+t.y),we(t.y,t.x,"scrollToOffset")}(o):($("In page link (#"+n+") not found in iFrame, so sending to parent"),we(0,0,"inPageLink","#"+n))}function e(){""!==location.hash&&"#"!==location.hash&&n(location.href)}function t(){Array.prototype.forEach.call(document.querySelectorAll('a[href^="#"]'),function(e){function t(e){e.preventDefault(),n(this.getAttribute("href"))}"#"!==e.getAttribute("href")&&Y(e,"click",t)})}y.enable?Array.prototype.forEach&&document.querySelectorAll?($("Setting up location.hash handlers"),t(),Y(window,"hashchange",e),setTimeout(e,l)):_("In page linking not fully supported in this browser! (See README.md for IE8 workaround)"):$("In page linking not enabled");return{findTarget:n}}(),pe("init","Init message from host page"),j()}function te(e){var t=e.split("Callback");if(2===t.length){var n="on"+t[0].charAt(0).toUpperCase()+t[0].slice(1);this[n]=this[e],delete this[e],_("Deprecated: '"+e+"' has been renamed '"+n+"'. The old method will be removed in the next major version.")}}function ne(e,t){d!==t&&""!==t&&"null"!==t&&$("Body "+e+' set to "'+(document.body.style[e]=t)+'"')}function oe(n){var e={add:function(e){function t(){pe(n.eventName,n.eventType)}W[e]=t,Y(window,e,t,{passive:!0})},remove:function(e){var t=W[e];delete W[e],function(e,t,n){e.removeEventListener(t,n,!1)}(window,e,t)}};n.eventNames&&Array.prototype.map?(n.eventName=n.eventNames[0],n.eventNames.map(e[n.method])):e[n.method](n.eventName),$(G(n.method)+" event listener: "+n.eventType)}function ie(e){oe({method:e,eventType:"Animation Start",eventNames:["animationstart","webkitAnimationStart"]}),oe({method:e,eventType:"Animation Iteration",eventNames:["animationiteration","webkitAnimationIteration"]}),oe({method:e,eventType:"Animation End",eventNames:["animationend","webkitAnimationEnd"]}),oe({method:e,eventType:"Input",eventName:"input"}),oe({method:e,eventType:"Mouse Up",eventName:"mouseup"}),oe({method:e,eventType:"Mouse Down",eventName:"mousedown"}),oe({method:e,eventType:"Orientation Change",eventName:"orientationchange"}),oe({method:e,eventType:"Print",eventName:["afterprint","beforeprint"]}),oe({method:e,eventType:"Ready State Change",eventName:"readystatechange"}),oe({method:e,eventType:"Touch Start",eventName:"touchstart"}),oe({method:e,eventType:"Touch End",eventName:"touchend"}),oe({method:e,eventType:"Touch Cancel",eventName:"touchcancel"}),oe({method:e,eventType:"Transition Start",eventNames:["transitionstart","webkitTransitionStart","MSTransitionStart","oTransitionStart","otransitionstart"]}),oe({method:e,eventType:"Transition Iteration",eventNames:["transitioniteration","webkitTransitionIteration","MSTransitionIteration","oTransitionIteration","otransitioniteration"]}),oe({method:e,eventType:"Transition End",eventNames:["transitionend","webkitTransitionEnd","MSTransitionEnd","oTransitionEnd","otransitionend"]}),"child"===I&&oe({method:e,eventType:"IFrame Resized",eventName:"resize"})}function re(e,t,n,o){return t!==e&&(e in n||(_(e+" is not a valid option for "+o+"CalculationMethod."),e=t),$(o+' calculation method set to "'+e+'"')),e}function ae(){g=re(g,h,V,"height")}function ue(){F=re(F,L,K,"width")}function ce(){!0===n?(ie("add"),function(){var e=b<0;window.MutationObserver||window.WebKitMutationObserver?e?se():t=function(){function t(e){function t(e){!1===e.complete&&($("Attach listeners to "+e.src),e.addEventListener("load",i,!1),e.addEventListener("error",r,!1),u.push(e))}"attributes"===e.type&&"src"===e.attributeName?t(e.target):"childList"===e.type&&Array.prototype.forEach.call(e.target.querySelectorAll("img"),t)}function o(e){$("Remove listeners from "+e.src),e.removeEventListener("load",i,!1),e.removeEventListener("error",r,!1),function(e){u.splice(u.indexOf(e),1)}(e)}function n(e,t,n){o(e.target),pe(t,n+": "+e.target.src,d,d)}function i(e){n(e,"imageLoad","Image loaded")}function r(e){n(e,"imageLoadFailed","Image load failed")}function a(e){pe("mutationObserver","mutationObserver: "+e[0].target+" "+e[0].type),e.forEach(t)}var u=[],c=window.MutationObserver||window.WebKitMutationObserver,s=function(){var e=document.querySelector("body"),t={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0};return s=new c(a),$("Create body MutationObserver"),s.observe(e,t),s}();return{disconnect:function(){"disconnect"in s&&($("Disconnect body MutationObserver"),s.disconnect(),u.forEach(o))}}}():($("MutationObserver not supported in this browser!"),se())}()):$("Auto Resize disabled")}function se(){0!==b&&($("setInterval: "+b+"ms"),w=setInterval(function(){pe("interval","setInterval: "+b)},Math.abs(b)))}function de(e,t){var n=0;return t=t||document.body,n=null!==(n=document.defaultView.getComputedStyle(t,null))?n[e]:0,parseInt(n,o)}function le(e,t){for(var n=t.length,o=0,i=0,r=G(e),a=J(),u=0;u<n;u++)i<(o=t[u].getBoundingClientRect()[e]+de("margin"+r,t[u]))&&(i=o);return a=J()-a,$("Parsed "+n+" HTML elements"),$("Element position calculated in "+a+"ms"),function(e){x/2<e&&$("Event throttle increased to "+(x=2*e)+"ms")}(a),i}function fe(e){return[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll()]}function me(e,t){var n=document.querySelectorAll("["+t+"]");return 0===n.length&&(_("No tagged elements ("+t+") found on page"),document.querySelectorAll("body *")),le(e,n)}function he(){return document.querySelectorAll("body *")}function ge(e,t,n,o){var i,r;!function(){function e(e,t){return!(Math.abs(e-t)<=k)}return i=d!==n?n:V[g](),r=d!==o?o:K[F](),e(m,i)||c&&e(R,r)}()&&"init"!==e?e in{init:1,interval:1,size:1}||!(g in M||c&&F in M)?e in{interval:1}||$("No change in size detected"):be(t):(ve(),we(m=i,R=r,e))}function pe(e,t,n,o){z&&e in s?$("Trigger event cancelled: "+e):(e in{reset:1,resetPage:1,init:1}||$("Trigger event: "+t),"init"===e?ge(e,t,n,o):Q(e,t,n,o))}function ve(){z||(z=!0,$("Trigger event lock on")),clearTimeout(e),e=setTimeout(function(){z=!1,$("Trigger event lock off"),$("--")},l)}function ye(e){m=V[g](),R=K[F](),we(m,R,e)}function be(e){var t=g;g=h,$("Reset trigger event: "+e),ve(),ye("reset"),g=t}function we(e,t,n,o,i){var r;!0===N&&(d===i?i=C:$("Message targetOrigin: "+i),$("Sending message to host page ("+(r=S+":"+e+":"+t+":"+n+(d!==o?":"+o:""))+")"),A.postMessage(E+r,i))}function Te(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}}(); | ||
!function(d){if("undefined"!=typeof window){var n=!0,o=10,i="",r=0,a="",t=null,u="",c=!1,s={resize:1,click:1},l=128,f=!0,m=1,h="bodyOffset",g=h,p=!0,v="",y={},b=32,w=null,T=!1,E="[iFrameSizer]",O=E.length,S="",M={max:1,min:1,bodyScroll:1,documentElementScroll:1},I="child",N=!0,A=window.parent,C="*",z=0,k=!1,e=null,R=16,x=1,L="scroll",F=L,P=window,D=function(){_("onMessage function not defined")},j=function(){},q=function(){},H={height:function(){return _("Custom height calculation function not defined"),document.documentElement.offsetHeight},width:function(){return _("Custom width calculation function not defined"),document.body.scrollWidth}},W={},B=!1;try{var J=Object.create({},{passive:{get:function(){B=!0}}});window.addEventListener("test",X,J),window.removeEventListener("test",X,J)}catch(e){}var U=Date.now||function(){return(new Date).getTime()},V={bodyOffset:function(){return document.body.offsetHeight+de("marginTop")+de("marginBottom")},offset:function(){return V.bodyOffset()},bodyScroll:function(){return document.body.scrollHeight},custom:function(){return H.height()},documentElementOffset:function(){return document.documentElement.offsetHeight},documentElementScroll:function(){return document.documentElement.scrollHeight},max:function(){return Math.max.apply(null,fe(V))},min:function(){return Math.min.apply(null,fe(V))},grow:function(){return V.max()},lowestElement:function(){return Math.max(V.bodyOffset()||V.documentElementOffset(),le("bottom",he()))},taggedElement:function(){return me("bottom","data-iframe-height")}},K={bodyScroll:function(){return document.body.scrollWidth},bodyOffset:function(){return document.body.offsetWidth},custom:function(){return H.width()},documentElementScroll:function(){return document.documentElement.scrollWidth},documentElementOffset:function(){return document.documentElement.offsetWidth},scroll:function(){return Math.max(K.bodyScroll(),K.documentElementScroll())},max:function(){return Math.max.apply(null,fe(K))},min:function(){return Math.min.apply(null,fe(K))},rightMostElement:function(){return le("right",he())},taggedElement:function(){return me("right","data-iframe-width")}},Q=function(n){function o(){c=U(),u=null,a=n.apply(i,r),u||(i=r=null)}var i,r,a,u=null,c=0;return function(){var e=U();c||(c=e);var t=R-(e-c);return i=this,r=arguments,t<=0||R<t?(u&&(clearTimeout(u),u=null),c=e,a=n.apply(i,r),u||(i=r=null)):u||(u=setTimeout(o,t)),a}}(ge);Y(window,"message",function(t){var n={init:function(){v=t.data,A=t.source,ee(),f=!1,setTimeout(function(){p=!1},l)},reset:function(){p?$("Page reset ignored by init"):($("Page size reset by host page"),ye("resetPage"))},resize:function(){pe("resizeParent","Parent window requested size check")},moveToAnchor:function(){y.findTarget(i())},inPageLink:function(){this.moveToAnchor()},pageInfo:function(){var e=i();$("PageInfoFromParent called from parent: "+e),q(JSON.parse(e)),$(" --")},message:function(){var e=i();$("onMessage called from parent: "+e),D(JSON.parse(e)),$(" --")}};function o(){return t.data.split("]")[1].split(":")[0]}function i(){return t.data.substr(t.data.indexOf(":")+1)}function r(){return t.data.split(":")[2]in{true:1,false:1}}function e(){var e=o();e in n?n[e]():("undefined"==typeof module||!module.exports)&&"iFrameResize"in window||"jQuery"in window&&"iFrameResize"in window.jQuery.prototype||r()||_("Unexpected message ("+t.data+")")}E===(""+t.data).substr(0,O)&&(!1===f?e():r()?n.init():$('Ignored message of type "'+o()+'". Received before initialization.'))}),Y(window,"readystatechange",Te),Te()}function X(){}function Y(e,t,n,o){e.addEventListener(t,n,!!B&&(o||{}))}function G(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Z(e){return E+"["+S+"] "+e}function $(e){T&&"object"==typeof window.console&&console.log(Z(e))}function _(e){"object"==typeof window.console&&console.warn(Z(e))}function ee(){!function(){function e(e){return"true"===e}var t=v.substr(O).split(":");S=t[0],r=d!==t[1]?Number(t[1]):r,c=d!==t[2]?e(t[2]):c,T=d!==t[3]?e(t[3]):T,b=d!==t[4]?Number(t[4]):b,n=d!==t[6]?e(t[6]):n,a=t[7],g=d!==t[8]?t[8]:g,i=t[9],u=t[10],z=d!==t[11]?Number(t[11]):z,y.enable=d!==t[12]&&e(t[12]),I=d!==t[13]?t[13]:I,F=d!==t[14]?t[14]:F}(),$("Initialising iFrame ("+location.href+")"),function(){function e(e,t){return"function"==typeof e&&($("Setup custom "+t+"CalcMethod"),H[t]=e,e="custom"),e}"iFrameResizer"in window&&Object===window.iFrameResizer.constructor&&(function(){var e=window.iFrameResizer;$("Reading data from page: "+JSON.stringify(e)),Object.keys(e).forEach(te,e),D="onMessage"in e?e.onMessage:D,j="onReady"in e?e.onReady:j,C="targetOrigin"in e?e.targetOrigin:C,g="heightCalculationMethod"in e?e.heightCalculationMethod:g,F="widthCalculationMethod"in e?e.widthCalculationMethod:F}(),g=e(g,"height"),F=e(F,"width"));$("TargetOrigin for parent set to: "+C)}(),function(){d===a&&(a=r+"px");ne("margin",function(e,t){-1!==t.indexOf("-")&&(_("Negative CSS value ignored for "+e),t="");return t}("margin",a))}(),ne("background",i),ne("padding",u),function(){var e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.appendChild(e)}(),ae(),ue(),document.documentElement.style.height="",document.body.style.height="",$('HTML & body height set to "auto"'),$("Enable public methods"),P.parentIFrame={autoResize:function(e){return!0===e&&!1===n?(n=!0,ce()):!1===e&&!0===n&&(n=!1,ie("remove"),null!==t&&t.disconnect(),clearInterval(w)),we(0,0,"autoResize",JSON.stringify(n)),n},close:function(){we(0,0,"close")},getId:function(){return S},getPageInfo:function(e){"function"==typeof e?(q=e,we(0,0,"pageInfo")):(q=function(){},we(0,0,"pageInfoStop"))},moveToAnchor:function(e){y.findTarget(e)},reset:function(){be("parentIFrame.reset")},scrollTo:function(e,t){we(t,e,"scrollTo")},scrollToOffset:function(e,t){we(t,e,"scrollToOffset")},sendMessage:function(e,t){we(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod:function(e){g=e,ae()},setWidthCalculationMethod:function(e){F=e,ue()},setTargetOrigin:function(e){$("Set targetOrigin: "+e),C=e},size:function(e,t){var n=(e||"")+(t?","+t:"");pe("size","parentIFrame.size("+n+")",e,t)}},ce(),y=function(){function i(e){var t=e.getBoundingClientRect(),n={x:window.pageXOffset!==d?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==d?window.pageYOffset:document.documentElement.scrollTop};return{x:parseInt(t.left,10)+parseInt(n.x,10),y:parseInt(t.top,10)+parseInt(n.y,10)}}function n(e){var n=e.split("#")[1]||e,t=decodeURIComponent(n),o=document.getElementById(t)||document.getElementsByName(t)[0];d!==o?function(e){var t=i(e);$("Moving to in page link (#"+n+") at x: "+t.x+" y: "+t.y),we(t.y,t.x,"scrollToOffset")}(o):($("In page link (#"+n+") not found in iFrame, so sending to parent"),we(0,0,"inPageLink","#"+n))}function e(){""!==location.hash&&"#"!==location.hash&&n(location.href)}function t(){Array.prototype.forEach.call(document.querySelectorAll('a[href^="#"]'),function(e){function t(e){e.preventDefault(),n(this.getAttribute("href"))}"#"!==e.getAttribute("href")&&Y(e,"click",t)})}y.enable?Array.prototype.forEach&&document.querySelectorAll?($("Setting up location.hash handlers"),t(),Y(window,"hashchange",e),setTimeout(e,l)):_("In page linking not fully supported in this browser! (See README.md for IE8 workaround)"):$("In page linking not enabled");return{findTarget:n}}(),pe("init","Init message from host page"),j()}function te(e){var t=e.split("Callback");if(2===t.length){var n="on"+t[0].charAt(0).toUpperCase()+t[0].slice(1);this[n]=this[e],delete this[e],_("Deprecated: '"+e+"' has been renamed '"+n+"'. The old method will be removed in the next major version.")}}function ne(e,t){d!==t&&""!==t&&"null"!==t&&$("Body "+e+' set to "'+(document.body.style[e]=t)+'"')}function oe(n){var e={add:function(e){function t(){pe(n.eventName,n.eventType)}W[e]=t,Y(window,e,t,{passive:!0})},remove:function(e){var t=W[e];delete W[e],function(e,t,n){e.removeEventListener(t,n,!1)}(window,e,t)}};n.eventNames&&Array.prototype.map?(n.eventName=n.eventNames[0],n.eventNames.map(e[n.method])):e[n.method](n.eventName),$(G(n.method)+" event listener: "+n.eventType)}function ie(e){oe({method:e,eventType:"Animation Start",eventNames:["animationstart","webkitAnimationStart"]}),oe({method:e,eventType:"Animation Iteration",eventNames:["animationiteration","webkitAnimationIteration"]}),oe({method:e,eventType:"Animation End",eventNames:["animationend","webkitAnimationEnd"]}),oe({method:e,eventType:"Input",eventName:"input"}),oe({method:e,eventType:"Mouse Up",eventName:"mouseup"}),oe({method:e,eventType:"Mouse Down",eventName:"mousedown"}),oe({method:e,eventType:"Orientation Change",eventName:"orientationchange"}),oe({method:e,eventType:"Print",eventName:["afterprint","beforeprint"]}),oe({method:e,eventType:"Ready State Change",eventName:"readystatechange"}),oe({method:e,eventType:"Touch Start",eventName:"touchstart"}),oe({method:e,eventType:"Touch End",eventName:"touchend"}),oe({method:e,eventType:"Touch Cancel",eventName:"touchcancel"}),oe({method:e,eventType:"Transition Start",eventNames:["transitionstart","webkitTransitionStart","MSTransitionStart","oTransitionStart","otransitionstart"]}),oe({method:e,eventType:"Transition Iteration",eventNames:["transitioniteration","webkitTransitionIteration","MSTransitionIteration","oTransitionIteration","otransitioniteration"]}),oe({method:e,eventType:"Transition End",eventNames:["transitionend","webkitTransitionEnd","MSTransitionEnd","oTransitionEnd","otransitionend"]}),"child"===I&&oe({method:e,eventType:"IFrame Resized",eventName:"resize"})}function re(e,t,n,o){return t!==e&&(e in n||(_(e+" is not a valid option for "+o+"CalculationMethod."),e=t),$(o+' calculation method set to "'+e+'"')),e}function ae(){g=re(g,h,V,"height")}function ue(){F=re(F,L,K,"width")}function ce(){!0===n?(ie("add"),function(){var e=b<0;window.MutationObserver||window.WebKitMutationObserver?e?se():t=function(){function t(e){function t(e){!1===e.complete&&($("Attach listeners to "+e.src),e.addEventListener("load",i,!1),e.addEventListener("error",r,!1),u.push(e))}"attributes"===e.type&&"src"===e.attributeName?t(e.target):"childList"===e.type&&Array.prototype.forEach.call(e.target.querySelectorAll("img"),t)}function o(e){$("Remove listeners from "+e.src),e.removeEventListener("load",i,!1),e.removeEventListener("error",r,!1),function(e){u.splice(u.indexOf(e),1)}(e)}function n(e,t,n){o(e.target),pe(t,n+": "+e.target.src,d,d)}function i(e){n(e,"imageLoad","Image loaded")}function r(e){n(e,"imageLoadFailed","Image load failed")}function a(e){pe("mutationObserver","mutationObserver: "+e[0].target+" "+e[0].type),e.forEach(t)}var u=[],c=window.MutationObserver||window.WebKitMutationObserver,s=function(){var e=document.querySelector("body"),t={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0};return s=new c(a),$("Create body MutationObserver"),s.observe(e,t),s}();return{disconnect:function(){"disconnect"in s&&($("Disconnect body MutationObserver"),s.disconnect(),u.forEach(o))}}}():($("MutationObserver not supported in this browser!"),se())}()):$("Auto Resize disabled")}function se(){0!==b&&($("setInterval: "+b+"ms"),w=setInterval(function(){pe("interval","setInterval: "+b)},Math.abs(b)))}function de(e,t){var n=0;return t=t||document.body,n=null!==(n=document.defaultView.getComputedStyle(t,null))?n[e]:0,parseInt(n,o)}function le(e,t){for(var n=t.length,o=0,i=0,r=G(e),a=U(),u=0;u<n;u++)i<(o=t[u].getBoundingClientRect()[e]+de("margin"+r,t[u]))&&(i=o);return a=U()-a,$("Parsed "+n+" HTML elements"),$("Element position calculated in "+a+"ms"),function(e){R/2<e&&$("Event throttle increased to "+(R=2*e)+"ms")}(a),i}function fe(e){return[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll()]}function me(e,t){var n=document.querySelectorAll("["+t+"]");return 0===n.length&&(_("No tagged elements ("+t+") found on page"),document.querySelectorAll("body *")),le(e,n)}function he(){return document.querySelectorAll("body *")}function ge(e,t,n,o){var i,r;!function(){function e(e,t){return!(Math.abs(e-t)<=z)}return i=d!==n?n:V[g](),r=d!==o?o:K[F](),e(m,i)||c&&e(x,r)}()&&"init"!==e?e in{init:1,interval:1,size:1}||!(g in M||c&&F in M)?e in{interval:1}||$("No change in size detected"):be(t):(ve(),we(m=i,x=r,e))}function pe(e,t,n,o){k&&e in s?$("Trigger event cancelled: "+e):(e in{reset:1,resetPage:1,init:1}||$("Trigger event: "+t),"init"===e?ge(e,t,n,o):Q(e,t,n,o))}function ve(){k||(k=!0,$("Trigger event lock on")),clearTimeout(e),e=setTimeout(function(){k=!1,$("Trigger event lock off"),$("--")},l)}function ye(e){m=V[g](),x=K[F](),we(m,x,e)}function be(e){var t=g;g=h,$("Reset trigger event: "+e),ve(),ye("reset"),g=t}function we(e,t,n,o,i){var r;!0===N&&(d===i?i=C:$("Message targetOrigin: "+i),$("Sending message to host page ("+(r=S+":"+e+":"+t+":"+n+(d!==o?":"+o:""))+")"),A.postMessage(E+r,i))}function Te(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}}(); | ||
//# sourceMappingURL=iframeResizer.contentWindow.map |
@@ -493,2 +493,6 @@ /* | ||
case 'autoResize': | ||
settings[iframeId].autoResize = JSON.parse(getMsgBody(9)) | ||
break | ||
case 'scrollTo': | ||
@@ -495,0 +499,0 @@ scrollRequestFromChild(false) |
@@ -1,2 +0,2 @@ | ||
/*! iFrame Resizer (iframeSizer.min.js ) - v4.2.0 - 2019-09-19 | ||
/*! iFrame Resizer (iframeSizer.min.js ) - v4.2.1 - 2019-09-24 | ||
* Desc: Force cross domain iframes to size to content. | ||
@@ -8,3 +8,3 @@ * Requires: iframeResizer.contentWindow.min.js to be loaded into the target frame. | ||
!function(f){if("undefined"!=typeof window){var e,l=0,m=!1,o=!1,p="message".length,b="[iFrameSizer]",y=b.length,v=null,r=window.requestAnimationFrame,g={max:1,scroll:1,bodyScroll:1,documentElementScroll:1},F={},i=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,resizeFrom:"parent",scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,widthCalculationMethod:"scroll",onClose:function(){return!0},onClosed:function(){},onInit:function(){},onMessage:function(){O("onMessage function not defined")},onResized:function(){},onScroll:function(){return!0}},I={};window.jQuery&&((e=window.jQuery).fn?e.fn.iFrameResize||(e.fn.iFrameResize=function(i){return this.filter("iframe").each(function(e,n){d(n,i)}).end()}):z("","Unable to bind to jQuery, it is not fully loaded.")),"function"==typeof define&&define.amd?define([],B):"object"==typeof module&&"object"==typeof module.exports&&(module.exports=B()),window.iFrameResize=window.iFrameResize||B()}function w(){return window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver}function M(e,n,i){e.addEventListener(n,i,!1)}function x(e,n,i){e.removeEventListener(n,i,!1)}function a(e){return b+"["+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 F[e]?F[e].log:m}function k(e,n){s("log",e,n,t(e))}function z(e,n){s("info",e,n,t(e))}function O(e,n){s("warn",e,n,!0)}function s(e,n,i,t){!0===t&&"object"==typeof window.console&&console[e](a(n),i)}function n(n){function e(){i("Height"),i("Width"),j(function(){S(h),W(w),d("onResized",h)},h,"init")}function i(e){var n=Number(F[w]["max"+e]),i=Number(F[w]["min"+e]),t=e.toLowerCase(),o=Number(h[t]);k(w,"Checking "+t+" is in range "+i+"-"+n),o<i&&(o=i,k(w,"Set "+t+" to min value")),n<o&&(o=n,k(w,"Set "+t+" to max value")),h[t]=""+o}function t(e){return g.substr(g.indexOf(":")+p+e)}function a(e,n){!function(e,n,i){I[i]||(I[i]=setTimeout(function(){I[i]=null,e()},n))}(function(){P("Send Page Info","pageInfo:"+function(){var e=document.body.getBoundingClientRect(),n=h.iframe.getBoundingClientRect();return JSON.stringify({iframeHeight:n.height,iframeWidth:n.width,clientHeight:Math.max(document.documentElement.clientHeight,window.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,window.innerWidth||0),offsetTop:parseInt(n.top-e.top,10),offsetLeft:parseInt(n.left-e.left,10),scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,documentHeight:document.documentElement.clientHeight,documentWidth:document.documentElement.clientWidth,windowHeight:window.innerHeight,windowWidth:window.innerWidth})}(),e,n)},32,n)}function r(e){var n=e.getBoundingClientRect();return C(w),{x:Math.floor(Number(n.left)+Number(v.x)),y:Math.floor(Number(n.top)+Number(v.y))}}function o(e){var n=e?r(h.iframe):{x:0,y:0},i={x:Number(h.width)+n.x,y:Number(h.height)+n.y};k(w,"Reposition requested from iFrame (offset x:"+n.x+" y:"+n.y+")"),window.top!==window.self?window.parentIFrame?window.parentIFrame["scrollTo"+(e?"Offset":"")](i.x,i.y):O(w,"Unable to scroll to requested position, window.parentIFrame not found"):(v=i,s(),k(w,"--"))}function s(){!1!==d("onScroll",v)?W(w):N()}function d(e,n){return R(w,e,n)}var c,u,f,l,m,g=n.data,h={},w=null;"[iFrameResizerChild]Ready"===g?function(){for(var e in F)P("iFrame requested init",A(e),document.getElementById(e),e)}():b===(""+g).substr(0,y)&&g.substr(y).split(":")[0]in F?(m=g.substr(y).split(":"),h={iframe:F[m[0]]&&F[m[0]].iframe,id:m[0],height:m[1],width:m[2],type:m[3]},w=h.id,F[w]&&(F[w].loaded=!0),(l=h.type in{true:1,false:1,undefined:1})&&k(w,"Ignoring init message from meta parent page"),!l&&(f=!0,F[u=w]||(f=!1,O(h.type+" No settings for "+u+". Message was: "+g)),f)&&(k(w,"Received: "+g),c=!0,null===h.iframe&&(O(w,"IFrame ("+h.id+") not found"),c=!1),c&&function(){var e,i=n.origin,t=F[w]&&F[w].checkOrigin;if(t&&""+i!="null"&&!(t.constructor===Array?function(){var e=0,n=!1;for(k(w,"Checking connection is from allowed list of origins: "+t);e<t.length;e++)if(t[e]===i){n=!0;break}return n}():(e=F[w]&&F[w].remoteHost,k(w,"Checking connection is from: "+e),i===e)))throw new Error("Unexpected message received from: "+i+" for "+h.iframe.id+". Message was: "+n.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return!0}()&&function(){switch(F[w]&&F[w].firstRun&&F[w]&&(F[w].firstRun=!1),h.type){case"close":T(h.iframe);break;case"message":!function(e){k(w,"onMessage passed: {iframe: "+h.iframe.id+", message: "+e+"}"),d("onMessage",{iframe:h.iframe,message:JSON.parse(e)}),k(w,"--")}(t(6));break;case"scrollTo":o(!1);break;case"scrollToOffset":o(!0);break;case"pageInfo":a(F[w]&&F[w].iframe,w),function(){function e(n,i){function t(){F[r]?a(F[r].iframe,r):o()}["scroll","resize"].forEach(function(e){k(r,n+e+" listener for sendPageInfo"),i(window,e,t)})}function o(){e("Remove ",x)}var r=w;e("Add ",M),F[r]&&(F[r].stopPageInfo=o)}();break;case"pageInfoStop":F[w]&&F[w].stopPageInfo&&(F[w].stopPageInfo(),delete F[w].stopPageInfo);break;case"inPageLink":!function(e){var n,i=e.split("#")[1]||"",t=decodeURIComponent(i),o=document.getElementById(t)||document.getElementsByName(t)[0];o?(n=r(o),k(w,"Moving to in page link (#"+i+") at x: "+n.x+" y: "+n.y),v={x:n.x,y:n.y},s(),k(w,"--")):window.top!==window.self?window.parentIFrame?window.parentIFrame.moveToAnchor(i):k(w,"In page link #"+i+" not found and window.parentIFrame not found"):k(w,"In page link #"+i+" not found")}(t(9));break;case"reset":H(h);break;case"init":e(),d("onInit",h.iframe);break;default:e()}}())):z(w,"Ignored: "+g)}function R(e,n,i){var t=null,o=null;if(F[e]){if("function"!=typeof(t=F[e][n]))throw new TypeError(n+" on iFrame["+e+"] is not a function");o=t(i)}return o}function E(e){var n=e.id;delete F[n]}function T(e){var n=e.id;if(!1!==R(n,"onClose",n)){k(n,"Removing iFrame: "+n);try{e.parentNode&&e.parentNode.removeChild(e)}catch(e){O(e)}R(n,"onClosed",n),k(n,"--"),E(e)}else k(n,"Close iframe cancelled by onClose event")}function C(e){null===v&&k(e,"Get page position: "+(v={x:window.pageXOffset!==f?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==f?window.pageYOffset:document.documentElement.scrollTop}).x+","+v.y)}function W(e){null!==v&&(window.scrollTo(v.x,v.y),k(e,"Set page position: "+v.x+","+v.y),N())}function N(){v=null}function H(e){k(e.id,"Size reset requested by "+("init"===e.type?"host page":"iFrame")),C(e.id),j(function(){S(e),P("reset","reset",e.iframe,e.id)},e,"reset")}function S(n){function i(e){o||"0"!==n[e]||(o=!0,k(t,"Hidden iFrame detected, creating visibility listener"),function(){function n(){Object.keys(F).forEach(function(e){!function(n){function e(e){return"0px"===(F[n]&&F[n].iframe.style[e])}F[n]&&(i=F[n].iframe,null!==i.offsetParent)&&(e("height")||e("width"))&&P("Visibility change","resize",F[n].iframe,n);var i}(F[e])})}function i(e){k("window","Mutation observed: "+e[0].target+" "+e[0].type),c(n,16)}var t=w();t&&function(){var e=document.querySelector("body"),n={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0};new t(i).observe(e,n)}()}())}function e(e){!function(e){n.id?(n.iframe.style[e]=n[e]+"px",k(n.id,"IFrame ("+t+") "+e+" set to "+n[e]+"px")):k("undefined","messageData id not set")}(e),i(e)}var t=n.iframe.id;F[t]&&(F[t].sizeHeight&&e("height"),F[t].sizeWidth&&e("width"))}function j(e,n,i){i!==n.type&&r?(k(n.id,"Requesting animation frame"),r(e)):e()}function P(e,n,i,t,o){var r,a=!1;t=t||i.id,F[t]&&(i&&"contentWindow"in i&&null!==i.contentWindow?(r=F[t]&&F[t].targetOrigin,k(t,"["+e+"] Sending msg to iframe["+t+"] ("+n+") targetOrigin: "+r),i.contentWindow.postMessage(b+n,r)):O(t,"["+e+"] IFrame("+t+") not found"),o&&F[t]&&F[t].warningTimeout&&(F[t].msgTimeout=setTimeout(function(){!F[t]||F[t].loaded||a||(a=!0,O(t,"IFrame has not responded within "+F[t].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."))},F[t].warningTimeout)))}function A(e){return e+":"+F[e].bodyMarginV1+":"+F[e].sizeWidth+":"+F[e].log+":"+F[e].interval+":"+F[e].enablePublicMethods+":"+F[e].autoResize+":"+F[e].bodyMargin+":"+F[e].heightCalculationMethod+":"+F[e].bodyBackground+":"+F[e].bodyPadding+":"+F[e].tolerance+":"+F[e].inPageLinks+":"+F[e].resizeFrom+":"+F[e].widthCalculationMethod}function d(i,e){function n(e){var n=e.split("Callback");if(2===n.length){var i="on"+n[0].charAt(0).toUpperCase()+n[0].slice(1);this[i]=this[e],delete this[e],O(u,"Deprecated: '"+e+"' has been renamed '"+i+"'. The old method will be removed in the next major version.")}}var t,o,r,a,s,d,c,u=(""===(o=i.id)&&(i.id=(t=e&&e.id||h.id+l++,null!==document.getElementById(t)&&(t+=l++),o=t),m=(e||{}).log,k(o,"Added missing iframe ID: "+o+" ("+i.src+")")),o);u in F&&"iFrameResizer"in i?O(u,"Ignored iFrame, already setup."):(c=(c=e)||{},F[u]={firstRun:!0,iframe:i,remoteHost:i.src.split("/").slice(0,3).join("/")},function(e){if("object"!=typeof e)throw new TypeError("Options is not an object")}(c),Object.keys(c).forEach(n,c),function(e){for(var n in h)Object.prototype.hasOwnProperty.call(h,n)&&(F[u][n]=Object.prototype.hasOwnProperty.call(e,n)?e[n]:h[n])}(c),F[u]&&(F[u].targetOrigin=!0===F[u].checkOrigin?""===(d=F[u].remoteHost)||"file://"===d?"*":d:"*"),function(){switch(k(u,"IFrame scrolling "+(F[u]&&F[u].scrolling?"enabled":"disabled")+" for "+u),i.style.overflow=!1===(F[u]&&F[u].scrolling)?"hidden":"auto",F[u]&&F[u].scrolling){case"omit":break;case!0:i.scrolling="yes";break;case!1:i.scrolling="no";break;default:i.scrolling=F[u]?F[u].scrolling:"no"}}(),function(){function e(e){1/0!==F[u][e]&&0!==F[u][e]&&(i.style[e]=F[u][e]+"px",k(u,"Set "+e+" = "+F[u][e]+"px"))}function n(e){if(F[u]["min"+e]>F[u]["max"+e])throw new Error("Value for min"+e+" can not be greater than max"+e)}n("Height"),n("Width"),e("maxHeight"),e("minHeight"),e("maxWidth"),e("minWidth")}(),"number"!=typeof(F[u]&&F[u].bodyMargin)&&"0"!==(F[u]&&F[u].bodyMargin)||(F[u].bodyMarginV1=F[u].bodyMargin,F[u].bodyMargin=F[u].bodyMargin+"px"),r=A(u),(s=w())&&(a=s,i.parentNode&&new a(function(e){e.forEach(function(e){Array.prototype.slice.call(e.removedNodes).forEach(function(e){e===i&&T(i)})})}).observe(i.parentNode,{childList:!0})),M(i,"load",function(){P("iFrame.onload",r,i,f,!0),function(){var e=F[u]&&F[u].firstRun,n=F[u]&&F[u].heightCalculationMethod in g;!e&&n&&H({iframe:i,height:0,width:0,type:"init"})}()}),P("init",r,i,f,!0),F[u]&&(F[u].iframe.iFrameResizer={close:T.bind(null,F[u].iframe),removeListeners:E.bind(null,F[u].iframe),resize:P.bind(null,"Window resize","resize",F[u].iframe),moveToAnchor:function(e){P("Move to anchor","moveToAnchor:"+e,F[u].iframe,u)},sendMessage:function(e){P("Send Message","message:"+(e=JSON.stringify(e)),F[u].iframe,u)}}))}function c(e,n){null===i&&(i=setTimeout(function(){i=null,e()},n))}function u(){"hidden"!==document.visibilityState&&(k("document","Trigger event: Visiblity change"),c(function(){L("Tab Visable","resize")},16))}function L(n,i){Object.keys(F).forEach(function(e){(function(e){return F[e]&&"parent"===F[e].resizeFrom&&F[e].autoResize&&!F[e].firstRun})(e)&&P(n,i,document.getElementById(e),e)})}function q(){M(window,"message",n),M(window,"resize",function(){!function(e){k("window","Trigger event: "+e),c(function(){L("Window "+e,"resize")},16)}("resize")}),M(document,"visibilitychange",u),M(document,"-webkit-visibilitychange",u)}function B(){function i(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+">")}(),d(n,e),t.push(n))}var t;return function(){var e,n=["moz","webkit","o","ms"];for(e=0;e<n.length&&!r;e+=1)r=window[n[e]+"RequestAnimationFrame"];r||k("setup","RequestAnimationFrame not supported")}(),q(),function(e,n){switch(t=[],function(e){e&&e.enablePublicMethods&&O("enablePublicMethods option has been removed, public methods are now always available in the iFrame")}(e),typeof n){case"undefined":case"string":Array.prototype.forEach.call(document.querySelectorAll(n||"iframe"),i.bind(f,e));break;case"object":i(e,n);break;default:throw new TypeError("Unexpected data type ("+typeof n+")")}return t}}}(); | ||
!function(f){if("undefined"!=typeof window){var e,l=0,m=!1,o=!1,p="message".length,b="[iFrameSizer]",y=b.length,v=null,r=window.requestAnimationFrame,g={max:1,scroll:1,bodyScroll:1,documentElementScroll:1},F={},i=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,resizeFrom:"parent",scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,widthCalculationMethod:"scroll",onClose:function(){return!0},onClosed:function(){},onInit:function(){},onMessage:function(){O("onMessage function not defined")},onResized:function(){},onScroll:function(){return!0}},I={};window.jQuery&&((e=window.jQuery).fn?e.fn.iFrameResize||(e.fn.iFrameResize=function(i){return this.filter("iframe").each(function(e,n){d(n,i)}).end()}):z("","Unable to bind to jQuery, it is not fully loaded.")),"function"==typeof define&&define.amd?define([],B):"object"==typeof module&&"object"==typeof module.exports&&(module.exports=B()),window.iFrameResize=window.iFrameResize||B()}function w(){return window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver}function M(e,n,i){e.addEventListener(n,i,!1)}function x(e,n,i){e.removeEventListener(n,i,!1)}function a(e){return b+"["+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 F[e]?F[e].log:m}function k(e,n){s("log",e,n,t(e))}function z(e,n){s("info",e,n,t(e))}function O(e,n){s("warn",e,n,!0)}function s(e,n,i,t){!0===t&&"object"==typeof window.console&&console[e](a(n),i)}function n(n){function e(){i("Height"),i("Width"),j(function(){S(h),N(w),d("onResized",h)},h,"init")}function i(e){var n=Number(F[w]["max"+e]),i=Number(F[w]["min"+e]),t=e.toLowerCase(),o=Number(h[t]);k(w,"Checking "+t+" is in range "+i+"-"+n),o<i&&(o=i,k(w,"Set "+t+" to min value")),n<o&&(o=n,k(w,"Set "+t+" to max value")),h[t]=""+o}function t(e){return g.substr(g.indexOf(":")+p+e)}function a(e,n){!function(e,n,i){I[i]||(I[i]=setTimeout(function(){I[i]=null,e()},n))}(function(){P("Send Page Info","pageInfo:"+function(){var e=document.body.getBoundingClientRect(),n=h.iframe.getBoundingClientRect();return JSON.stringify({iframeHeight:n.height,iframeWidth:n.width,clientHeight:Math.max(document.documentElement.clientHeight,window.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,window.innerWidth||0),offsetTop:parseInt(n.top-e.top,10),offsetLeft:parseInt(n.left-e.left,10),scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,documentHeight:document.documentElement.clientHeight,documentWidth:document.documentElement.clientWidth,windowHeight:window.innerHeight,windowWidth:window.innerWidth})}(),e,n)},32,n)}function r(e){var n=e.getBoundingClientRect();return C(w),{x:Math.floor(Number(n.left)+Number(v.x)),y:Math.floor(Number(n.top)+Number(v.y))}}function o(e){var n=e?r(h.iframe):{x:0,y:0},i={x:Number(h.width)+n.x,y:Number(h.height)+n.y};k(w,"Reposition requested from iFrame (offset x:"+n.x+" y:"+n.y+")"),window.top!==window.self?window.parentIFrame?window.parentIFrame["scrollTo"+(e?"Offset":"")](i.x,i.y):O(w,"Unable to scroll to requested position, window.parentIFrame not found"):(v=i,s(),k(w,"--"))}function s(){!1!==d("onScroll",v)?N(w):W()}function d(e,n){return R(w,e,n)}var c,u,f,l,m,g=n.data,h={},w=null;"[iFrameResizerChild]Ready"===g?function(){for(var e in F)P("iFrame requested init",A(e),document.getElementById(e),e)}():b===(""+g).substr(0,y)&&g.substr(y).split(":")[0]in F?(m=g.substr(y).split(":"),h={iframe:F[m[0]]&&F[m[0]].iframe,id:m[0],height:m[1],width:m[2],type:m[3]},w=h.id,F[w]&&(F[w].loaded=!0),(l=h.type in{true:1,false:1,undefined:1})&&k(w,"Ignoring init message from meta parent page"),!l&&(f=!0,F[u=w]||(f=!1,O(h.type+" No settings for "+u+". Message was: "+g)),f)&&(k(w,"Received: "+g),c=!0,null===h.iframe&&(O(w,"IFrame ("+h.id+") not found"),c=!1),c&&function(){var e,i=n.origin,t=F[w]&&F[w].checkOrigin;if(t&&""+i!="null"&&!(t.constructor===Array?function(){var e=0,n=!1;for(k(w,"Checking connection is from allowed list of origins: "+t);e<t.length;e++)if(t[e]===i){n=!0;break}return n}():(e=F[w]&&F[w].remoteHost,k(w,"Checking connection is from: "+e),i===e)))throw new Error("Unexpected message received from: "+i+" for "+h.iframe.id+". Message was: "+n.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return!0}()&&function(){switch(F[w]&&F[w].firstRun&&F[w]&&(F[w].firstRun=!1),h.type){case"close":T(h.iframe);break;case"message":!function(e){k(w,"onMessage passed: {iframe: "+h.iframe.id+", message: "+e+"}"),d("onMessage",{iframe:h.iframe,message:JSON.parse(e)}),k(w,"--")}(t(6));break;case"autoResize":F[w].autoResize=JSON.parse(t(9));break;case"scrollTo":o(!1);break;case"scrollToOffset":o(!0);break;case"pageInfo":a(F[w]&&F[w].iframe,w),function(){function e(n,i){function t(){F[r]?a(F[r].iframe,r):o()}["scroll","resize"].forEach(function(e){k(r,n+e+" listener for sendPageInfo"),i(window,e,t)})}function o(){e("Remove ",x)}var r=w;e("Add ",M),F[r]&&(F[r].stopPageInfo=o)}();break;case"pageInfoStop":F[w]&&F[w].stopPageInfo&&(F[w].stopPageInfo(),delete F[w].stopPageInfo);break;case"inPageLink":!function(e){var n,i=e.split("#")[1]||"",t=decodeURIComponent(i),o=document.getElementById(t)||document.getElementsByName(t)[0];o?(n=r(o),k(w,"Moving to in page link (#"+i+") at x: "+n.x+" y: "+n.y),v={x:n.x,y:n.y},s(),k(w,"--")):window.top!==window.self?window.parentIFrame?window.parentIFrame.moveToAnchor(i):k(w,"In page link #"+i+" not found and window.parentIFrame not found"):k(w,"In page link #"+i+" not found")}(t(9));break;case"reset":H(h);break;case"init":e(),d("onInit",h.iframe);break;default:e()}}())):z(w,"Ignored: "+g)}function R(e,n,i){var t=null,o=null;if(F[e]){if("function"!=typeof(t=F[e][n]))throw new TypeError(n+" on iFrame["+e+"] is not a function");o=t(i)}return o}function E(e){var n=e.id;delete F[n]}function T(e){var n=e.id;if(!1!==R(n,"onClose",n)){k(n,"Removing iFrame: "+n);try{e.parentNode&&e.parentNode.removeChild(e)}catch(e){O(e)}R(n,"onClosed",n),k(n,"--"),E(e)}else k(n,"Close iframe cancelled by onClose event")}function C(e){null===v&&k(e,"Get page position: "+(v={x:window.pageXOffset!==f?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==f?window.pageYOffset:document.documentElement.scrollTop}).x+","+v.y)}function N(e){null!==v&&(window.scrollTo(v.x,v.y),k(e,"Set page position: "+v.x+","+v.y),W())}function W(){v=null}function H(e){k(e.id,"Size reset requested by "+("init"===e.type?"host page":"iFrame")),C(e.id),j(function(){S(e),P("reset","reset",e.iframe,e.id)},e,"reset")}function S(n){function i(e){o||"0"!==n[e]||(o=!0,k(t,"Hidden iFrame detected, creating visibility listener"),function(){function n(){Object.keys(F).forEach(function(e){!function(n){function e(e){return"0px"===(F[n]&&F[n].iframe.style[e])}F[n]&&(i=F[n].iframe,null!==i.offsetParent)&&(e("height")||e("width"))&&P("Visibility change","resize",F[n].iframe,n);var i}(F[e])})}function i(e){k("window","Mutation observed: "+e[0].target+" "+e[0].type),c(n,16)}var t=w();t&&function(){var e=document.querySelector("body"),n={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0};new t(i).observe(e,n)}()}())}function e(e){!function(e){n.id?(n.iframe.style[e]=n[e]+"px",k(n.id,"IFrame ("+t+") "+e+" set to "+n[e]+"px")):k("undefined","messageData id not set")}(e),i(e)}var t=n.iframe.id;F[t]&&(F[t].sizeHeight&&e("height"),F[t].sizeWidth&&e("width"))}function j(e,n,i){i!==n.type&&r?(k(n.id,"Requesting animation frame"),r(e)):e()}function P(e,n,i,t,o){var r,a=!1;t=t||i.id,F[t]&&(i&&"contentWindow"in i&&null!==i.contentWindow?(r=F[t]&&F[t].targetOrigin,k(t,"["+e+"] Sending msg to iframe["+t+"] ("+n+") targetOrigin: "+r),i.contentWindow.postMessage(b+n,r)):O(t,"["+e+"] IFrame("+t+") not found"),o&&F[t]&&F[t].warningTimeout&&(F[t].msgTimeout=setTimeout(function(){!F[t]||F[t].loaded||a||(a=!0,O(t,"IFrame has not responded within "+F[t].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."))},F[t].warningTimeout)))}function A(e){return e+":"+F[e].bodyMarginV1+":"+F[e].sizeWidth+":"+F[e].log+":"+F[e].interval+":"+F[e].enablePublicMethods+":"+F[e].autoResize+":"+F[e].bodyMargin+":"+F[e].heightCalculationMethod+":"+F[e].bodyBackground+":"+F[e].bodyPadding+":"+F[e].tolerance+":"+F[e].inPageLinks+":"+F[e].resizeFrom+":"+F[e].widthCalculationMethod}function d(i,e){function n(e){var n=e.split("Callback");if(2===n.length){var i="on"+n[0].charAt(0).toUpperCase()+n[0].slice(1);this[i]=this[e],delete this[e],O(u,"Deprecated: '"+e+"' has been renamed '"+i+"'. The old method will be removed in the next major version.")}}var t,o,r,a,s,d,c,u=(""===(o=i.id)&&(i.id=(t=e&&e.id||h.id+l++,null!==document.getElementById(t)&&(t+=l++),o=t),m=(e||{}).log,k(o,"Added missing iframe ID: "+o+" ("+i.src+")")),o);u in F&&"iFrameResizer"in i?O(u,"Ignored iFrame, already setup."):(c=(c=e)||{},F[u]={firstRun:!0,iframe:i,remoteHost:i.src.split("/").slice(0,3).join("/")},function(e){if("object"!=typeof e)throw new TypeError("Options is not an object")}(c),Object.keys(c).forEach(n,c),function(e){for(var n in h)Object.prototype.hasOwnProperty.call(h,n)&&(F[u][n]=Object.prototype.hasOwnProperty.call(e,n)?e[n]:h[n])}(c),F[u]&&(F[u].targetOrigin=!0===F[u].checkOrigin?""===(d=F[u].remoteHost)||"file://"===d?"*":d:"*"),function(){switch(k(u,"IFrame scrolling "+(F[u]&&F[u].scrolling?"enabled":"disabled")+" for "+u),i.style.overflow=!1===(F[u]&&F[u].scrolling)?"hidden":"auto",F[u]&&F[u].scrolling){case"omit":break;case!0:i.scrolling="yes";break;case!1:i.scrolling="no";break;default:i.scrolling=F[u]?F[u].scrolling:"no"}}(),function(){function e(e){1/0!==F[u][e]&&0!==F[u][e]&&(i.style[e]=F[u][e]+"px",k(u,"Set "+e+" = "+F[u][e]+"px"))}function n(e){if(F[u]["min"+e]>F[u]["max"+e])throw new Error("Value for min"+e+" can not be greater than max"+e)}n("Height"),n("Width"),e("maxHeight"),e("minHeight"),e("maxWidth"),e("minWidth")}(),"number"!=typeof(F[u]&&F[u].bodyMargin)&&"0"!==(F[u]&&F[u].bodyMargin)||(F[u].bodyMarginV1=F[u].bodyMargin,F[u].bodyMargin=F[u].bodyMargin+"px"),r=A(u),(s=w())&&(a=s,i.parentNode&&new a(function(e){e.forEach(function(e){Array.prototype.slice.call(e.removedNodes).forEach(function(e){e===i&&T(i)})})}).observe(i.parentNode,{childList:!0})),M(i,"load",function(){P("iFrame.onload",r,i,f,!0),function(){var e=F[u]&&F[u].firstRun,n=F[u]&&F[u].heightCalculationMethod in g;!e&&n&&H({iframe:i,height:0,width:0,type:"init"})}()}),P("init",r,i,f,!0),F[u]&&(F[u].iframe.iFrameResizer={close:T.bind(null,F[u].iframe),removeListeners:E.bind(null,F[u].iframe),resize:P.bind(null,"Window resize","resize",F[u].iframe),moveToAnchor:function(e){P("Move to anchor","moveToAnchor:"+e,F[u].iframe,u)},sendMessage:function(e){P("Send Message","message:"+(e=JSON.stringify(e)),F[u].iframe,u)}}))}function c(e,n){null===i&&(i=setTimeout(function(){i=null,e()},n))}function u(){"hidden"!==document.visibilityState&&(k("document","Trigger event: Visiblity change"),c(function(){L("Tab Visable","resize")},16))}function L(n,i){Object.keys(F).forEach(function(e){(function(e){return F[e]&&"parent"===F[e].resizeFrom&&F[e].autoResize&&!F[e].firstRun})(e)&&P(n,i,document.getElementById(e),e)})}function q(){M(window,"message",n),M(window,"resize",function(){!function(e){k("window","Trigger event: "+e),c(function(){L("Window "+e,"resize")},16)}("resize")}),M(document,"visibilitychange",u),M(document,"-webkit-visibilitychange",u)}function B(){function i(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+">")}(),d(n,e),t.push(n))}var t;return function(){var e,n=["moz","webkit","o","ms"];for(e=0;e<n.length&&!r;e+=1)r=window[n[e]+"RequestAnimationFrame"];r||k("setup","RequestAnimationFrame not supported")}(),q(),function(e,n){switch(t=[],function(e){e&&e.enablePublicMethods&&O("enablePublicMethods option has been removed, public methods are now always available in the iFrame")}(e),typeof n){case"undefined":case"string":Array.prototype.forEach.call(document.querySelectorAll(n||"iframe"),i.bind(f,e));break;case"object":i(e,n);break;default:throw new TypeError("Unexpected data type ("+typeof n+")")}return t}}}(); | ||
//# sourceMappingURL=iframeResizer.map |
{ | ||
"name": "iframe-resizer", | ||
"version": "4.2.0", | ||
"version": "4.2.1", | ||
"homepage": "https://github.com/davidjbradshaw/iframe-resizer", | ||
@@ -49,3 +49,3 @@ "authors": [ | ||
"eslint-plugin-switch-case": "^1.1.2", | ||
"eslint-plugin-unicorn": "^11.0.0", | ||
"eslint-plugin-unicorn": "^11.0.2", | ||
"grunt": "^1.0.4", | ||
@@ -52,0 +52,0 @@ "grunt-bump": "^0.8.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
168400
2385