Skip to content

Instantly share code, notes, and snippets.

@benlienart
Created January 10, 2019 09:50
Show Gist options
  • Save benlienart/fc9a8761a09a8550a37b8fd8c12e1fac to your computer and use it in GitHub Desktop.
Save benlienart/fc9a8761a09a8550a37b8fd8c12e1fac to your computer and use it in GitHub Desktop.
!function(i){var t={};function o(e){if(t[e])return t[e].exports;var n=t[e]={i:e,l:!1,exports:{}};return i[e].call(n.exports,n,n.exports,o),n.l=!0,n.exports}o.m=i,o.c=t,o.d=function(e,n,i){o.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:i})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(n,e){if(1&e&&(n=o(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var i=Object.create(null);if(o.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var t in n)o.d(i,t,function(e){return n[e]}.bind(null,t));return i},o.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(n,"a",n),n},o.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},o.p="",o(o.s=0)}([function(e,n,i){var t,o,r;o=[i(1)],void 0===(r="function"==typeof(t=function(e){"use strict";var n,i,t=(n=e)&&n.__esModule?n:{default:n},r=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var i=arguments[n];for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&(e[t]=i[t])}return e},o=function(){function t(e,n){for(var i=0;i<n.length;i++){var t=n[i];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}();i=function(){function a(e,n){var i,t,o,r=this;!function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,a),this.iframeResizeLoaded=!1,r.iframeResizeLoaded=!0,i="\n html.pledg-modal-open.pledg-non-inline body {\n overflow: hidden;\n position: fixed;\n height: 100%;\n }\n\n #pledg-iframe {\n border: 0;\n display: block;\n width: 100%;\n border: 0;\n box-shadow: 1px 2px 7px rgba(0, 0, 0, 0.1);\n border-radius: 5px;\n background: #FFF;\n min-height: 200px;\n }\n html.pledg-small #pledg-iframe {\n min-height: 120px;\n max-width: 400px;\n }\n\n #pledg-iframe.ios {\n height: 100vh;\n }\n\n #pledg-iframe-wrapper {\n display: none;\n position: relative;\n }\n #pledg-iframe-wrapper.ios {\n -webkit-overflow-scrolling: touch;\n height: 100vh;\n }\n\n .pledg-iframe-close {\n position: absolute;\n top: 10px;\n right: 10px;\n text-align: center;\n position: absolute;\n top: 25px;\n right: 10px;\n z-index: 1000;\n cursor: pointer;\n color: #e41a13;\n background: #ffff;\n font-size: 32px;\n border-radius: 50%;\n width: 25px;\n height: 25px;\n line-height: 25px;\n border: 2px solid #e41a13;\n }\n\n html.pledg-inline.pledg-modal-open #pledg-iframe-wrapper {\n display: block;\n width: 100%;\n }\n\n html.pledg-non-inline #pledg-iframe-wrapper {\n z-index: 10000;\n max-width: 600px;\n -webkit-box-flex: 1;\n -ms-flex: 1 1;\n flex: 1 1;\n margin: auto;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n }\n\n html.pledg-non-inline.pledg-small #pledg-iframe-wrapper {\n max-width: 400px;\n }\n\n html.pledg-non-inline.pledg-modal-open .pledg-iframe-overlay {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n }\n\n .pledg-iframe-overlay {\n z-index: 10000;\n display: none;\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n padding: 20px;\n overflow: auto;\n background: rgba(0, 0, 0, 0.25);\n -webkit-overflow-scrolling: touch;\n }",t=document.getElementsByTagName("head")[0],(o=document.createElement("style")).setAttribute("type","text/css"),o.styleSheet?o.styleSheet.cssText=i:o.appendChild(document.createTextNode(i)),t.appendChild(o),this.buildIframe(),this.buildIframeClose(),this.configure(n),this.button=this.buildButton(e),this.attachEvents(),this.closingTimeout=null}return o(a,[{key:"configure",value:function(e){this.has_invalid_request_error=!1;var n=document.getElementsByTagName("html")[0];this.options=r({iframeBaseUrl:"https://front.ecard.pledg.co",containerElement:null,amountCents:null,merchantId:null,onSuccess:null,onCancel:function(){},onError:console.error,onOpen:function(){},onClose:function(){},title:null,subtitle:null,pspAuthorizationId:null,email:null,reference:null,currency:null,singlePage:!1,products:null,lang:null,first_name:null,last_name:null,address:{street:null,city:null,state_province:null,zipcode:null,country:null},confirm:!1},this.options,e),this.options.containerElement&&!this.options.confirm?(this.destroyIframeOverlay(),this.iframeWrapper&&this.iframeWrapper.parentNode!==this.options.containerElement&&this.options.containerElement.appendChild(this.iframeWrapper)):(this.buildIframeOverlay(),this.iframeWrapper&&this.iframeWrapper.parentNode!==this.options.iframeOverlay&&this.iframeOverlay.appendChild(this.iframeWrapper)),this.iframeSrc=this.options.iframeBaseUrl,this.options.confirm?(this.iframeSrc+="/userConfirmation",this.iframeClose.style.visibility="hidden",n.classList.add("pledg-small")):(this.iframeClose.style.visibility="visible",n.classList.remove("pledg-small")),this.iframeSrc+="/?embeded=1",this.options.singlePage&&(this.iframeSrc+="&single_page=1"),this.options.merchantId&&(this.iframeSrc+="&merchant_uid="+encodeURIComponent(this.options.merchantId)),this.options.amountCents&&(this.iframeSrc+="&amount_cents="+encodeURIComponent(this.options.amountCents)),this.options.title&&(this.iframeSrc+="&title="+encodeURIComponent(this.options.title)),this.options.subtitle&&(this.iframeSrc+="&subtitle="+encodeURIComponent(this.options.subtitle)),this.options.pspAuthorizationId&&(this.iframeSrc+="&psp_authorization_id="+encodeURIComponent(this.options.pspAuthorizationId)),this.options.email&&(this.iframeSrc+="&email="+encodeURIComponent(this.options.email)),this.options.currency&&(this.iframeSrc+="&currency="+encodeURIComponent(this.options.currency)),this.options.reference&&(this.iframeSrc+="&reference="+encodeURIComponent(this.options.reference)),this.options.products&&Array.isArray(this.options.products)&&(this.iframeSrc+="&products="+encodeURIComponent(JSON.stringify(this.options.products))),this.options.lang&&(this.iframeSrc+="&lang="+encodeURIComponent(this.options.lang)),this.options.first_name&&(this.iframeSrc+="&first_name="+encodeURIComponent(this.options.first_name)),this.options.last_name&&(this.iframeSrc+="&last_name="+encodeURIComponent(this.options.last_name)),this.options.address.street&&(this.iframeSrc+="&address_street="+encodeURIComponent(this.options.address.street)),this.options.address.city&&(this.iframeSrc+="&address_city="+encodeURIComponent(this.options.address.city)),this.options.address.state_province&&(this.iframeSrc+="&address_state_province="+encodeURIComponent(this.options.address.state_province)),this.options.address.zipcode&&(this.iframeSrc+="&address_zipcode="+encodeURIComponent(this.options.address.zipcode)),this.options.address.country&&(this.iframeSrc+="&address_country="+encodeURIComponent(this.options.address.country));for(var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t="",o=0;o<5;o++)t+=i.charAt(Math.floor(Math.random()*i.length));this.iframeSrc+="&"+t,this.iframe.src=this.iframeSrc}},{key:"destroyIframeOverlay",value:function(){this.iframeOverlay&&this.iframeOverlay.parentNode&&this.iframeOverlay.parentNode.removeChild(this.iframeOverlay)}},{key:"buildIframeOverlay",value:function(){this.iframeOverlay||(this.iframeOverlay=document.createElement("div"),this.iframeOverlay.className="pledg-iframe-overlay",this.iframeOverlay.id="pledg-iframe-overlay",document.getElementsByTagName("body")[0].appendChild(this.iframeOverlay))}},{key:"buildIframe",value:function(){this.iframe=document.createElement("iframe"),this.iframe.id="pledg-iframe",this.iframeWrapper=document.createElement("div"),this.iframeWrapper.id="pledg-iframe-wrapper",this.iframeWrapper.className="pledg-iframe-wrapper",this.iframeWrapper.appendChild(this.iframe)}},{key:"buildIframeClose",value:function(){var e=this;this.iframeClose=document.createElement("div"),this.iframeClose.innerHTML="&times;",this.iframeClose.className="pledg-iframe-close",this.iframeClose.addEventListener("click",function(){e.iframe.contentWindow.postMessage({name:"PLEDG_ASK_TO_CLOSE"},"*"),e.iframeClose.style.visibility="hidden",e.closingTimeout=setTimeout(function(){e.closeIframe()},300)}),this.iframeWrapper.appendChild(this.iframeClose)}},{key:"buildButton",value:function(e){return e.addEventListener("click",this.handleButtonClick.bind(this)),e}},{key:"handleButtonClick",value:function(){this.openIframe()}},{key:"closeIframe",value:function(){var e=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];this.options.onClose();var n=document.getElementsByTagName("html")[0];n.classList.remove("pledg-modal-open","pledg-inline","pledg-non-inline"),e&&(this.iframe.src=this.iframeSrc)}},{key:"openIframe",value:function(){if(this.iframe.contentWindow.postMessage({name:"PLEDG_START"},"*"),this.options.onOpen(),!this.has_invalid_request_error){var e=document.getElementsByTagName("html")[0];this.options.containerElement&&!this.options.confirm?e.classList.add("pledg-modal-open","pledg-inline"):e.classList.add("pledg-modal-open","pledg-non-inline"),(0,t.default)({log:!1,scrolling:!0,checkOrigin:!1},"#pledg-iframe"),this.iframe.iFrameResizer.resize()}}},{key:"attachEvents",value:function(){var o=this,e=window.addEventListener?"addEventListener":"attachEvent",n=window[e],i="attachEvent"==e?"onmessage":"message";n(i,function(e){if(e.data&&e.origin===o.options.iframeBaseUrl)if(console.log(e.data),"SCROLL_TOP"===e.data.name)document.getElementById("pledg-iframe-overlay")&&(document.getElementById("pledg-iframe-overlay").scrollTop=0),window.scrollBy(0,document.getElementById("pledg-iframe-wrapper").getBoundingClientRect().y-70);else if("VIRTUAL_CARD_SUCCESS"===e.data.name){var n=e.data.payload.virtualCard;o.options.onSuccess(n),o.iframeClose.style.visibility="visible",o.closeIframe()}else if("PLEDG_ERROR"===e.data.name){var i=e.data.payload.error;"invalid_request_error"==i.type&&(o.has_invalid_request_error=!0),o.options.onError(i),o.closeIframe(!1)}else if("CANCEL_CLOSE"==e.data.name)o.iframeClose.style.visibility="visible";else if("PLEDG_WAIT"===e.data.name)clearTimeout(o.closingTimeout);else if("PLEDG_CANCEL"===e.data.name)o.iframeClose.style.visibility="visible",o.closeIframe(),o.options.onCancel();else if("PLEDG_SHARE_PAYMENT"===e.data.name){var t=document.getElementsByTagName("html")[0];t.classList.remove("pledg-non-inline"),t.classList.add("pledg-inline"),o.configure({confirm:!1})}},!1)}}]),a}(),window.Pledg=i})?t.apply(n,o):t)||(e.exports=r)},function(e,q,n){var D,V,G;V=[e],void 0===(G="function"==typeof(D=function(w){"use strict";var H="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(c){if("undefined"!=typeof window){var e,f=0,u=!1,o=!1,C="message".length,x="[iFrameSizer]",I=x.length,k=null,t=window.requestAnimationFrame,m={max:1,scroll:1,bodyScroll:1,documentElementScroll:1},E={},i=null,p={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",closedCallback:function(){},initCallback:function(){},messageCallback:function(){z("MessageCallback function not defined")},resizedCallback:function(){},scrollCallback:function(){return!0}},S={};window.jQuery&&((e=window.jQuery).fn?e.fn.iFrameResize||(e.fn.iFrameResize=function(i){function e(e,n){d(n,i)}return this.filter("iframe").each(e).end()}):_("","Unable to bind to jQuery, it is not fully loaded.")),V=[],(G="function"==typeof(D=function(){function i(e,n){function i(){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+">")}n&&(i(),d(n,e),o.push(n))}function t(e){e&&e.enablePublicMethods&&z("enablePublicMethods option has been removed, public methods are now always available in the iFrame")}var o;return n(),O(window,"message",l),O(window,"resize",function(){y("resize")}),O(document,"visibilitychange",b),O(document,"-webkit-visibilitychange",b),O(window,"focusin",function(){y("focus")}),O(window,"focus",function(){y("focus")}),function(e,n){switch(o=[],t(e),void 0===n?"undefined":H(n)){case"undefined":case"string":Array.prototype.forEach.call(document.querySelectorAll(n||"iframe"),i.bind(c,e));break;case"object":i(e,n);break;default:throw new TypeError("Unexpected data type ("+(void 0===n?"undefined":H(n))+")")}return o}})?D.apply(q,V):D)===c||(w.exports=G)}function O(e,n,i){"addEventListener"in window?e.addEventListener(n,i,!1):"attachEvent"in window&&e.attachEvent("on"+n,i)}function R(e,n,i){"removeEventListener"in window?e.removeEventListener(n,i,!1):"detachEvent"in window&&e.detachEvent("on"+n,i)}function n(){var e,n=["moz","webkit","o","ms"];for(e=0;e<n.length&&!t;e+=1)t=window[n[e]+"RequestAnimationFrame"];t||T("setup","RequestAnimationFrame not supported")}function r(e){return x+"["+(i="Host page: "+(n=e),window.top!==window.self&&(i=window.parentIFrame&&window.parentIFrame.getId?window.parentIFrame.getId()+": "+n:"Nested host page: "+n),i)+"]";var n,i}function a(e){return E[e]?E[e].log:u}function T(e,n){s("log",e,n,a(e))}function _(e,n){s("info",e,n,a(e))}function z(e,n){s("warn",e,n,!0)}function s(e,n,i,t){!0===t&&"object"===H(window.console)&&console[e](r(n),i)}function l(n){function i(){e("Height"),e("Width"),B(function(){A(v),N(w),f("resizedCallback",v)},v,"init")}function e(e){var n=Number(E[w]["max"+e]),i=Number(E[w]["min"+e]),t=e.toLowerCase(),o=Number(v[t]);T(w,"Checking "+t+" is in range "+i+"-"+n),o<i&&(o=i,T(w,"Set "+t+" to min value")),n<o&&(o=n,T(w,"Set "+t+" to max value")),v[t]=""+o}function t(e){return b.substr(b.indexOf(":")+C+e)}function a(i,t){var e,n,o;e=function(){var e,n;U("Send Page Info","pageInfo:"+(e=document.body.getBoundingClientRect(),n=v.iframe.getBoundingClientRect(),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})),i,t)},n=32,S[o=t]||(S[o]=setTimeout(function(){S[o]=null,e()},n))}function o(){function e(n,i){function t(){E[r]?a(E[r].iframe,r):o()}["scroll","resize"].forEach(function(e){T(r,n+e+" listener for sendPageInfo"),i(window,e,t)})}function o(){e("Remove ",R)}var r=w;e("Add ",O),E[r]&&(E[r].stopPageInfo=o)}function r(){E[w]&&E[w].stopPageInfo&&(E[w].stopPageInfo(),delete E[w].stopPageInfo)}function s(e){var n=e.getBoundingClientRect();return L(w),{x:Math.floor(Number(n.left)+Number(k.x)),y:Math.floor(Number(n.top)+Number(k.y))}}function l(e){var n=e?s(v.iframe):{x:0,y:0},i={x:Number(v.width)+n.x,y:Number(v.height)+n.y};T(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):z(w,"Unable to scroll to requested position, window.parentIFrame not found"):(k=i,d(),T(w,"--"))}function d(){!1!==f("scrollCallback",k)?N(w):P()}function c(e){var n,i=e.split("#")[1]||"",t=decodeURIComponent(i),o=document.getElementById(t)||document.getElementsByName(t)[0];o?(n=s(o),T(w,"Moving to in page link (#"+i+") at x: "+n.x+" y: "+n.y),k={x:n.x,y:n.y},d(),T(w,"--")):window.top!==window.self?window.parentIFrame?window.parentIFrame.moveToAnchor(i):T(w,"In page link #"+i+" not found and window.parentIFrame not found"):T(w,"In page link #"+i+" not found")}function f(e,n){return M(w,e,n)}function u(){E[w]&&(E[w].firstRun=!1)}var m,p,h,g,y,b=n.data,v={},w=null;"[iFrameResizerChild]Ready"===b?function(){for(var e in E)U("iFrame requested init",j(e),document.getElementById(e),e)}():x===(""+b).substr(0,I)&&b.substr(I).split(":")[0]in E?(m=b.substr(I).split(":"),v={iframe:E[m[0]]&&E[m[0]].iframe,id:m[0],height:m[1],width:m[2],type:m[3]},w=v.id,E[w]&&(E[w].loaded=!0),(y=v.type in{true:1,false:1,undefined:1})&&T(w,"Ignoring init message from meta parent page"),!y&&(g=!0,E[h=w]||(g=!1,z(v.type+" No settings for "+h+". Message was: "+b)),g)&&(T(w,"Received: "+b),p=!0,null===v.iframe&&(z(w,"IFrame ("+v.id+") not found"),p=!1),p&&function(){function e(){function e(){var e=0,n=!1;for(T(w,"Checking connection is from allowed list of origins: "+t);e<t.length;e++)if(t[e]===i){n=!0;break}return n}return t.constructor===Array?e():(n=E[w]&&E[w].remoteHost,T(w,"Checking connection is from: "+n),i===n);var n}var i=n.origin,t=E[w]&&E[w].checkOrigin;if(!t||""+i=="null"||e())return!0;throw new Error("Unexpected message received from: "+i+" for "+v.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.")}()&&function(){switch(E[w]&&E[w].firstRun&&u(),v.type){case"close":E[w].closeRequestCallback?M(w,"closeRequestCallback",E[w].iframe):F(v.iframe);break;case"message":e=t(6),T(w,"MessageCallback passed: {iframe: "+v.iframe.id+", message: "+e+"}"),f("messageCallback",{iframe:v.iframe,message:JSON.parse(e)}),T(w,"--");break;case"scrollTo":l(!1);break;case"scrollToOffset":l(!0);break;case"pageInfo":a(E[w]&&E[w].iframe,w),o();break;case"pageInfoStop":r();break;case"inPageLink":c(t(9));break;case"reset":W(v);break;case"init":i(),f("initCallback",v.iframe);break;default:i()}var e}())):_(w,"Ignored: "+b)}function M(e,n,i){var t=null,o=null;if(E[e]){if("function"!=typeof(t=E[e][n]))throw new TypeError(n+" on iFrame["+e+"] is not a function");o=t(i)}return o}function h(e){var n=e.id;delete E[n]}function F(e){var n=e.id;T(n,"Removing iFrame: "+n);try{e.parentNode&&e.parentNode.removeChild(e)}catch(e){}M(n,"closedCallback",n),T(n,"--"),h(e)}function L(e){null===k&&(k={x:window.pageXOffset!==c?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==c?window.pageYOffset:document.documentElement.scrollTop},T(e,"Get page position: "+k.x+","+k.y))}function N(e){null!==k&&(window.scrollTo(k.x,k.y),T(e,"Set page position: "+k.x+","+k.y),P())}function P(){k=null}function W(e){T(e.id,"Size reset requested by "+("init"===e.type?"host page":"iFrame")),L(e.id),B(function(){A(e),U("reset","reset",e.iframe,e.id)},e,"reset")}function A(n){function i(e){o||"0"!==n[e]||(o=!0,T(t,"Hidden iFrame detected, creating visibility listener"),function(){function n(){function e(n){function e(e){return"0px"===(E[n]&&E[n].iframe.style[e])}E[n]&&null!==E[n].iframe.offsetParent&&(e("height")||e("width"))&&U("Visibility change","resize",E[n].iframe,n)}for(var n in E)e(n)}function e(e){T("window","Mutation observed: "+e[0].target+" "+e[0].type),g(n,16)}var i,t,o=window.MutationObserver||window.WebKitMutationObserver;o&&(i=document.querySelector("body"),t={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0},new o(e).observe(i,t))}())}function e(e){!function(e){if(!n.id)return T("undefined","messageData id not set");n.iframe.style[e]=n[e]+"px",T(n.id,"IFrame ("+t+") "+e+" set to "+n[e]+"px")}(e),i(e)}var t=n.iframe.id;E[t]&&(E[t].sizeHeight&&e("height"),E[t].sizeWidth&&e("width"))}function B(e,n,i){i!==n.type&&t?(T(n.id,"Requesting animation frame"),t(e)):e()}function U(e,n,i,t,o){var r,a=!1;t=t||i.id,E[t]&&(i&&"contentWindow"in i&&null!==i.contentWindow?(r=E[t]&&E[t].targetOrigin,T(t,"["+e+"] Sending msg to iframe["+t+"] ("+n+") targetOrigin: "+r),i.contentWindow.postMessage(x+n,r)):z(t,"["+e+"] IFrame("+t+") not found"),function(){function e(){!E[t]||E[t].loaded||a||(a=!0,z(t,"IFrame has not responded within "+E[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."))}o&&E[t]&&E[t].warningTimeout&&(E[t].msgTimeout=setTimeout(e,E[t].warningTimeout))}())}function j(e){return e+":"+E[e].bodyMarginV1+":"+E[e].sizeWidth+":"+E[e].log+":"+E[e].interval+":"+E[e].enablePublicMethods+":"+E[e].autoResize+":"+E[e].bodyMargin+":"+E[e].heightCalculationMethod+":"+E[e].bodyBackground+":"+E[e].bodyPadding+":"+E[e].tolerance+":"+E[e].inPageLinks+":"+E[e].resizeFrom+":"+E[e].widthCalculationMethod}function d(i,n){function e(){var e=n&&n.id||p.id+f++;return null!==document.getElementById(e)&&(e+=f++),e}function t(){var e=E[d]&&E[d].firstRun,n=E[d]&&E[d].heightCalculationMethod in m;!e&&n&&W({iframe:i,height:0,width:0,type:"init"})}function o(e){if("object"!==(void 0===e?"undefined":H(e)))throw new TypeError("Options is not an object")}function r(e){for(var n in p)p.hasOwnProperty(n)&&(E[d][n]=e.hasOwnProperty(n)?e[n]:p[n])}var a,s,l,d=(""===(l=i.id)&&(i.id=l=e(),u=(n||{}).log,T(l,"Added missing iframe ID: "+l+" ("+i.src+")")),l);d in E&&"iFrameResizer"in i?z(d,"Ignored iFrame, already setup."):(a=(a=n)||{},E[d]={firstRun:!0,iframe:i,remoteHost:i.src.split("/").slice(0,3).join("/")},o(a),r(a),E[d]&&(E[d].targetOrigin=!0===E[d].checkOrigin?""===(s=E[d].remoteHost)||"file://"===s?"*":s:"*"),function(){switch(T(d,"IFrame scrolling "+(E[d]&&E[d].scrolling?"enabled":"disabled")+" for "+d),i.style.overflow=!1===(E[d]&&E[d].scrolling)?"hidden":"auto",E[d]&&E[d].scrolling){case"omit":break;case!0:i.scrolling="yes";break;case!1:i.scrolling="no";break;default:i.scrolling=E[d]?E[d].scrolling:"no"}}(),function(){function e(e){1/0!==E[d][e]&&0!==E[d][e]&&(i.style[e]=E[d][e]+"px",T(d,"Set "+e+" = "+E[d][e]+"px"))}function n(e){if(E[d]["min"+e]>E[d]["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(E[d]&&E[d].bodyMargin)&&"0"!==(E[d]&&E[d].bodyMargin)||(E[d].bodyMarginV1=E[d].bodyMargin,E[d].bodyMargin=E[d].bodyMargin+"px"),function(e){function n(){U("iFrame.onload",e,i,c,!0),t()}O(i,"load",n),U("init",e,i,c,!0)}(j(d)),Function.prototype.bind&&E[d]&&(E[d].iframe.iFrameResizer={close:F.bind(null,E[d].iframe),removeListeners:h.bind(null,E[d].iframe),resize:U.bind(null,"Window resize","resize",E[d].iframe),moveToAnchor:function(e){U("Move to anchor","moveToAnchor:"+e,E[d].iframe,d)},sendMessage:function(e){U("Send Message","message:"+(e=JSON.stringify(e)),E[d].iframe,d)}}))}function g(e,n){null===i&&(i=setTimeout(function(){i=null,e()},n))}function y(e){T("window","Trigger event: "+e),g(function(){v("Window "+e,"resize")},16)}function b(){"hidden"!==document.visibilityState&&(T("document","Trigger event: Visiblity change"),g(function(){v("Tab Visable","resize")},16))}function v(e,n){for(var i in E)E[t=i]&&"parent"===E[t].resizeFrom&&E[t].autoResize&&!E[t].firstRun&&U(e,n,document.getElementById(i),i);var t}}()})?D.apply(q,V):D)||(e.exports=G)}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment