/*! iFrame Resizer (iframeSizer.min.js ) - v2.8.7 - 2015-05-19
 *  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(){"use strict";function a(a,b,c){"addEventListener"in window?a.addEventListener(b,c,!1):"attachEvent"in window&&a.attachEvent("on"+b,c)}function b(){var a,b=["moz","webkit","o","ms"];for(a=0;a<b.length&&!A;a+=1)A=window[b[a]+"RequestAnimationFrame"];A||e(" RequestAnimationFrame not supported")}function c(){var a="Host page";return window.top!==window.self&&(a=window.parentIFrame?window.parentIFrame.getId():"Nested host page"),a}function d(a){return x+"["+c()+"]"+a}function e(a){u&&"object"==typeof window.console&&console.log(d(a))}function f(a){"object"==typeof window.console&&console.warn(d(a))}function g(a){function b(){function a(){k(G),i(),C[H].resizedCallback(G)}g("Height"),g("Width"),l(a,G,"resetPage")}function c(a){var b=a.id;e(" Removing iFrame: "+b),a.parentNode.removeChild(a),C[b].closedCallback(b),delete C[b],e(" --")}function d(){var a=F.substr(y).split(":");return{iframe:document.getElementById(a[0]),id:a[0],height:a[1],width:a[2],type:a[3]}}function g(a){var b=Number(C[H]["max"+a]),c=Number(C[H]["min"+a]),d=a.toLowerCase(),f=Number(G[d]);if(c>b)throw new Error("Value for min"+a+" can not be greater than max"+a);e(" Checking "+d+" is in range "+c+"-"+b),c>f&&(f=c,e(" Set "+d+" to min value")),f>b&&(f=b,e(" Set "+d+" to max value")),G[d]=""+f}function m(){function b(){function a(){e(" Checking connection is from allowed list of origins: "+d);var a;for(a=0;a<d.length;a++)if(d[a]===c)return!0;return!1}function b(){return e(" Checking connection is from: "+f),c==f}return d.constructor===Array?a():b()}var c=a.origin,d=C[H].checkOrigin,f=G.iframe.src.split("/").slice(0,3).join("/");if(d&&""+c!="null"&&!b())throw new Error("Unexpected message received from: "+c+" for "+G.iframe.id+". Message was: "+a.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return!0}function n(){return x===(""+F).substr(0,y)}function o(){var a=G.type in{"true":1,"false":1,undefined:1};return a&&e(" Ignoring init message from meta parent page"),a}function p(a){return F.substr(F.indexOf(":")+w+a)}function q(a){e(" MessageCallback passed: {iframe: "+G.iframe.id+", message: "+a+"}"),C[H].messageCallback({iframe:G.iframe,message:JSON.parse(a)}),e(" --")}function r(){return null===G.iframe?(f(" IFrame ("+G.id+") not found"),!1):!0}function s(a){var b=a.getBoundingClientRect();return h(),{x:parseInt(b.left,10)+parseInt(z.x,10),y:parseInt(b.top,10)+parseInt(z.y,10)}}function v(a){function b(){z=g,A(),e(" --")}function c(){return{x:Number(G.width)+d.x,y:Number(G.height)+d.y}}var d=a?s(G.iframe):{x:0,y:0},g=c();e(" Reposition requested from iFrame (offset x:"+d.x+" y:"+d.y+")"),window.top!==window.self?window.parentIFrame?a?parentIFrame.scrollToOffset(g.x,g.y):parentIFrame.scrollTo(G.width,G.height):f(" Unable to scroll to requested position, window.parentIFrame not found"):b()}function A(){!1!==C[H].scrollCallback(z)&&i()}function B(a){function b(a){var b=s(a);e(" Moving to in page link (#"+c+") at x: "+b.x+" y: "+b.y),z={x:b.x,y:b.y},A(),e(" --")}var c=a.split("#")[1]||"",d=decodeURIComponent(c),f=document.getElementById(d)||document.getElementsByName(d)[0];window.top!==window.self?window.parentIFrame?parentIFrame.moveToAnchor(c):e(" In page link #"+c+" not found and window.parentIFrame not found"):f?b(f):e(" In page link #"+c+" not found")}function D(){switch(G.type){case"close":c(G.iframe);break;case"message":q(p(6));break;case"scrollTo":v(!1);break;case"scrollToOffset":v(!0);break;case"inPageLink":B(p(9));break;case"reset":j(G);break;case"init":b(),C[H].initCallback(G.iframe);break;default:b()}}function E(a){var b=!0;return C[a]||(b=!1,f(G.type+" No settings for "+a+". Message was: "+F)),b}var F=a.data,G={},H=null;n()&&(G=d(),H=G.id,!o()&&E(H)&&(u=C[H].log,e(" Received: "+F),r()&&m()&&(D(),t=!1)))}function h(){null===z&&(z={x:void 0!==window.pageXOffset?window.pageXOffset:document.documentElement.scrollLeft,y:void 0!==window.pageYOffset?window.pageYOffset:document.documentElement.scrollTop},e(" Get page position: "+z.x+","+z.y))}function i(){null!==z&&(window.scrollTo(z.x,z.y),e(" Set page position: "+z.x+","+z.y),z=null)}function j(a){function b(){k(a),m("reset","reset",a.iframe,a.id)}e(" Size reset requested by "+("init"===a.type?"host page":"iFrame")),h(),l(b,a,"init")}function k(a){function b(b){a.iframe.style[b]=a[b]+"px",e(" IFrame ("+c+") "+b+" set to "+a[b]+"px")}var c=a.iframe.id;C[c].sizeHeight&&b("height"),C[c].sizeWidth&&b("width")}function l(a,b,c){c!==b.type&&A?(e(" Requesting animation frame"),A(a)):a()}function m(a,b,c,d){c&&c.contentWindow?(e("["+a+"] Sending msg to iframe ("+b+")"),c.contentWindow.postMessage(x+b,"*")):(f("["+a+"] IFrame not found"),C[d]&&delete C[d])}function n(b){function c(){function a(a){1/0!==C[o][a]&&0!==C[o][a]&&(n.style[a]=C[o][a]+"px",e(" Set "+a+" = "+C[o][a]+"px"))}a("maxHeight"),a("minHeight"),a("maxWidth"),a("minWidth")}function d(a){return""===a&&(n.id=a="iFrameResizer"+s++,u=(b||{}).log,e(" Added missing iframe ID: "+a+" ("+n.src+")")),a}function f(){e(" IFrame scrolling "+(C[o].scrolling?"enabled":"disabled")+" for "+o),n.style.overflow=!1===C[o].scrolling?"hidden":"auto",n.scrolling=!1===C[o].scrolling?"no":"yes"}function g(){("number"==typeof C[o].bodyMargin||"0"===C[o].bodyMargin)&&(C[o].bodyMarginV1=C[o].bodyMargin,C[o].bodyMargin=""+C[o].bodyMargin+"px")}function h(){return o+":"+C[o].bodyMarginV1+":"+C[o].sizeWidth+":"+C[o].log+":"+C[o].interval+":"+C[o].enablePublicMethods+":"+C[o].autoResize+":"+C[o].bodyMargin+":"+C[o].heightCalculationMethod+":"+C[o].bodyBackground+":"+C[o].bodyPadding+":"+C[o].tolerance+":"+C[o].enableInPageLinks+":"+C[o].resizeFrom}function i(b){a(n,"load",function(){var a=t;m("iFrame.onload",b,n),!a&&C[o].heightCalculationMethod in B&&j({iframe:n,height:0,width:0,type:"init"})}),m("init",b,n)}function k(a){if("object"!=typeof a)throw new TypeError("Options is not an object.")}function l(a){a=a||{},C[o]={},k(a);for(var b in E)E.hasOwnProperty(b)&&(C[o][b]=a.hasOwnProperty(b)?a[b]:E[b]);u=C[o].log}var n=this,o=d(n.id);l(b),f(),c(),g(),i(h())}function o(a,b){null===D&&(D=setTimeout(function(){D=null,a()},b))}function p(){o(function(){for(var a in C)"parent"===C[a].resizeFrom&&m("Window resize","resize",document.getElementById(a),a)},66)}function q(){function c(a,b){if(!a.tagName)throw new TypeError("Object is not a valid DOM element");if("IFRAME"!==a.tagName.toUpperCase())throw new TypeError("Expected <IFRAME> tag, found <"+a.tagName+">.");n.call(a,b)}return b(),a(window,"message",g),a(window,"resize",p),function(a,b){switch(typeof b){case"undefined":case"string":Array.prototype.forEach.call(document.querySelectorAll(b||"iframe"),function(b){c(b,a)});break;case"object":c(b,a);break;default:throw new TypeError("Unexpected data type ("+typeof b+").")}}}function r(a){a.fn.iFrameResize=function(a){return this.filter("iframe").each(function(b,c){n.call(c,a)}).end()}}var s=0,t=!0,u=!1,v="message",w=v.length,x="[iFrameSizer]",y=x.length,z=null,A=window.requestAnimationFrame,B={max:1,scroll:1,bodyScroll:1,documentElementScroll:1},C={},D=null,E={autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,enableInPageLinks:!1,enablePublicMethods:!1,heightCalculationMethod:"offset",interval:32,log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,resizeFrom:"parent",scrolling:!1,sizeHeight:!0,sizeWidth:!1,tolerance:0,closedCallback:function(){},initCallback:function(){},messageCallback:function(){},resizedCallback:function(){},scrollCallback:function(){return!0}};window.jQuery&&r(jQuery),"function"==typeof define&&define.amd?define([],q):"object"==typeof module&&"object"==typeof module.exports?module.exports=q():window.iFrameResize=window.iFrameResize||q()}();
//# sourceMappingURL=iframeResizer.map