Skip to content

Beautiful Open-Source Form Builder

14.0 KB
Raw Blame
/* eslint-disable */
"use strict";(function(x){var W,C,j,P,T,I,h,M,$,e,A,S,B,U;function G(){return window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver}function N(n,t,d){n.addEventListener(t,d,!1)}function me(n,t,d){n.removeEventListener(t,d,!1)}function K(n){return e[n]?e[n].log:C}function u(n,t){V("log",n,t,K(n))}function Z(n,t){V("info",n,t,K(n))}function z(n,t){V("warn",n,t,!0)}function V(n,t,d,r){var m,i;r===!0&&typeof window.console=="object"&&console[n](T+"["+(i="Host page: "+(m=t),i=window.top!==window.self?window.parentIFrame&&window.parentIFrame.getId?window.parentIFrame.getId()+": "+m:"Nested host page: "+m:i)+"]",d)}function ge(n){function t(){d("Height"),d("Width"),ae(function(){re(l),ie(o),a("onResized",l)},l,"init")}function d(y){var f=Number(e[o]["max"+y]),s=Number(e[o]["min"+y]),y=y.toLowerCase(),p=Number(l[y]);u(o,"Checking "+y+" is in range "+s+"-"+f),p<s&&(p=s,u(o,"Set "+y+" to min value")),f<p&&(p=f,u(o,"Set "+y+" to max value")),l[y]=""+p}function r(b){return k.slice(k.indexOf(":")+P+b)}function m(b,f){var s,y,p;s=function(){var v,R;F("Send Page Info","pageInfo:"+(v=document.body.getBoundingClientRect(),JSON.stringify({iframeHeight:(R=l.iframe.getBoundingClientRect()).height,iframeWidth:R.width,clientHeight:Math.max(document.documentElement.clientHeight,window.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,window.innerWidth||0),offsetTop:parseInt(R.top-v.top,10),offsetLeft:parseInt(R.left-v.left,10),scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,documentHeight:document.documentElement.clientHeight,documentWidth:document.documentElement.clientWidth,windowHeight:window.innerHeight,windowWidth:window.innerWidth})),b,f)},y=32,B[p=f]||(B[p]=setTimeout(function(){B[p]=null,s()},y))}function i(b){return b=b.getBoundingClientRect(),ne(o),{x:Math.floor(Number(b.left)+Number(h.x)),y:Math.floor(Number(b.top)+Number(h.y))}}function w(b){var f=b?i(l.iframe):{x:0,y:0},s={x:Number(l.width)+f.x,y:Number(l.height)+f.y};u(o,"Reposition requested from iFrame (offset x:"+f.x+" y:"+f.y+")"),window.top===window.self?(h=s,O(),u(o,"--")):window.parentIFrame?window.parentIFrame["scrollTo"+(b?"Offset":"")](s.x,s.y):z(o,"Unable to scroll to requested position, window.parentIFrame not found")}function O(){a("onScroll",h)===!1?te():ie(o)}function c(b){var f,s={};s=Number(l.width)===0&&Number(l.height)===0?{x:(f=r(9).split(":"))[1],y:f[0]}:{x:l.width,y:l.height},a(b,{iframe:l.iframe,screenX:Number(s.x),screenY:Number(s.y),type:l.type})}function a(b,f){return D(o,b,f)}var g,E,q,Y,H,L,k=n.data,l={},o=null;if(k==="[iFrameResizerChild]Ready")for(var Q in e)F("iFrame requested init",se(Q),e[Q].iframe,Q);else T===(""+k).slice(0,I)&&k.slice(I).split(":")[0]in e?(e[o=(l=(E=(g=k.slice(I).split(":"))[1]?parseInt(g[1],10):0,Y=getComputedStyle(q=e[g[0]]&&e[g[0]].iframe),{iframe:q,id:g[0],height:E+function(s){if(s.boxSizing!=="border-box")return 0;var f=s.paddingTop?parseInt(s.paddingTop,10):0,s=s.paddingBottom?parseInt(s.paddingBottom,10):0;return f+s}(Y)+function(s){if(s.boxSizing!=="border-box")return 0;var f=s.borderTopWidth?parseInt(s.borderTopWidth,10):0,s=s.borderBottomWidth?parseInt(s.borderBottomWidth,10):0;return f+s}(Y),width:g[2],type:g[3]})).id]&&(e[o].loaded=!0),(L=l.type in{true:1,false:1,undefined:1})&&u(o,"Ignoring init message from meta parent page"),!L&&(L=!0,e[H=o]||(L=!1,z(l.type+" No settings for "+H+". Message was: "+k)),L)&&(u(o,"Received: "+k),H=!0,l.iframe===null&&(z(o,"IFrame ("+l.id+") not found"),H=!1),H&&function(){var f=n.origin,s=e[o]&&e[o].checkOrigin;if(s&&""+f!="null"&&!function(){if(s.constructor!==Array)return y=e[o]&&e[o].remoteHost,u(o,"Checking connection is from: "+y),f===y;var y,p=0,v=!1;for(u(o,"Checking connection is from allowed list of origins: "+s);p<s.length;p++)if(s[p]===f){v=!0;break}return v}())throw Error("Unexpected message received from: "+f+" for "+l.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 1}()&&function(){var f,s,y,p,v;switch(e[o]&&e[o].firstRun&&e[o]&&(e[o].firstRun=!1),l.type){case"close":_(l.iframe);break;case"message":s=r(6),u(o,"onMessage passed: {iframe: "+l.iframe.id+", message: "+s+"}"),a("onMessage",{iframe:l.iframe,message:JSON.parse(s)}),u(o,"--");break;case"mouseenter":c("onMouseEnter");break;case"mouseleave":c("onMouseLeave");break;case"autoResize":e[o].autoResize=JSON.parse(r(9));break;case"scrollTo":w(!1);break;case"scrollToOffset":w(!0);break;case"pageInfo":m(e[o]&&e[o].iframe,o),f=o,R("Add ",N),e[f]&&(e[f].stopPageInfo=fe);break;case"pageInfoStop":e[o]&&e[o].stopPageInfo&&(e[o].stopPageInfo(),delete e[o].stopPageInfo);break;case"inPageLink":r(9),v=decodeURIComponent(p=p.split("#")[1]||""),(v=document.getElementById(v)||document.getElementsByName(v)[0])?(v=i(v),u(o,"Moving to in page link (#"+p+") at x: "+v.x+" y: "+v.y),h={x:v.x,y:v.y},O(),u(o,"--")):window.top===window.self?u(o,"In page link #"+p+" not found"):window.parentIFrame?window.parentIFrame.moveToAnchor(p):u(o,"In page link #"+p+" not found and window.parentIFrame not found");break;case"reset":oe(l);break;case"init":t(),a("onInit",l.iframe);break;default:Number(l.width)===0&&Number(l.height)===0?z("Unsupported message received ("+l.type+"), this is likely due to the iframe containing a later version of iframe-resizer than the parent page"):t()}function R(he,pe){function we(){e[f]?m(e[f].iframe,f):fe()}["scroll","resize"].forEach(function(le){u(f,he+le+" listener for sendPageInfo"),pe(window,le,we)})}function fe(){R("Remove ",me)}}())):Z(o,"Ignored: "+k)}function D(n,t,d){var r=null,m=null;if(e[n]){if(typeof(r=e[n][t])!="function")throw TypeError(t+" on iFrame["+n+"] is not a function");m=r(d)}return m}function ee(n){delete e[n=n.id]}function _(n){var t=n.id;if(D(t,"onClose",t)===!1)u(t,"Close iframe cancelled by onClose event");else{u(t,"Removing iFrame: "+t);try{n.parentNode&&n.parentNode.removeChild(n)}catch(d){z(d)}D(t,"onClosed",t),u(t,"--"),ee(n)}}function ne(n){h===null&&u(n,"Get page position: "+(h={x:window.pageXOffset===x?document.documentElement.scrollLeft:window.pageXOffset,y:window.pageYOffset===x?document.documentElement.scrollTop:window.pageYOffset}).x+","+h.y)}function ie(n){h!==null&&(window.scrollTo(h.x,h.y),u(n,"Set page position: "+h.x+","+h.y),te())}function te(){h=null}function oe(n){u(n.id,"Size reset requested by "+(n.type==="init"?"host page":"iFrame")),ne(n.id),ae(function(){re(n),F("reset","reset",n.iframe,n.id)},n,"reset")}function re(n){function t(r){var m;m=r,n.id?(n.iframe.style[m]=n[m]+"px",u(n.id,"IFrame ("+d+") "+m+" set to "+n[m]+"px")):u("undefined","messageData id not set"),function(w){var O;function c(){Object.keys(e).forEach(function(a){var g;function E(q){return(e[g]&&e[g].iframe.style[q])==="0px"}e[g=a]&&e[g].iframe.offsetParent!==null&&(E("height")||E("width"))&&F("Visibility change","resize",e[g].iframe,g)})}!j&&n[w]==="0"&&(j=!0,u(d,"Hidden iFrame detected, creating visibility listener"),w=G())&&(O=document.querySelector("body"),new w(function(g){u("window","Mutation observed: "+g[0].target+" "+g[0].type),J(c,16)}).observe(O,{attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0}))}(r)}var d=n.iframe.id;e[d]&&(e[d].sizeHeight&&t("height"),e[d].sizeWidth)&&t("width")}function ae(n,t,d){d!==t.type&&M&&!window.jasmine?(u(t.id,"Requesting animation frame"),M(n)):n()}function F(n,t,d,r,m){var i,w=!1;e[r=r||d.id]&&(d&&"contentWindow"in d&&d.contentWindow!==null?(i=e[r]&&e[r].targetOrigin,u(r,"["+n+"] Sending msg to iframe["+r+"] ("+t+") targetOrigin: "+i),d.contentWindow.postMessage(T+t,i)):z(r,"["+n+"] IFrame("+r+") not found"),m&&e[r]&&e[r].warningTimeout&&(e[r].msgTimeout=setTimeout(function(){!e[r]||e[r].loaded||w||(w=!0,z(r,"IFrame has not responded within "+e[r].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."))},e[r].warningTimeout)))}function se(n){return n+":"+e[n].bodyMarginV1+":"+e[n].sizeWidth+":"+e[n].log+":"+e[n].interval+":"+e[n].enablePublicMethods+":"+e[n].autoResize+":"+e[n].bodyMargin+":"+e[n].heightCalculationMethod+":"+e[n].bodyBackground+":"+e[n].bodyPadding+":"+e[n].tolerance+":"+e[n].inPageLinks+":"+e[n].resizeFrom+":"+e[n].widthCalculationMethod+":"+e[n].mouseEvents}function de(n,t){function d(c){var a=c.split("Callback");a.length===2&&(this[a="on"+a[0].charAt(0).toUpperCase()+a[0].slice(1)]=this[c],delete this[c],z(i,"Deprecated: '"+c+"' has been renamed '"+a+"'. The old method will be removed in the next major version."))}var r,m,i=function(c){var a;if(typeof c!="string")throw TypeError("Invaild id for iFrame. Expected String");return c===""&&(n.id=(a=t&&t.id||S.id+W++,document.getElementById(a)!==null&&(a+=W++),c=a),C=(t||{}).log,u(c,"Added missing iframe ID: "+c+" ("+n.src+")")),c}(n.id);if(i in e&&"iFrameResizer"in n)z(i,"Ignored iFrame, already setup.");else{switch(function(a){if(a=a||{},e[i]=Object.create(null),e[i].iframe=n,e[i].firstRun=!0,e[i].remoteHost=n.src&&n.src.split("/").slice(0,3).join("/"),typeof a!="object")throw TypeError("Options is not an object");Object.keys(a).forEach(d,a);var g,E=a;for(g in S)Object.prototype.hasOwnProperty.call(S,g)&&(e[i][g]=(Object.prototype.hasOwnProperty.call(E,g)?E:S)[g]);e[i]&&(e[i].targetOrigin=e[i].checkOrigin!==!0||(a=e[i].remoteHost)===""||a.match(/^(about:blank|javascript:|file:\/\/)/)!==null?"*":a)}(t),u(i,"IFrame scrolling "+(e[i]&&e[i].scrolling?"enabled":"disabled")+" for "+i),n.style.overflow=(e[i]&&e[i].scrolling)===!1?"hidden":"auto",e[i]&&e[i].scrolling){case"omit":break;case!0:n.scrolling="yes";break;case!1:n.scrolling="no";break;default:n.scrolling=e[i]?e[i].scrolling:"no"}O("Height"),O("Width"),w("maxHeight"),w("minHeight"),w("maxWidth"),w("minWidth"),typeof(e[i]&&e[i].bodyMargin)!="number"&&(e[i]&&e[i].bodyMargin)!=="0"||(e[i].bodyMarginV1=e[i].bodyMargin,e[i].bodyMargin=e[i].bodyMargin+"px"),r=se(i),(m=G())&&n.parentNode&&new m(function(c){c.forEach(function(a){Array.prototype.slice.call(a.removedNodes).forEach(function(g){g===n&&_(n)})})}).observe(n.parentNode,{childList:!0}),N(n,"load",function(){var c,a;F("iFrame.onload",r,n,x,!0),c=e[i]&&e[i].firstRun,a=e[i]&&e[i].heightCalculationMethod in $,!c&&a&&oe({iframe:n,height:0,width:0,type:"init"})}),F("init",r,n,x,!0),e[i]&&(e[i].iframe.iFrameResizer={close:_.bind(null,e[i].iframe),removeListeners:ee.bind(null,e[i].iframe),resize:F.bind(null,"Window resize","resize",e[i].iframe),moveToAnchor:function(c){F("Move to anchor","moveToAnchor:"+c,e[i].iframe,i)},sendMessage:function(c){F("Send Message","message:"+(c=JSON.stringify(c)),e[i].iframe,i)}})}function w(c){var a=e[i][c];a!==1/0&&a!==0&&(n.style[c]=typeof a=="number"?a+"px":a,u(i,"Set "+c+" = "+n.style[c]))}function O(c){if(e[i]["min"+c]>e[i]["max"+c])throw Error("Value for min"+c+" can not be greater than max"+c)}}function J(n,t){A===null&&(A=setTimeout(function(){A=null,n()},t))}function ce(){document.visibilityState!=="hidden"&&(u("document","Trigger event: Visibility change"),J(function(){ue("Tab Visible","resize")},16))}function ue(n,t){Object.keys(e).forEach(function(d){var r;e[r=d]&&e[r].resizeFrom==="parent"&&e[r].autoResize&&!e[r].firstRun&&F(n,t,e[d].iframe,d)})}function X(){function n(m,i){if(i){if(!i.tagName)throw TypeError("Object is not a valid DOM element");if(i.tagName.toUpperCase()!=="IFRAME")throw TypeError("Expected <IFRAME> tag, found <"+i.tagName+">");de(i,m),t.push(i)}}for(var t,d=["moz","webkit","o","ms"],r=0;r<d.length&&!M;r+=1)M=window[d[r]+"RequestAnimationFrame"];return M?M=M.bind(window):u("setup","RequestAnimationFrame not supported"),N(window,"message",ge),N(window,"resize",function(){var m;u("window","Trigger event: "+(m="resize")),J(function(){ue("Window "+m,"resize")},16)}),N(document,"visibilitychange",ce),N(document,"-webkit-visibilitychange",ce),function(m,i){var w;switch(t=[],(w=m)&&w.enablePublicMethods&&z("enablePublicMethods option has been removed, public methods are now always available in the iFrame"),typeof i){case"undefined":case"string":Array.prototype.forEach.call(document.querySelectorAll(i||"iframe"),n.bind(x,m));break;case"object":n(m,i);break;default:throw TypeError("Unexpected data type ("+typeof i+")")}return t}}typeof window<"u"&&(W=0,j=C=!1,P=7,I=(T="[iFrameSizer]").length,h=null,M=window.requestAnimationFrame,$=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),e={},A=null,S=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"bodyOffset",id:"iFrameResizer",interval:32,log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,mouseEvents:!0,resizeFrom:"parent",scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,widthCalculationMethod:"scroll",onClose:function(){return!0},onClosed:function(){},onInit:function(){},onMessage:function(){z("onMessage function not defined")},onMouseEnter:function(){},onMouseLeave:function(){},onResized:function(){},onScroll:function(){return!0}}),B={},window.jQuery!==x&&((U=window.jQuery).fn?U.fn.iFrameResize||(U.fn.iFrameResize=function(n){return this.filter("iframe").each(function(t,d){de(d,n)}).end()}):Z("","Unable to bind to jQuery, it is not fully loaded.")),typeof define=="function"&&define.amd?define([],X):typeof module=="object"&&typeof module.exports=="object"&&(module.exports=X()),window.iFrameResize=window.iFrameResize||X())})();function initEmbed(x,W={}){if(!x)return;const{autoResize:C=!0}=W||{};function j(){return document.getElementById(x)}function P(I){try{return I?.src?new URL(I.src,window.location.href).origin:null}catch{return null}}function T(I){const h=j(),M=P(h);return!!h&&I.source===h.contentWindow&&(!M||I.origin===M)}window.addEventListener("message",function(I){I.data?.type!=="form-submitted"||I.data?.form?.slug!==x||T(I)&&I.data?.form?.redirect_target_url&&(window.top.location.href=I.data.form.redirect_target_url)}),C&&document.addEventListener("DOMContentLoaded",function(){iFrameResize({log:!1},"#"+x)})}