@iframe-resizer/jquery 5.0.0-alpha.1 → 5.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,11 @@
1
- ## @iframe-resizer/jquery
1
+ # @iframe-resizer/jquery
2
2
 
3
- This is package is part of [iframe-resizer](http://davidjbradshaw.github.io/iframe-resizer/).
3
+ > _Keep same and cross domain iframes sized to their content_
4
4
 
5
- --
6
- _ iframe-resizer version 5.0.0-alpha.1 2024-04-12 - 13:11:29.509Z _
5
+ This package is an alpha release of version 5 of _iframe-resizer_ for the production version see the [iframe-resizer](https://www.npmjs.com/package/iframe-resizer) package.
6
+
7
+ Alpha version 5 docs: http://davidjbradshaw.github.io/iframe-resizer-docs/.
8
+
9
+ ---
10
+
11
+ _iframe-resizer version 5.0.0-alpha.3 2024-04-13 - 20:04:18.979Z_
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * @preserve
3
3
  *
4
- * @module iframe-resizer/jquery 5.0.0-alpha.1 (cjs) - 2024-04-12
4
+ * @module iframe-resizer/jquery 5.0.0-alpha.3 (cjs) - 2024-04-13
5
5
  *
6
6
  * @license GPL-3.0 for non-commercial use only.
7
7
  * For commercial use, you must purchase a license from
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * @preserve
3
3
  *
4
- * @module iframe-resizer/jquery 5.0.0-alpha.1 (esm) - 2024-04-12
4
+ * @module iframe-resizer/jquery 5.0.0-alpha.3 (esm) - 2024-04-13
5
5
  *
6
6
  * @license GPL-3.0 for non-commercial use only.
7
7
  * For commercial use, you must purchase a license from
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * @preserve
3
3
  *
4
- * @module iframe-resizer/jquery 5.0.0-alpha.1 (umd) - 2024-04-12
4
+ * @module iframe-resizer/jquery 5.0.0-alpha.3 (umd) - 2024-04-13
5
5
  *
6
6
  * @license GPL-3.0 for non-commercial use only.
7
7
  * For commercial use, you must purchase a license from
@@ -17,4 +17,4 @@
17
17
  */
18
18
 
19
19
 
20
- !function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";const e="[iFrameSizer]",n=e.length,i=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),t=(e,n,i,t)=>e.addEventListener(n,i,t||!1),o=(e,n,i)=>e.removeEventListener(n,i,!1),r="[iframeResizer]";const s=e=>`${r}[${function(e){return window.top===window.self?`Host page: ${e}`:window?.parentIFrame?.getId?`${window.parentIFrame.getId()}: ${e}`:`Nested host page: ${e}`}(e)}]`,a=(e,n,...i)=>window?.console[e](s(n),...i),d=(e,...n)=>a("info",e,...n),c=(e,...n)=>a("warn",e,...n),l=(e,n)=>window?.console.warn(((e,...n)=>[`${r}[${e}]`,...n].join(" "))(e,window.chrome?n:n.replaceAll(/\u001B\[[\d;]*m/gi,""))),u=e=>!Number.isNaN(e),f={},m=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:"vertical",inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"auto",id:"iFrameResizer",log:!0,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,mouseEvents:!0,offsetHeight:0,offsetWidth:0,postMessageTarget:null,sameDomain:!1,scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,widthCalculationMethod:"auto",onClose:()=>!0,onClosed(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{"function"==typeof f[e.id].onInit&&(l(e.id,"\nDeprecated Option\n\nThe onInit() function is deprecated and has been replaced with onReady(). It will be removed in a future version of iFrame Resizer.\n "),f[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),h={position:null,version:"5.0.0-alpha.1"};function g(i){function r(){l("Height"),l("Width"),R(L),v(),C("onResized",L)}function s(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function a(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}function l(e){const n=Number(f[B][`max${e}`]),i=Number(f[B][`min${e}`]),t=e.toLowerCase();let o=Number(L[t]);o<i&&(o=i),o>n&&(o=n),L[t]=`${o}`}function u(e){return j.slice(j.indexOf(":")+7+e)}const m=(e,n)=>(i,t)=>{const o={};var r,s;r=function(){T(`Send ${e} (${i})`,`${e}:${n()}`,t)},o[s=t]||(r(),o[s]=requestAnimationFrame((()=>{o[s]=null})))},g=(e,n)=>()=>{const i=n=>()=>{f[a]?e(n,a):s()};function r(e,n){n(window,"scroll",i("scroll")),n(window,"resize",i("resize window"))}function s(){r(0,o),d.disconnect()}const a=B,d=new ResizeObserver(i("iframe observed"));r(0,t),d.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),f[a]&&(f[a][`stop${n}`]=s)},w=e=>()=>{e in f[B]&&(f[B][e](),delete f[B][e])},k=m("pageInfo",(function(){const e=document.body.getBoundingClientRect(),n=L.iframe.getBoundingClientRect(),{scrollY:i,scrollX:t,innerHeight:o,innerWidth:r}=window,{clientHeight:s,clientWidth:a}=document.documentElement;return JSON.stringify({iframeHeight:n.height,iframeWidth:n.width,clientHeight:Math.max(s,o||0),clientWidth:Math.max(a,r||0),offsetTop:parseInt(n.top-e.top,10),offsetLeft:parseInt(n.left-e.left,10),scrollTop:i,scrollLeft:t,documentHeight:s,documentWidth:a,windowHeight:o,windowWidth:r})})),x=m("parentInfo",(function(){const{iframe:e}=L,{scrollWidth:n,scrollHeight:i}=document.documentElement,{width:t,height:o,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:d,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:n,scrollHeight:i},viewport:{width:t,height:o,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:d,scale:c}})})),M=g(k,"PageInfo"),W=g(x,"ParentInfo"),N=w("stopPageInfo"),H=w("stopParentInfo");function E(e){const n=e.getBoundingClientRect();return y(),{x:Math.floor(Number(n.left)+Number(h.position.x)),y:Math.floor(Number(n.top)+Number(h.position.y))}}function F(e){const n=e?E(L.iframe):{x:0,y:0};let i=((e,n)=>({x:Number(e.width)+n.x,y:Number(e.height)+n.y}))(L,n);window.top===window.self?(h.position=i,O()):window.parentIFrame?window.parentIFrame["scrollTo"+(e?"Offset":"")](i.x,i.y):c(B,"Unable to scroll to requested position, window.parentIFrame not found")}function O(){!1!==C("onScroll",h.position)?v():z()}function S(e){let n={};if(0===Number(L.width)&&0===Number(L.height)){const e=u(9).split(":");n={x:e[1],y:e[0]}}else n={x:L.width,y:L.height};C(e,{iframe:L.iframe,screenX:Number(n.x),screenY:Number(n.y),type:L.type})}const C=(e,n)=>p(B,e,n);let j=i.data,L={},B=null;"[iFrameResizerChild]Ready"!==j?e===`${j}`.slice(0,n)&&j.slice(n).split(":")[0]in f?(L=function(){const e=j.slice(n).split(":"),i=e[1]?Number(e[1]):0,t=f[e[0]]?.iframe,o=getComputedStyle(t);return{iframe:t,id:e[0],height:i+s(o)+a(o),width:Number(e[2]),type:e[3]}}(),B=L.id,B?(function(e){if(!f[e])throw new Error(`${L.type} No settings for ${e}. Message was: ${j}`)}(B),L.type in{true:1,false:1,undefined:1}||(f[B].loaded=!0,function(){let e=!0;return null===L.iframe&&(c(B,`The iframe (${L.id}) was not found.`),e=!1),e}()&&function(){const{origin:e,sameDomain:n}=i;if(n)return!0;let t=f[B]?.checkOrigin;if(t&&"null"!=`${e}`&&!(t.constructor===Array?function(){let n=0,i=!1;for(;n<t.length;n++)if(t[n]===e){i=!0;break}return i}():function(){const n=f[B]?.remoteHost;return e===n}()))throw new Error(`Unexpected message received from: ${e} for ${L.iframe.id}. Message was: ${i.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[B]?.firstRun&&f[B]&&(f[B].firstRun=!1),L.type){case"close":b(L.iframe);break;case"message":e=u(6),C("onMessage",{iframe:L.iframe,message:JSON.parse(e)});break;case"mouseenter":S("onMouseEnter");break;case"mouseleave":S("onMouseLeave");break;case"autoResize":f[B].autoResize=JSON.parse(u(9));break;case"scrollTo":F(!1);break;case"scrollToOffset":F(!0);break;case"pageInfo":k("start",B),M();break;case"parentInfo":x("start",B),W();break;case"pageInfoStop":N();break;case"parentInfoStop":H();break;case"inPageLink":!function(e){const n=e.split("#")[1]||"",i=decodeURIComponent(n);let t=document.getElementById(i)||document.getElementsByName(i)[0];t?function(){const e=E(t);h.position={x:e.x,y:e.y},O()}():window.top!==window.self&&window.parentIFrame&&window.parentIFrame.moveToAnchor(n)}(u(9));break;case"reset":$(L);break;case"init":r(),function(e){try{f[e].sameDomain=!!f[e]?.iframe?.contentWindow?.iframeChildListener}catch(n){f[e].sameDomain=!1}}(B),C("onReady",L.iframe);break;default:if(0===L.width&&0===L.height)return void c(`Unsupported message received (${L.type}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===L.width||0===L.height)return;if(document.hidden)return;r()}var e}())):c("iframeResizer received messageData without id, message was: ",j)):d(B,`Ignored: ${j}`):Object.keys(f).forEach((e=>T("iFrame requested init",I(e),e)))}function p(e,n,i){let t=null,o=null;if(f[e]){if(t=f[e][n],"function"!=typeof t)throw new TypeError(`${n} on iFrame[${e}] is not a function`);o=t(i)}return o}function w(e){const n=e.id;delete f[n]}function b(e){const n=e.id;if(!1!==p(n,"onClose",n)){try{e.parentNode&&e.remove()}catch(e){c(e)}p(n,"onClosed",n),w(e)}}function y(e){null===h.position&&(h.position={x:window.scrollX,y:window.scrollY})}function z(){h.position=null}function v(e){null!==h.position&&(window.scrollTo(h.position.x,h.position.y),z())}function $(e){y(e.id),R(e),T("reset","reset",e.id)}function R(e){const n=e.id;function i(n){const i=`${e[n]}px`;e.iframe.style[n]=i}f[n].sizeHeight&&i("height"),f[n].sizeWidth&&i("width")}function T(n,i,t,o){f[t]&&(f[t]?.postMessageTarget?function(){const{postMessageTarget:n,targetOrigin:o}=f[t];if(f[t].sameDomain)try{return void f[t].iframe.contentWindow.iframeChildListener(e+i)}catch(e){d(t,"Same domain connection failed. Trying cross domain"),f[t].sameDomain=!1}n.postMessage(e+i,o)}():c(t,`[${n}] IFrame(${t}) not found`),o&&f[t]?.warningTimeout&&(f[t].msgTimeout=setTimeout((function(){void 0!==f[t]&&(f[t].loaded||f[t].loadErrorShown||(f[t].loadErrorShown=!0,l(t,`\nNo response from iFrame\n \nThe iframe (${t}) has not responded within ${f[t].warningTimeout/1e3} seconds. Check iFrameResizer.contentWindow.js has been loaded in the iframe.\n\nThis 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.\n`)))}),f[t].warningTimeout)))}function I(e){const n=f[e];return[e,"8",n.sizeWidth,n.log,"32",n.enablePublicMethods,n.autoResize,n.bodyMargin,n.heightCalculationMethod,n.bodyBackground,n.bodyPadding,n.tolerance,n.inPageLinks,"child",n.widthCalculationMethod,n.mouseEvents,n.offsetHeight,n.offsetWidth,n.sizeHeight,h.version].join(":")}let k=0;const x=e=>n=>{function o(e){if(!e)return{};if("object"!=typeof e)throw new TypeError("Options is not an object");return("sizeWidth"in e||"sizeHeight"in e||"autoResize"in e)&&l(r,'\nDeprecated Optionm\n\nThe sizeWidth, sizeHeight and autoResize options have been replaced with new direction option which expects values of "vertical", "horizontal" or "horizontal".\n'),e}const r=function(i){if(i&&"string"!=typeof i)throw new TypeError("Invaild id for iFrame. Expected String");return""!==i&&i||(n.id=i=function(){let n=e?.id||m.id+k++;return null!==document.getElementById(n)&&(n+=k++),n}(),(e||{}).log),i}(n.id);r in f&&"iFrameResizer"in n?c(r,"Ignored iFrame, already setup."):(!function(e){var i;f[r]={iframe:n,firstRun:!0,remoteHost:n?.src.split("/").slice(0,3).join("/"),...m,...o(e)},function(){if("horizontal"===f[r].direction)return f[r].sizeWidth=!0,void(f[r].sizeHeight=!1);if("none"===f[r].direction)return f[r].sizeWidth=!1,f[r].sizeHeight=!1,void(f[r].autoResize=!1);if("vertical"!==f[r].direction)throw new TypeError(r,`Direction value of "${f[r].direction}" is not valid`)}(),null===f[r].postMessageTarget&&(f[r].postMessageTarget=n.contentWindow),f[r].targetOrigin=!0===f[r].checkOrigin?""===(i=f[r].remoteHost)||null!==i.match(/^(about:blank|javascript:|file:\/\/)/)?"*":i:"*"}(e),W(),function(){switch(n.style.overflow=!1===f[r]?.scrolling?"hidden":"auto",f[r]?.scrolling){case"omit":break;case!0:n.scrolling="yes";break;case!1:n.scrolling="no";break;default:n.scrolling=f[r]?f[r].scrolling:"no"}}(),function(){function e(e){const i=f[r][e];1/0!==i&&0!==i&&(n.style[e]=u(i)?`${i}px`:i)}function i(e){if(u(`min${e}`)&&u(`max${e}`)&&f[r][`min${e}`]>f[r][`max${e}`])throw new Error(`Value for min${e} can not be greater than max${e}`)}i("Height"),i("Width"),e("maxHeight"),e("minHeight"),e("maxWidth"),e("minWidth")}(),function(){const{bodyMargin:e}=f[r];"number"!=typeof e&&"0"!==e||(f[r].bodyMargin=`${e}px`)}(),function(e){const{id:o}=n;t(n,"load",(function(){T("iFrame.onload",e,o,!0),function(){const e=f[r]?.firstRun,t=f[r]?.heightCalculationMethod in i;!e&&t&&$({iframe:n,height:0,width:0,type:"init"})}()})),T("init",e,o,!0)}(I(r)),f[r]&&(f[r].iframe.iFrameResizer={close:b.bind(null,f[r].iframe),removeListeners:w.bind(null,f[r].iframe),resize:T.bind(null,"Window resize","resize",r),moveToAnchor(e){T("Move to anchor",`moveToAnchor:${e}`,r)},sendMessage(e){T("Send Message",`message:${e=JSON.stringify(e)}`,r)}}))};function M(){!1===document.hidden&&function(e,n){const i=e=>f[e]?.autoResize&&!f[e]?.firstRun;Object.keys(f).forEach((function(t){i(t)&&T(e,n,t)}))}("Tab Visible","resize")}const W=(e=>{let n=!1;return function(){return n?void 0:(n=!0,Reflect.apply(e,this,arguments))}})((()=>{t(window,"message",g),t(document,"visibilitychange",M),window.iframeParentListener=e=>g({data:e,sameDomain:!0})}));switch(!0){case void 0===window.jQuery:c("","Unable to bind to jQuery, it is not available.");break;case!window.jQuery.fn:c("","Unable to bind to jQuery, it is not fully loaded.");break;case window.jQuery.fn.iframeResize:c("","iframeResize is already assigned to jQuery.fn.");break;default:window.jQuery.fn.iframeResize=function(e){const n=x(e);return this.filter("iframe").each(n).end()},window.jQuery.fn.iFrameResize=function(e){return c("","Deprecated: Use the iframeResize method instead of iFrameResize"),this.iframeResize(e)}}}));
20
+ !function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";const e="[iFrameSizer]",n=e.length,i=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),t=(e,n,i,t)=>e.addEventListener(n,i,t||!1),o=(e,n,i)=>e.removeEventListener(n,i,!1),r="[iframeResizer]";const s=e=>`${r}[${function(e){return window.top===window.self?`Host page: ${e}`:window?.parentIFrame?.getId?`${window.parentIFrame.getId()}: ${e}`:`Nested host page: ${e}`}(e)}]`,a=(e,n,...i)=>window?.console[e](s(n),...i),d=(e,...n)=>a("info",e,...n),c=(e,...n)=>a("warn",e,...n),l=(e,n)=>window?.console.warn(((e,...n)=>[`${r}[${e}]`,...n].join(" "))(e,window.chrome?n:n.replaceAll(/\u001B\[[\d;]*m/gi,""))),u=e=>!Number.isNaN(e),f={},m=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:"vertical",inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"auto",id:"iFrameResizer",log:!0,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,mouseEvents:!0,offsetHeight:0,offsetWidth:0,postMessageTarget:null,sameDomain:!1,scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,widthCalculationMethod:"auto",onClose:()=>!0,onClosed(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{"function"==typeof f[e.id].onInit&&(l(e.id,"\nDeprecated Option\n\nThe onInit() function is deprecated and has been replaced with onReady(). It will be removed in a future version of iFrame Resizer.\n "),f[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),h={position:null,version:"5.0.0-alpha.3"};function g(i){function r(){l("Height"),l("Width"),R(L),v(),C("onResized",L)}function s(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function a(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}function l(e){const n=Number(f[B][`max${e}`]),i=Number(f[B][`min${e}`]),t=e.toLowerCase();let o=Number(L[t]);o<i&&(o=i),o>n&&(o=n),L[t]=`${o}`}function u(e){return j.slice(j.indexOf(":")+7+e)}const m=(e,n)=>(i,t)=>{const o={};var r,s;r=function(){T(`Send ${e} (${i})`,`${e}:${n()}`,t)},o[s=t]||(r(),o[s]=requestAnimationFrame((()=>{o[s]=null})))},g=(e,n)=>()=>{const i=n=>()=>{f[a]?e(n,a):s()};function r(e,n){n(window,"scroll",i("scroll")),n(window,"resize",i("resize window"))}function s(){r(0,o),d.disconnect()}const a=B,d=new ResizeObserver(i("iframe observed"));r(0,t),d.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),f[a]&&(f[a][`stop${n}`]=s)},w=e=>()=>{e in f[B]&&(f[B][e](),delete f[B][e])},k=m("pageInfo",(function(){const e=document.body.getBoundingClientRect(),n=L.iframe.getBoundingClientRect(),{scrollY:i,scrollX:t,innerHeight:o,innerWidth:r}=window,{clientHeight:s,clientWidth:a}=document.documentElement;return JSON.stringify({iframeHeight:n.height,iframeWidth:n.width,clientHeight:Math.max(s,o||0),clientWidth:Math.max(a,r||0),offsetTop:parseInt(n.top-e.top,10),offsetLeft:parseInt(n.left-e.left,10),scrollTop:i,scrollLeft:t,documentHeight:s,documentWidth:a,windowHeight:o,windowWidth:r})})),x=m("parentInfo",(function(){const{iframe:e}=L,{scrollWidth:n,scrollHeight:i}=document.documentElement,{width:t,height:o,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:d,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:n,scrollHeight:i},viewport:{width:t,height:o,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:d,scale:c}})})),M=g(k,"PageInfo"),W=g(x,"ParentInfo"),N=w("stopPageInfo"),H=w("stopParentInfo");function E(e){const n=e.getBoundingClientRect();return y(),{x:Math.floor(Number(n.left)+Number(h.position.x)),y:Math.floor(Number(n.top)+Number(h.position.y))}}function F(e){const n=e?E(L.iframe):{x:0,y:0};let i=((e,n)=>({x:Number(e.width)+n.x,y:Number(e.height)+n.y}))(L,n);window.top===window.self?(h.position=i,O()):window.parentIFrame?window.parentIFrame["scrollTo"+(e?"Offset":"")](i.x,i.y):c(B,"Unable to scroll to requested position, window.parentIFrame not found")}function O(){!1!==C("onScroll",h.position)?v():z()}function S(e){let n={};if(0===Number(L.width)&&0===Number(L.height)){const e=u(9).split(":");n={x:e[1],y:e[0]}}else n={x:L.width,y:L.height};C(e,{iframe:L.iframe,screenX:Number(n.x),screenY:Number(n.y),type:L.type})}const C=(e,n)=>p(B,e,n);let j=i.data,L={},B=null;"[iFrameResizerChild]Ready"!==j?e===`${j}`.slice(0,n)&&j.slice(n).split(":")[0]in f?(L=function(){const e=j.slice(n).split(":"),i=e[1]?Number(e[1]):0,t=f[e[0]]?.iframe,o=getComputedStyle(t);return{iframe:t,id:e[0],height:i+s(o)+a(o),width:Number(e[2]),type:e[3]}}(),B=L.id,B?(function(e){if(!f[e])throw new Error(`${L.type} No settings for ${e}. Message was: ${j}`)}(B),L.type in{true:1,false:1,undefined:1}||(f[B].loaded=!0,function(){let e=!0;return null===L.iframe&&(c(B,`The iframe (${L.id}) was not found.`),e=!1),e}()&&function(){const{origin:e,sameDomain:n}=i;if(n)return!0;let t=f[B]?.checkOrigin;if(t&&"null"!=`${e}`&&!(t.constructor===Array?function(){let n=0,i=!1;for(;n<t.length;n++)if(t[n]===e){i=!0;break}return i}():function(){const n=f[B]?.remoteHost;return e===n}()))throw new Error(`Unexpected message received from: ${e} for ${L.iframe.id}. Message was: ${i.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[B]?.firstRun&&f[B]&&(f[B].firstRun=!1),L.type){case"close":b(L.iframe);break;case"message":e=u(6),C("onMessage",{iframe:L.iframe,message:JSON.parse(e)});break;case"mouseenter":S("onMouseEnter");break;case"mouseleave":S("onMouseLeave");break;case"autoResize":f[B].autoResize=JSON.parse(u(9));break;case"scrollTo":F(!1);break;case"scrollToOffset":F(!0);break;case"pageInfo":k("start",B),M();break;case"parentInfo":x("start",B),W();break;case"pageInfoStop":N();break;case"parentInfoStop":H();break;case"inPageLink":!function(e){const n=e.split("#")[1]||"",i=decodeURIComponent(n);let t=document.getElementById(i)||document.getElementsByName(i)[0];t?function(){const e=E(t);h.position={x:e.x,y:e.y},O()}():window.top!==window.self&&window.parentIFrame&&window.parentIFrame.moveToAnchor(n)}(u(9));break;case"reset":$(L);break;case"init":r(),function(e){try{f[e].sameDomain=!!f[e]?.iframe?.contentWindow?.iframeChildListener}catch(n){f[e].sameDomain=!1}}(B),C("onReady",L.iframe);break;default:if(0===L.width&&0===L.height)return void c(`Unsupported message received (${L.type}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===L.width||0===L.height)return;if(document.hidden)return;r()}var e}())):c("iframeResizer received messageData without id, message was: ",j)):d(B,`Ignored: ${j}`):Object.keys(f).forEach((e=>T("iFrame requested init",I(e),e)))}function p(e,n,i){let t=null,o=null;if(f[e]){if(t=f[e][n],"function"!=typeof t)throw new TypeError(`${n} on iFrame[${e}] is not a function`);o=t(i)}return o}function w(e){const n=e.id;delete f[n]}function b(e){const n=e.id;if(!1!==p(n,"onClose",n)){try{e.parentNode&&e.remove()}catch(e){c(e)}p(n,"onClosed",n),w(e)}}function y(e){null===h.position&&(h.position={x:window.scrollX,y:window.scrollY})}function z(){h.position=null}function v(e){null!==h.position&&(window.scrollTo(h.position.x,h.position.y),z())}function $(e){y(e.id),R(e),T("reset","reset",e.id)}function R(e){const n=e.id;function i(n){const i=`${e[n]}px`;e.iframe.style[n]=i}f[n].sizeHeight&&i("height"),f[n].sizeWidth&&i("width")}function T(n,i,t,o){f[t]&&(f[t]?.postMessageTarget?function(){const{postMessageTarget:n,targetOrigin:o}=f[t];if(f[t].sameDomain)try{return void f[t].iframe.contentWindow.iframeChildListener(e+i)}catch(e){d(t,"Same domain connection failed. Trying cross domain"),f[t].sameDomain=!1}n.postMessage(e+i,o)}():c(t,`[${n}] IFrame(${t}) not found`),o&&f[t]?.warningTimeout&&(f[t].msgTimeout=setTimeout((function(){void 0!==f[t]&&(f[t].loaded||f[t].loadErrorShown||(f[t].loadErrorShown=!0,l(t,`\nNo response from iFrame\n \nThe iframe (${t}) has not responded within ${f[t].warningTimeout/1e3} seconds. Check iFrameResizer.contentWindow.js has been loaded in the iframe.\n\nThis 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.\n`)))}),f[t].warningTimeout)))}function I(e){const n=f[e];return[e,"8",n.sizeWidth,n.log,"32",n.enablePublicMethods,n.autoResize,n.bodyMargin,n.heightCalculationMethod,n.bodyBackground,n.bodyPadding,n.tolerance,n.inPageLinks,"child",n.widthCalculationMethod,n.mouseEvents,n.offsetHeight,n.offsetWidth,n.sizeHeight,h.version].join(":")}let k=0;const x=e=>n=>{function o(e){if(!e)return{};if("object"!=typeof e)throw new TypeError("Options is not an object");return("sizeWidth"in e||"sizeHeight"in e||"autoResize"in e)&&l(r,'\nDeprecated Optionm\n\nThe sizeWidth, sizeHeight and autoResize options have been replaced with new direction option which expects values of "vertical", "horizontal" or "horizontal".\n'),e}const r=function(i){if(i&&"string"!=typeof i)throw new TypeError("Invaild id for iFrame. Expected String");return""!==i&&i||(n.id=i=function(){let n=e?.id||m.id+k++;return null!==document.getElementById(n)&&(n+=k++),n}(),(e||{}).log),i}(n.id);r in f&&"iFrameResizer"in n?c(r,"Ignored iFrame, already setup."):(!function(e){var i;f[r]={iframe:n,firstRun:!0,remoteHost:n?.src.split("/").slice(0,3).join("/"),...m,...o(e)},function(){if("horizontal"===f[r].direction)return f[r].sizeWidth=!0,void(f[r].sizeHeight=!1);if("none"===f[r].direction)return f[r].sizeWidth=!1,f[r].sizeHeight=!1,void(f[r].autoResize=!1);if("vertical"!==f[r].direction)throw new TypeError(r,`Direction value of "${f[r].direction}" is not valid`)}(),null===f[r].postMessageTarget&&(f[r].postMessageTarget=n.contentWindow),f[r].targetOrigin=!0===f[r].checkOrigin?""===(i=f[r].remoteHost)||null!==i.match(/^(about:blank|javascript:|file:\/\/)/)?"*":i:"*"}(e),W(),function(){switch(n.style.overflow=!1===f[r]?.scrolling?"hidden":"auto",f[r]?.scrolling){case"omit":break;case!0:n.scrolling="yes";break;case!1:n.scrolling="no";break;default:n.scrolling=f[r]?f[r].scrolling:"no"}}(),function(){function e(e){const i=f[r][e];1/0!==i&&0!==i&&(n.style[e]=u(i)?`${i}px`:i)}function i(e){if(u(`min${e}`)&&u(`max${e}`)&&f[r][`min${e}`]>f[r][`max${e}`])throw new Error(`Value for min${e} can not be greater than max${e}`)}i("Height"),i("Width"),e("maxHeight"),e("minHeight"),e("maxWidth"),e("minWidth")}(),function(){const{bodyMargin:e}=f[r];"number"!=typeof e&&"0"!==e||(f[r].bodyMargin=`${e}px`)}(),function(e){const{id:o}=n;t(n,"load",(function(){T("iFrame.onload",e,o,!0),function(){const e=f[r]?.firstRun,t=f[r]?.heightCalculationMethod in i;!e&&t&&$({iframe:n,height:0,width:0,type:"init"})}()})),T("init",e,o,!0)}(I(r)),f[r]&&(f[r].iframe.iFrameResizer={close:b.bind(null,f[r].iframe),removeListeners:w.bind(null,f[r].iframe),resize:T.bind(null,"Window resize","resize",r),moveToAnchor(e){T("Move to anchor",`moveToAnchor:${e}`,r)},sendMessage(e){T("Send Message",`message:${e=JSON.stringify(e)}`,r)}}))};function M(){!1===document.hidden&&function(e,n){const i=e=>f[e]?.autoResize&&!f[e]?.firstRun;Object.keys(f).forEach((function(t){i(t)&&T(e,n,t)}))}("Tab Visible","resize")}const W=(e=>{let n=!1;return function(){return n?void 0:(n=!0,Reflect.apply(e,this,arguments))}})((()=>{t(window,"message",g),t(document,"visibilitychange",M),window.iframeParentListener=e=>g({data:e,sameDomain:!0})}));switch(!0){case void 0===window.jQuery:c("","Unable to bind to jQuery, it is not available.");break;case!window.jQuery.fn:c("","Unable to bind to jQuery, it is not fully loaded.");break;case window.jQuery.fn.iframeResize:c("","iframeResize is already assigned to jQuery.fn.");break;default:window.jQuery.fn.iframeResize=function(e){const n=x(e);return this.filter("iframe").each(n).end()},window.jQuery.fn.iFrameResize=function(e){return c("","Deprecated: Use the iframeResize method instead of iFrameResize"),this.iframeResize(e)}}}));
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "@iframe-resizer/jquery",
3
- "version": "5.0.0-alpha.1",
3
+ "version": "5.0.0-alpha.3",
4
4
  "license": "GPL-3.0",
5
- "private": false,
6
5
  "homepage": "https://iframeresizer.com",
7
6
  "author": {
8
7
  "name": "David J. Bradshaw",
@@ -18,9 +17,9 @@
18
17
  "type": "individual",
19
18
  "url": "https://github.com/davidjbradshaw/iframe-resizer/blob/master/FUNDING.md"
20
19
  },
21
- "main": "iframe-resizer.jquery.cjs.js",
22
- "module": "iframe-resizer.jquery.esm.js",
23
- "browser": "iframe-resizer.jquery.umd.js",
20
+ "main": "index.cjs.js",
21
+ "module": "index.esm.js",
22
+ "browser": "index.umd.js",
24
23
  "keywords": [
25
24
  "iFrame",
26
25
  "Resizing",
@@ -42,6 +41,6 @@
42
41
  "jquery"
43
42
  ],
44
43
  "dependencies": {
45
- "@iframe-resizer/core": "5.0.0-alpha.1"
44
+ "@iframe-resizer/core": "5.0.0-alpha.3"
46
45
  }
47
46
  }