/* iFrame Resizer (iframeSizer.min.js ) - v3.5.0 - 2015-10-26 Desc: Force cross domain iframes to size to content. Requires: iframeResizer.contentWindow.min.js to be loaded into the target frame. Copyright: (c) 2015 David J. Bradshaw - dave@bradshaw.net License: MIT */ !function(h){function z(a,c,g){"addEventListener"in h?a.addEventListener(c,g,!1):"attachEvent"in h&&a.attachEvent("on"+c,g)}function ha(a,c,g){"removeEventListener"in h?a.removeEventListener(c,g,!1):"detachEvent"in h&&a.detachEvent("on"+c,g)}function ia(){var a,c=["moz","webkit","o","ms"];for(a=0;aw&&(w=p,m(f,"Set "+d+" to min value"));w>n&&(w=n,m(f,"Set "+d+" to max value"));q[d]=""+w}function r(){function d(){function w(){var A=0,F=!1;for(m(f,"Checking connection is from allowed list of origins: "+p);Ab[k]["max"+v])throw Error("Value for min"+v+" can not be greater than max"+v);}t("Height");t("Width");l("maxHeight");l("minHeight");l("maxWidth");l("minWidth")}function e(){Function.prototype.bind&&(b[k].iframe.iFrameResizer= {close:Y.bind(null,b[k].iframe),resize:y.bind(null,"Window resize","resize",b[k].iframe),moveToAnchor:function(l){y("Move to anchor","inPageLink:"+l,b[k].iframe,k)},sendMessage:function(l){l=JSON.stringify(l);y("Send Message","message:"+l,b[k].iframe,k)}})}function r(l){z(a,"load",function(){y("iFrame.onload",l,a);var t=b[k].heightCalculationMethod in oa;!b[k].firstRun&&t&&aa({iframe:a,height:0,width:0,type:"init"})});y("init",l,a)}function B(l){l=l||{};b[k]={firstRun:!0,iframe:a,remoteHost:a.src.split("/").slice(0, 3).join("/")};if("object"!=typeof l)throw new TypeError("Options is not an object");for(var t in K)K.hasOwnProperty(t)&&(b[k][t]=l.hasOwnProperty(t)?l[t]:K[t]);t=b[k];!0===b[k].checkOrigin?(l=b[k].remoteHost,l=""===l||"file://"===l?"*":l):l="*";t.targetOrigin=l}var k=function(l){if(""===l){var t=c&&c.id||K.id+da++;l=(null!==document.getElementById(t)&&(t+=da++),t);a.id=l;H=(c||{}).log;m(l,"Added missing iframe ID: "+l+" ("+a.src+")")}return l}(a.id);k in b&&"iFrameResizer"in a?E(k,"Ignored iFrame, already setup."): (B(c),m(k,"IFrame scrolling "+(b[k].scrolling?"enabled":"disabled")+" for "+k),a.style.overflow=!1===b[k].scrolling?"hidden":"auto",a.scrolling=!1===b[k].scrolling?"no":"yes",g(),("number"==typeof b[k].bodyMargin||"0"===b[k].bodyMargin)&&(b[k].bodyMarginV1=b[k].bodyMargin,b[k].bodyMargin=""+b[k].bodyMargin+"px"),r(X(k)),e())}function J(a,c){null===N&&(N=setTimeout(function(){N=null;a()},c))}function na(){function a(){for(var r in b)null===b[r].iframe.offsetParent||"0px"!==b[r].iframe.style.height&& "0px"!==b[r].iframe.style.width||y("Visibility change","resize",b[r].iframe,r)}function c(r){m("window","Mutation observed: "+r[0].target+" "+r[0].type);J(a,16)}function g(){var r=document.querySelector("body");(new e(c)).observe(r,{attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0})}var e=h.MutationObserver||h.WebKitMutationObserver;e&&g()}function O(a){m("window","Trigger event: "+a);J(function(){ea("Window "+a,"resize")},16)}function fa(){function a(){ea("Tab Visable", "resize")}"hidden"!==document.visibilityState&&(m("document","Trigger event: Visiblity change"),J(a,16))}function ea(a,c){for(var g in b)"parent"===b[g].resizeFrom&&b[g].autoResize&&!b[g].firstRun&&y(a,c,document.getElementById(g),g)}function pa(){z(h,"message",ja);z(h,"resize",function(){O("resize")});z(document,"visibilitychange",fa);z(document,"-webkit-visibilitychange",fa);z(h,"focusin",function(){O("focus")});z(h,"focus",function(){O("focus")})}function P(){function a(g,e){if(e){if(!e.tagName)throw new TypeError("Object is not a valid DOM element"); if("IFRAME"!==e.tagName.toUpperCase())throw new TypeError("Expected \x3cIFRAME\x3e tag, found \x3c"+e.tagName+"\x3e");ca(e,g);c.push(e)}}var c;return ia(),pa(),function(g,e){switch(c=[],typeof e){case "undefined":case "string":Array.prototype.forEach.call(document.querySelectorAll(e||"iframe"),a.bind(void 0,g));break;case "object":a(g,e);break;default:throw new TypeError("Unexpected data type ("+typeof e+")");}return c}}function qa(a){a.fn.iFrameResize=function(c){return this.filter("iframe").each(function(g, e){ca(e,c)}).end()}}var da=0,H=!1,ba=!1,Z=7,I="[iFrameSizer]",L=I.length,u=null,D=h.requestAnimationFrame,oa={max:1,scroll:1,bodyScroll:1,documentElementScroll:1},b={},N=null,K={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,tolerance:0, widthCalculationMethod:"scroll",closedCallback:function(){},initCallback:function(){},messageCallback:function(){E("MessageCallback function not defined")},resizedCallback:function(){},scrollCallback:function(){return!0}};h.jQuery&&qa(jQuery);"function"==typeof define&&define.amd?define([],P):"object"==typeof module&&"object"==typeof module.exports?module.exports=P():h.iFrameResize=h.iFrameResize||P()}(window||{});