@iframe-resizer/jquery 5.0.0-alpha.7 → 5.0.0-alpha.9
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 +1 -1
- package/index.cjs.js +1 -1
- package/index.esm.js +1 -1
- package/index.umd.js +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
package/index.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @preserve
|
|
3
3
|
*
|
|
4
|
-
* @module iframe-resizer/jquery 5.0.0-alpha.
|
|
4
|
+
* @module iframe-resizer/jquery 5.0.0-alpha.9 (cjs) - 2024-04-24
|
|
5
5
|
*
|
|
6
6
|
* @license GPL-3.0 for non-commercial use only.
|
|
7
7
|
* For commercial use, you must purchase a license from
|
package/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @preserve
|
|
3
3
|
*
|
|
4
|
-
* @module iframe-resizer/jquery 5.0.0-alpha.
|
|
4
|
+
* @module iframe-resizer/jquery 5.0.0-alpha.9 (esm) - 2024-04-24
|
|
5
5
|
*
|
|
6
6
|
* @license GPL-3.0 for non-commercial use only.
|
|
7
7
|
* For commercial use, you must purchase a license from
|
package/index.umd.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @preserve
|
|
3
3
|
*
|
|
4
|
-
* @module iframe-resizer/jquery 5.0.0-alpha.
|
|
4
|
+
* @module iframe-resizer/jquery 5.0.0-alpha.9 (umd) - 2024-04-24
|
|
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="5.0.0-alpha.7",n="[iFrameSizer]",i=n.length,t=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),o=(e,n,i,t)=>e.addEventListener(n,i,t||!1),r=(e,n,i)=>e.removeEventListener(n,i,!1),s="[iframeResizer]";const a=e=>`${s}[${function(e){return window.top===window.self?`Host page: ${e}`:window?.parentIFrame?.getId?`${window.parentIFrame.getId()}: ${e}`:`Nested host page: ${e}`}(e)}]`,d=(e,n,...i)=>window?.console[e](a(n),...i),c=(e,...n)=>d("info",e,...n),l=(e,...n)=>d("warn",e,...n),u=(e,n)=>window?.console.warn(((e,...n)=>[`${s}[${e}]`,...n].join(" "))(e,window.chrome?n:n.replaceAll(/\u001B\[[\d;]*m/gi,""))),f=e=>!Number.isNaN(e),m=e=>{if(!e)return"";let n=-559038744,i=1103547984;for(let t,o=0;o<e.length;o++)t=e.codePointAt(o),n=Math.imul(n^t,2246822519),i=Math.imul(i^t,3266489917);return n^=Math.imul(n^i>>>15,1935289751),i^=Math.imul(i^n>>>15,3405138345),n^=i>>>16,i^=n>>>16,(2097152*(i>>>0)+(n>>>11)).toString(36)},h={},g=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:"vertical",inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"auto",id:"iFrameResizer",log:!0,license:void 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 h[e.id].onInit&&(u(e.id,"\n[31;1mDeprecated Option[m\n\nThe [1monInit()[m function is deprecated and has been replaced with [1monReady()[m. It will be removed in a future version of iFrame Resizer.\n "),h[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),p={position:null,version:e};function w(e){function t(){d("Height"),d("Width"),I(B),R(),L("onResized",B)}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 d(e){const n=Number(h[D][`max${e}`]),i=Number(h[D][`min${e}`]),t=e.toLowerCase();let o=Number(B[t]);o<i&&(o=i),o>n&&(o=n),B[t]=`${o}`}function u(e){return j.slice(j.indexOf(":")+7+e)}const f=(e,n)=>(i,t)=>{const o={};var r,s;r=function(){k(`Send ${e} (${i})`,`${e}:${n()}`,t)},o[s=t]||(r(),o[s]=requestAnimationFrame((()=>{o[s]=null})))},m=(e,n)=>()=>{const i=n=>()=>{h[a]?e(n,a):s()};function t(e,n){n(window,"scroll",i("scroll")),n(window,"resize",i("resize window"))}function s(){t(0,r),d.disconnect()}const a=D,d=new ResizeObserver(i("iframe observed"));t(0,o),d.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),h[a]&&(h[a][`stop${n}`]=s)},g=e=>()=>{e in h[D]&&(h[D][e](),delete h[D][e])},w=f("pageInfo",(function(){const e=document.body.getBoundingClientRect(),n=B.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})})),y=f("parentInfo",(function(){const{iframe:e}=B,{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}})})),x=m(w,"PageInfo"),N=m(y,"ParentInfo"),H=g("stopPageInfo"),E=g("stopParentInfo");function F(e){const n=e.getBoundingClientRect();return v(),{x:Math.floor(Number(n.left)+Number(p.position.x)),y:Math.floor(Number(n.top)+Number(p.position.y))}}function O(e){const n=e?F(B.iframe):{x:0,y:0};let i=((e,n)=>({x:Number(e.width)+n.x,y:Number(e.height)+n.y}))(B,n);window.top===window.self?(p.position=i,S()):window.parentIFrame?window.parentIFrame["scrollTo"+(e?"Offset":"")](i.x,i.y):l(D,"Unable to scroll to requested position, window.parentIFrame not found")}function S(){!1!==L("onScroll",p.position)?R():$()}function C(e){let n={};if(0===Number(B.width)&&0===Number(B.height)){const e=u(9).split(":");n={x:e[1],y:e[0]}}else n={x:B.width,y:B.height};L(e,{iframe:B.iframe,screenX:Number(n.x),screenY:Number(n.y),type:B.type})}const L=(e,n)=>b(D,e,n);let j=e.data,B={},D=null;"[iFrameResizerChild]Ready"!==j?n===`${j}`.slice(0,i)&&j.slice(i).split(":")[0]in h?(B=function(){const e=j.slice(i).split(":"),n=e[1]?Number(e[1]):0,t=h[e[0]]?.iframe,o=getComputedStyle(t);return{iframe:t,id:e[0],height:n+s(o)+a(o),width:Number(e[2]),type:e[3]}}(),D=B.id,D?(function(e){if(!h[e])throw new Error(`${B.type} No settings for ${e}. Message was: ${j}`)}(D),B.type in{true:1,false:1,undefined:1}||(h[D].loaded=!0,function(){let e=!0;return null===B.iframe&&(l(D,`The iframe (${B.id}) was not found.`),e=!1),e}()&&function(){const{origin:n,sameDomain:i}=e;if(i)return!0;let t=h[D]?.checkOrigin;if(t&&"null"!=`${n}`&&!(t.constructor===Array?function(){let e=0,i=!1;for(;e<t.length;e++)if(t[e]===n){i=!0;break}return i}():function(){const e=h[D]?.remoteHost;return n===e}()))throw new Error(`Unexpected message received from: ${n} for ${B.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(h[D]?.firstRun&&h[D]&&(h[D].firstRun=!1),B.type){case"close":z(B.iframe);break;case"message":e=u(6),L("onMessage",{iframe:B.iframe,message:JSON.parse(e)});break;case"mouseenter":C("onMouseEnter");break;case"mouseleave":C("onMouseLeave");break;case"autoResize":h[D].autoResize=JSON.parse(u(9));break;case"scrollTo":O(!1);break;case"scrollToOffset":O(!0);break;case"pageInfo":w("start",D),x();break;case"parentInfo":y("start",D),N();break;case"pageInfoStop":H();break;case"parentInfoStop":E();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=F(t);p.position={x:e.x,y:e.y},S()}():window.top!==window.self&&window.parentIFrame&&window.parentIFrame.moveToAnchor(n)}(u(9));break;case"reset":T(B);break;case"init":t(),function(e){try{h[e].sameDomain=!!h[e]?.iframe?.contentWindow?.iframeChildListener}catch(n){h[e].sameDomain=!1}}(D),W=!0,L("onReady",B.iframe);break;default:if(0===B.width&&0===B.height)return void l(`Unsupported message received (${B.type}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===B.width||0===B.height)return;if(document.hidden)return;t()}var e}())):l("iframeResizer received messageData without id, message was: ",j)):c(D,`Ignored: ${j}`):Object.keys(h).forEach((e=>k("iFrame requested init",M(e),e)))}function b(e,n,i){let t=null,o=null;if(h[e]){if(t=h[e][n],"function"!=typeof t)throw new TypeError(`${n} on iFrame[${e}] is not a function`);o=t(i)}return o}function y(e){const n=e.id;delete h[n]}function z(e){const n=e.id;if(!1!==b(n,"onClose",n)){try{e.parentNode&&e.remove()}catch(e){l(e)}b(n,"onClosed",n),y(e)}}function v(e){null===p.position&&(p.position={x:window.scrollX,y:window.scrollY})}function $(){p.position=null}function R(e){null!==p.position&&(window.scrollTo(p.position.x,p.position.y),$())}function T(e){v(e.id),I(e),k("reset","reset",e.id)}function I(e){const n=e.id;function i(n){const i=`${e[n]}px`;e.iframe.style[n]=i}h[n].sizeHeight&&i("height"),h[n].sizeWidth&&i("width")}function k(e,i,t,o){h[t]&&(h[t]?.postMessageTarget?function(){const{postMessageTarget:e,targetOrigin:o}=h[t];if(h[t].sameDomain)try{return void h[t].iframe.contentWindow.iframeChildListener(n+i)}catch(e){c(t,"Same domain connection failed. Trying cross domain"),h[t].sameDomain=!1}e.postMessage(n+i,o)}():l(t,`[${e}] IFrame(${t}) not found`),o&&h[t]?.warningTimeout&&(h[t].msgTimeout=setTimeout((function(){void 0!==h[t]&&(h[t].loaded||h[t].loadErrorShown||(h[t].loadErrorShown=!0,u(t,`\n[31;1mNo response from iFrame[m\n \nThe iframe ([3m${t}[m) has not responded within ${h[t].warningTimeout/1e3} seconds. Check [1m@iframe-resizer/child[m package has been loaded in the iframe.\n\nThis message can be ignored if everything is working, or you can set the [1mwarningTimeout[m option to a higher value or zero to suppress this warning.\n`)))}),h[t].warningTimeout)))}function M(e){const n=h[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,m(n.license),p.version].join(":")}let x=0,W=!1;const N=n=>i=>{function r(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)&&u(s,'\n[31;1mDeprecated Optionm\n\nThe [1msizeWidth[m, [1msizeHeight[m and [1mautoResize[m options have been replaced with new [1mdirection[m option which expects values of [3m"vertical"[m, [3m"horizontal"[m or [3m"horizontal"[m.\n'),e}const s=function(e){if(e&&"string"!=typeof e)throw new TypeError("Invaild id for iFrame. Expected String");return""!==e&&e||(i.id=e=function(){let e=n?.id||g.id+x++;return null!==document.getElementById(e)&&(e+=x++),e}(),(n||{}).log),e}(i.id);return s in h&&"iFrameResizer"in i?l(s,"Ignored iFrame, already setup."):(c(`v${e}`),u(i.id,"[31;1mAlpha Release[m\n \nDo not use in production, API is not stable."),function(e){var n;h[s]={iframe:i,firstRun:!0,remoteHost:i?.src.split("/").slice(0,3).join("/"),...g,...r(e)},function(){if("horizontal"===h[s].direction)return h[s].sizeWidth=!0,void(h[s].sizeHeight=!1);if("none"===h[s].direction)return h[s].sizeWidth=!1,h[s].sizeHeight=!1,void(h[s].autoResize=!1);if("vertical"!==h[s].direction)throw new TypeError(s,`Direction value of "${h[s].direction}" is not valid`)}(),null===h[s].postMessageTarget&&(h[s].postMessageTarget=i.contentWindow),h[s].targetOrigin=!0===h[s].checkOrigin?""===(n=h[s].remoteHost)||null!==n.match(/^(about:blank|javascript:|file:\/\/)/)?"*":n:"*"}(n),E(),function(){switch(i.style.overflow=!1===h[s]?.scrolling?"hidden":"auto",h[s]?.scrolling){case"omit":break;case!0:i.scrolling="yes";break;case!1:i.scrolling="no";break;default:i.scrolling=h[s]?h[s].scrolling:"no"}}(),function(){function e(e){const n=h[s][e];1/0!==n&&0!==n&&(i.style[e]=f(n)?`${n}px`:n)}function n(e){if(f(`min${e}`)&&f(`max${e}`)&&h[s][`min${e}`]>h[s][`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")}(),function(){const{bodyMargin:e}=h[s];"number"!=typeof e&&"0"!==e||(h[s].bodyMargin=`${e}px`)}(),function(e){const{id:n}=i;o(i,"load",(function(){k("iFrame.onload",`${e}:${W}`,n,!0),function(){const e=h[s]?.firstRun,n=h[s]?.heightCalculationMethod in t;!e&&n&&T({iframe:i,height:0,width:0,type:"init"})}()})),k("init",`${e}:${W}`,n,!0)}(M(s)),function(){if(h[s]){const e={close:z.bind(null,h[s].iframe),disconnect:y.bind(null,h[s].iframe),removeListeners(){u(s,"\n[31;1mDeprecated Method Namem\n\nThe [removeListeners()[m method has been renamed to [disconnect()[m.\n"),this.disconnect()},resize:k.bind(null,"Window resize","resize",s),moveToAnchor(e){k("Move to anchor",`moveToAnchor:${e}`,s)},sendMessage(e){k("Send Message",`message:${e=JSON.stringify(e)}`,s)}};h[s].iframe.iframeResizer=e,h[s].iframe.iFrameResizer=e}}()),i?.iFrameResizer};function H(){!1===document.hidden&&function(e,n){const i=e=>h[e]?.autoResize&&!h[e]?.firstRun;Object.keys(h).forEach((function(t){i(t)&&k(e,n,t)}))}("Tab Visible","resize")}const E=(e=>{let n=!1;return function(){return n?void 0:(n=!0,Reflect.apply(e,this,arguments))}})((()=>{o(window,"message",w),o(document,"visibilitychange",H),window.iframeParentListener=e=>w({data:e,sameDomain:!0})}));switch(!0){case void 0===window.jQuery:l("","Unable to bind to jQuery, it is not available.");break;case!window.jQuery.fn:l("","Unable to bind to jQuery, it is not fully loaded.");break;case window.jQuery.fn.iframeResize:l("","iframeResize is already assigned to jQuery.fn.");break;default:window.jQuery.fn.iframeResize=function(e){const n=N(e);return this.filter("iframe").each(n).end()},window.jQuery.fn.iFrameResize=function(e){return l("","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="5.0.0-alpha.9",n="[iFrameSizer]",i=n.length,t=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),o=(e,n,i,t)=>e.addEventListener(n,i,t||!1),r=(e,n,i)=>e.removeEventListener(n,i,!1),s="[iframeResizer]";const a=e=>`${s}[${function(e){return window.top===window.self?`Host page: ${e}`:window?.parentIFrame?.getId?`${window.parentIFrame.getId()}: ${e}`:`Nested host page: ${e}`}(e)}]`,c=(e,n,...i)=>window?.console[e](a(n),...i),d=(e,...n)=>c("info",e,...n),l=(e,...n)=>c("warn",e,...n),u=(e,n)=>window?.console.warn(((e,...n)=>[`${s}[${e}]`,...n])(e,window.chrome?n:n.replaceAll(/\u001B\[[\d;]*m/gi,""))),f=e=>!Number.isNaN(e),m=e=>{if(!e)return"";let n=-559038744,i=1103547984;for(let t,o=0;o<e.length;o++)t=e.codePointAt(o),n=Math.imul(n^t,2246822519),i=Math.imul(i^t,3266489917);return n^=Math.imul(n^i>>>15,1935289751),i^=Math.imul(i^n>>>15,3405138345),n^=i>>>16,i^=n>>>16,(2097152*(i>>>0)+(n>>>11)).toString(36)},h={},g=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:"vertical",inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"auto",id:"iFrameResizer",log:!0,license:void 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 h[e.id].onInit&&(u(e.id,"\n[31;1mDeprecated Option[m\n\nThe [1monInit()[m function is deprecated and has been replaced with [1monReady()[m. It will be removed in a future version of iFrame Resizer.\n "),h[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),p={position:null,version:e};function w(e){function t(){c("Height"),c("Width"),k(j),R(),C("onResized",j)}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 c(e){const n=Number(h[B][`max${e}`]),i=Number(h[B][`min${e}`]),t=e.toLowerCase();let o=Number(j[t]);o<i&&(o=i),o>n&&(o=n),j[t]=`${o}`}function d(e){return L.slice(L.indexOf(":")+7+e)}const u=(e,n)=>(i,t)=>{const o={};var r,s;r=function(){I(`Send ${e} (${i})`,`${e}:${n()}`,t)},o[s=t]||(r(),o[s]=requestAnimationFrame((()=>{o[s]=null})))},f=(e,n)=>()=>{const i=n=>()=>{h[a]?e(n,a):s()};function t(e,n){n(window,"scroll",i("scroll")),n(window,"resize",i("resize window"))}function s(){t(0,r),c.disconnect()}const a=B,c=new ResizeObserver(i("iframe observed"));t(0,o),c.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),h[a]&&(h[a][`stop${n}`]=s)},m=e=>()=>{e in h[B]&&(h[B][e](),delete h[B][e])},g=u("pageInfo",(function(){const e=document.body.getBoundingClientRect(),n=j.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})})),w=u("parentInfo",(function(){const{iframe:e}=j,{scrollWidth:n,scrollHeight:i}=document.documentElement,{width:t,height:o,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:c,scale:d}=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:c,scale:d}})})),y=f(g,"PageInfo"),x=f(w,"ParentInfo"),N=m("stopPageInfo"),H=m("stopParentInfo");function E(e){const n=e.getBoundingClientRect();return v(),{x:Math.floor(Number(n.left)+Number(p.position.x)),y:Math.floor(Number(n.top)+Number(p.position.y))}}function F(e){const n=e?E(j.iframe):{x:0,y:0};let i=((e,n)=>({x:Number(e.width)+n.x,y:Number(e.height)+n.y}))(j,n);window.top===window.self?(p.position=i,O()):window.parentIFrame?window.parentIFrame["scrollTo"+(e?"Offset":"")](i.x,i.y):l(B,"Unable to scroll to requested position, window.parentIFrame not found")}function O(){!1!==C("onScroll",p.position)?R():$()}function S(e){let n={};if(0===Number(j.width)&&0===Number(j.height)){const e=d(9).split(":");n={x:e[1],y:e[0]}}else n={x:j.width,y:j.height};C(e,{iframe:j.iframe,screenX:Number(n.x),screenY:Number(n.y),type:j.type})}const C=(e,n)=>b(B,e,n);let L=e.data,j={},B=null;"[iFrameResizerChild]Ready"!==L?n===`${L}`.slice(0,i)&&L.slice(i).split(":")[0]in h&&(j=function(){const e=L.slice(i).split(":"),n=e[1]?Number(e[1]):0,t=h[e[0]]?.iframe,o=getComputedStyle(t);return{iframe:t,id:e[0],height:n+s(o)+a(o),width:Number(e[2]),type:e[3]}}(),B=j.id,B?(function(e){if(!h[e])throw new Error(`${j.type} No settings for ${e}. Message was: ${L}`)}(B),j.type in{true:1,false:1,undefined:1}||(h[B].loaded=!0,function(){let e=!0;return null===j.iframe&&(l(B,`The iframe (${j.id}) was not found.`),e=!1),e}()&&function(){const{origin:n,sameDomain:i}=e;if(i)return!0;let t=h[B]?.checkOrigin;if(t&&"null"!=`${n}`&&!(t.constructor===Array?function(){let e=0,i=!1;for(;e<t.length;e++)if(t[e]===n){i=!0;break}return i}():function(){const e=h[B]?.remoteHost;return n===e}()))throw new Error(`Unexpected message received from: ${n} for ${j.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(h[B]?.firstRun&&h[B]&&(h[B].firstRun=!1),j.type){case"close":z(j.iframe);break;case"message":e=d(6),C("onMessage",{iframe:j.iframe,message:JSON.parse(e)});break;case"mouseenter":S("onMouseEnter");break;case"mouseleave":S("onMouseLeave");break;case"autoResize":h[B].autoResize=JSON.parse(d(9));break;case"scrollTo":F(!1);break;case"scrollToOffset":F(!0);break;case"pageInfo":g("start",B),y();break;case"parentInfo":w("start",B),x();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);p.position={x:e.x,y:e.y},O()}():window.top!==window.self&&window.parentIFrame&&window.parentIFrame.moveToAnchor(n)}(d(9));break;case"reset":T(j);break;case"init":t(),function(e){try{h[e].sameDomain=!!h[e]?.iframe?.contentWindow?.iframeChildListener}catch(n){h[e].sameDomain=!1}}(B),W=!0,C("onReady",j.iframe);break;default:if(0===j.width&&0===j.height)return void l(`Unsupported message received (${j.type}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===j.width||0===j.height)return;if(document.hidden)return;t()}var e}())):l("iframeResizer received messageData without id, message was: ",L)):Object.keys(h).forEach((e=>I("iFrame requested init",M(e),e)))}function b(e,n,i){let t=null,o=null;if(h[e]){if(t=h[e][n],"function"!=typeof t)throw new TypeError(`${n} on iFrame[${e}] is not a function`);o=t(i)}return o}function y(e){const n=e.id;delete h[n]}function z(e){const n=e.id;if(!1!==b(n,"onClose",n)){try{e.parentNode&&e.remove()}catch(e){l(e)}b(n,"onClosed",n),y(e)}}function v(e){null===p.position&&(p.position={x:window.scrollX,y:window.scrollY})}function $(){p.position=null}function R(e){null!==p.position&&(window.scrollTo(p.position.x,p.position.y),$())}function T(e){v(e.id),k(e),I("reset","reset",e.id)}function k(e){const n=e.id;function i(n){const i=`${e[n]}px`;e.iframe.style[n]=i}h[n].sizeHeight&&i("height"),h[n].sizeWidth&&i("width")}function I(e,i,t,o){h[t]&&(h[t]?.postMessageTarget?function(){const{postMessageTarget:e,targetOrigin:o}=h[t];if(h[t].sameDomain)try{return void h[t].iframe.contentWindow.iframeChildListener(n+i)}catch(e){d(t,"Same domain connection failed. Trying cross domain"),h[t].sameDomain=!1}e.postMessage(n+i,o)}():l(t,`[${e}] IFrame(${t}) not found`),o&&h[t]?.warningTimeout&&(h[t].msgTimeout=setTimeout((function(){void 0!==h[t]&&(h[t].loaded||h[t].loadErrorShown||(h[t].loadErrorShown=!0,u(t,`\n[31;1mNo response from iFrame[m\n \nThe iframe ([3m${t}[m) has not responded within ${h[t].warningTimeout/1e3} seconds. Check [1m@iframe-resizer/child[m package has been loaded in the iframe.\n\nThis message can be ignored if everything is working, or you can set the [1mwarningTimeout[m option to a higher value or zero to suppress this warning.\n`)))}),h[t].warningTimeout)))}function M(e){const n=h[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,m(n.license),p.version].join(":")}let x=0,W=!1;const N=n=>i=>{function r(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)&&u(s,'\n[31;1mDeprecated Optionm\n\nThe [1msizeWidth[m, [1msizeHeight[m and [1mautoResize[m options have been replaced with new [1mdirection[m option which expects values of [3m"vertical"[m, [3m"horizontal"[m or [3m"horizontal"[m.\n'),e}const s=function(e){if(e&&"string"!=typeof e)throw new TypeError("Invaild id for iFrame. Expected String");return""!==e&&e||(i.id=e=function(){let e=n?.id||g.id+x++;return null!==document.getElementById(e)&&(e+=x++),e}(),(n||{}).log),e}(i.id);return s in h&&"iFrameResizer"in i?l(s,"Ignored iFrame, already setup."):(d(`v${e}`),u(i.id,"[31;1mAlpha Release[m\n \nDo not use in production, API is not stable."),function(e){var n;h[s]={iframe:i,firstRun:!0,remoteHost:i?.src.split("/").slice(0,3).join("/"),...g,...r(e)},function(){if("horizontal"===h[s].direction)return h[s].sizeWidth=!0,void(h[s].sizeHeight=!1);if("none"===h[s].direction)return h[s].sizeWidth=!1,h[s].sizeHeight=!1,void(h[s].autoResize=!1);if("vertical"!==h[s].direction)throw new TypeError(s,`Direction value of "${h[s].direction}" is not valid`)}(),null===h[s].postMessageTarget&&(h[s].postMessageTarget=i.contentWindow),h[s].targetOrigin=!0===h[s].checkOrigin?""===(n=h[s].remoteHost)||null!==n.match(/^(about:blank|javascript:|file:\/\/)/)?"*":n:"*"}(n),E(),function(){switch(i.style.overflow=!1===h[s]?.scrolling?"hidden":"auto",h[s]?.scrolling){case"omit":break;case!0:i.scrolling="yes";break;case!1:i.scrolling="no";break;default:i.scrolling=h[s]?h[s].scrolling:"no"}}(),function(){function e(e){const n=h[s][e];1/0!==n&&0!==n&&(i.style[e]=f(n)?`${n}px`:n)}function n(e){if(f(`min${e}`)&&f(`max${e}`)&&h[s][`min${e}`]>h[s][`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")}(),function(){const{bodyMargin:e}=h[s];"number"!=typeof e&&"0"!==e||(h[s].bodyMargin=`${e}px`)}(),function(e){const{id:n}=i;o(i,"load",(function(){I("iFrame.onload",`${e}:${W}`,n,!0),function(){const e=h[s]?.firstRun,n=h[s]?.heightCalculationMethod in t;!e&&n&&T({iframe:i,height:0,width:0,type:"init"})}()})),I("init",`${e}:${W}`,n,!0)}(M(s)),function(){if(h[s]){const e={close:z.bind(null,h[s].iframe),disconnect:y.bind(null,h[s].iframe),removeListeners(){u(s,"\n[31;1mDeprecated Method Namem\n\nThe [removeListeners()[m method has been renamed to [disconnect()[m.\n"),this.disconnect()},resize:I.bind(null,"Window resize","resize",s),moveToAnchor(e){I("Move to anchor",`moveToAnchor:${e}`,s)},sendMessage(e){I("Send Message",`message:${e=JSON.stringify(e)}`,s)}};h[s].iframe.iframeResizer=e,h[s].iframe.iFrameResizer=e}}()),i?.iFrameResizer};function H(){!1===document.hidden&&function(e,n){const i=e=>h[e]?.autoResize&&!h[e]?.firstRun;Object.keys(h).forEach((function(t){i(t)&&I(e,n,t)}))}("Tab Visible","resize")}const E=(e=>{let n=!1;return function(){return n?void 0:(n=!0,Reflect.apply(e,this,arguments))}})((()=>{o(window,"message",w),o(document,"visibilitychange",H),window.iframeParentListener=e=>w({data:e,sameDomain:!0})}));switch(!0){case void 0===window.jQuery:l("","Unable to bind to jQuery, it is not available.");break;case!window.jQuery.fn:l("","Unable to bind to jQuery, it is not fully loaded.");break;case window.jQuery.fn.iframeResize:l("","iframeResize is already assigned to jQuery.fn.");break;default:window.jQuery.fn.iframeResize=function(e){const n=N(e);return this.filter("iframe").each(n).end()},window.jQuery.fn.iFrameResize=function(e){return l("","Deprecated: Use the iframeResize method instead of iFrameResize"),this.iframeResize(e)}}}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iframe-resizer/jquery",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.9",
|
|
4
4
|
"license": "GPL-3.0",
|
|
5
5
|
"homepage": "http://iframe-resizer.com",
|
|
6
6
|
"author": {
|
|
@@ -41,6 +41,6 @@
|
|
|
41
41
|
"jquery"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@iframe-resizer/core": "5.0.0-alpha.
|
|
44
|
+
"@iframe-resizer/core": "5.0.0-alpha.9"
|
|
45
45
|
}
|
|
46
46
|
}
|