/*! iframe resizer (iframesizer.contentwindow.min.js) - v3.6.3 - 2018-10-28 * desc: include this file in any page being loaded into an iframe * to force the iframe to resize to the content size. * requires: iframeresizer.min.js on host page. * copyright: (c) 2018 david j. bradshaw - dave@bradshaw.net * license: mit */ !function(a){"use strict";function b(){}function c(a,b,c,d){"addeventlistener"in window?a.addeventlistener(b,c,!!ia&&(d||{})):"attachevent"in window&&a.attachevent("on"+b,c)}function d(a,b,c){"removeeventlistener"in window?a.removeeventlistener(b,c,!1):"detachevent"in window&&a.detachevent("on"+b,c)}function e(a){return a.charat(0).touppercase()+a.slice(1)}function f(a){var b,c,d,e=null,f=0,g=function(){f=la(),e=null,d=a.apply(b,c),e||(b=c=null)};return function(){var h=la();f||(f=h);var i=ya-(h-f);return b=this,c=arguments,i<=0||i>ya?(e&&(cleartimeout(e),e=null),f=h,d=a.apply(b,c),e||(b=c=null)):e||(e=settimeout(g,i)),d}}function g(a){return na+"["+pa+"] "+a}function h(a){ma&&"object"==typeof window.console&&console.log(g(a))}function i(a){"object"==typeof window.console&&console.warn(g(a))}function j(){k(),h("initialising iframe ("+location.href+")"),l(),o(),n("background",x),n("padding",_),b(),t(),u(),p(),d(),v(),ja=c(),o("init","init message from host page"),ea()}function k(){function b(a){return"true"===a}var c=ia.substr(oa).split(":");pa=c[0],y=a!==c[1]?number(c[1]):y,aa=a!==c[2]?b(c[2]):aa,ma=a!==c[3]?b(c[3]):ma,ka=a!==c[4]?number(c[4]):ka,v=a!==c[6]?b(c[6]):v,z=c[7],ga=a!==c[8]?c[8]:ga,x=c[9],_=c[10],va=a!==c[11]?number(c[11]):va,ja.enable=a!==c[12]&&b(c[12]),ra=a!==c[13]?c[13]:ra,ba=a!==c[14]?c[14]:ba}function l(){function a(){var a=window.iframeresizer;h("reading data from page: "+json.stringify(a)),da="messagecallback"in a?a.messagecallback:da,ea="readycallback"in a?a.readycallback:ea,ua="targetorigin"in a?a.targetorigin:ua,ga="heightcalculationmethod"in a?a.heightcalculationmethod:ga,ba="widthcalculationmethod"in a?a.widthcalculationmethod:ba}function b(a,b){return"function"==typeof a&&(h("setup custom "+b+"calcmethod"),ga[b]=a,a="custom"),a}"iframeresizer"in window&&object===window.iframeresizer.constructor&&(a(),ga=b(ga,"height"),ba=b(ba,"width")),h("targetorigin for parent set to: "+ua)}function m(a,b){return-1!==b.indexof("-")&&(i("negative css value ignored for "+a),b=""),b}function n(b,c){a!==c&&""!==c&&"null"!==c&&(document.body.style[b]=c,h("body "+b+' set to "'+c+'"'))}function o(){a===z&&(z=y+"px"),n("margin",m("margin",z))}function p(){document.documentelement.style.height="",document.body.style.height="",h('html & body height set to "auto"')}function q(a){var b={add:function(b){function d(){o(a.eventname,a.eventtype)}ha[b]=d,c(window,b,d,{passive:!0})},remove:function(a){var b=ha[a];delete ha[a],d(window,a,b)}};a.eventnames&&array.prototype.map?(a.eventname=a.eventnames[0],a.eventnames.map(b[a.method])):b[a.method](a.eventname),h(e(a.method)+" event listener: "+a.eventtype)}function r(a){q({method:a,eventtype:"animation start",eventnames:["animationstart","webkitanimationstart"]}),q({method:a,eventtype:"animation iteration",eventnames:["animationiteration","webkitanimationiteration"]}),q({method:a,eventtype:"animation end",eventnames:["animationend","webkitanimationend"]}),q({method:a,eventtype:"input",eventname:"input"}),q({method:a,eventtype:"mouse up",eventname:"mouseup"}),q({method:a,eventtype:"mouse down",eventname:"mousedown"}),q({method:a,eventtype:"orientation change",eventname:"orientationchange"}),q({method:a,eventtype:"print",eventname:["afterprint","beforeprint"]}),q({method:a,eventtype:"ready state change",eventname:"readystatechange"}),q({method:a,eventtype:"touch start",eventname:"touchstart"}),q({method:a,eventtype:"touch end",eventname:"touchend"}),q({method:a,eventtype:"touch cancel",eventname:"touchcancel"}),q({method:a,eventtype:"transition start",eventnames:["transitionstart","webkittransitionstart","mstransitionstart","otransitionstart","otransitionstart"]}),q({method:a,eventtype:"transition iteration",eventnames:["transitioniteration","webkittransitioniteration","mstransitioniteration","otransitioniteration","otransitioniteration"]}),q({method:a,eventtype:"transition end",eventnames:["transitionend","webkittransitionend","mstransitionend","otransitionend","otransitionend"]}),"child"===ra&&q({method:a,eventtype:"iframe resized",eventname:"resize"})}function s(a,b,c,d){return b!==a&&(a in c||(i(a+" is not a valid option for "+d+"calculationmethod."),a=b),h(d+' calculation method set to "'+a+'"')),a}function t(){ga=s(ga,fa,ma,"height")}function u(){ba=s(ba,aa,na,"width")}function v(){!0===v?(r("add"),g()):h("auto resize disabled")}function w(){h("disable outgoing messages"),sa=!1}function x(){h("remove event listener: message"),d(window,"message",t)}function y(){null!==$&&$.disconnect()}function z(){r("remove"),y(),clearinterval(la)}function a(){w(),x(),!0===v&&z()}function b(){var a=document.createelement("div");a.style.clear="both",a.style.display="block",document.body.appendchild(a)}function c(){function b(){return{x:window.pagexoffset!==a?window.pagexoffset:document.documentelement.scrollleft,y:window.pageyoffset!==a?window.pageyoffset:document.documentelement.scrolltop}}function d(a){var c=a.getboundingclientrect(),d=b();return{x:parseint(c.left,10)+parseint(d.x,10),y:parseint(c.top,10)+parseint(d.y,10)}}function e(b){function c(a){var b=d(a);h("moving to in page link (#"+e+") at x: "+b.x+" y: "+b.y),s(b.y,b.x,"scrolltooffset")}var e=b.split("#")[1]||b,f=decodeuricomponent(e),g=document.getelementbyid(f)||document.getelementsbyname(f)[0];a!==g?c(g):(h("in page link (#"+e+") not found in iframe, so sending to parent"),s(0,0,"inpagelink","#"+e))}function f(){""!==location.hash&&"#"!==location.hash&&e(location.href)}function g(){function a(a){function b(a){a.preventdefault(),e(this.getattribute("href"))}"#"!==a.getattribute("href")&&c(a,"click",b)}array.prototype.foreach.call(document.queryselectorall('a[href^="#"]'),a)}function j(){c(window,"hashchange",f)}function k(){settimeout(f,ca)}function l(){array.prototype.foreach&&document.queryselectorall?(h("setting up location.hash handlers"),g(),j(),k()):i("in page linking not fully supported in this browser! (see readme.md for ie8 workaround)")}return ja.enable?l():h("in page linking not enabled"),{findtarget:e}}function d(){h("enable public methods"),ca.parentiframe={autoresize:function(a){return!0===a&&!1===v?(v=!0,v()):!1===a&&!0===v&&(v=!1,z()),v},close:function(){s(0,0,"close"),a()},getid:function(){return pa},getpageinfo:function(a){"function"==typeof a?(fa=a,s(0,0,"pageinfo")):(fa=function(){},s(0,0,"pageinfostop"))},movetoanchor:function(a){ja.findtarget(a)},reset:function(){r("parentiframe.reset")},scrollto:function(a,b){s(b,a,"scrollto")},scrolltooffset:function(a,b){s(b,a,"scrolltooffset")},sendmessage:function(a,b){s(0,0,"message",json.stringify(a),b)},setheightcalculationmethod:function(a){ga=a,t()},setwidthcalculationmethod:function(a){ba=a,u()},settargetorigin:function(a){h("set targetorigin: "+a),ua=a},size:function(a,b){o("size","parentiframe.size("+(a||"")+(b?","+b:"")+")",a,b)}}}function e(){0!==ka&&(h("setinterval: "+ka+"ms"),la=setinterval(function(){o("interval","setinterval: "+ka)},math.abs(ka)))}function f(){function b(a){function b(a){!1===a.complete&&(h("attach listeners to "+a.src),a.addeventlistener("load",f,!1),a.addeventlistener("error",g,!1),k.push(a))}"attributes"===a.type&&"src"===a.attributename?b(a.target):"childlist"===a.type&&array.prototype.foreach.call(a.target.queryselectorall("img"),b)}function c(a){k.splice(k.indexof(a),1)}function d(a){h("remove listeners from "+a.src),a.removeeventlistener("load",f,!1),a.removeeventlistener("error",g,!1),c(a)}function e(b,c,e){d(b.target),o(c,e+": "+b.target.src,a,a)}function f(a){e(a,"imageload","image loaded")}function g(a){e(a,"imageloadfailed","image load failed")}function i(a){o("mutationobserver","mutationobserver: "+a[0].target+" "+a[0].type),a.foreach(b)}function j(){var a=document.queryselector("body"),b={attributes:!0,attributeoldvalue:!1,characterdata:!0,characterdataoldvalue:!1,childlist:!0,subtree:!0};return m=new l(i),h("create body mutationobserver"),m.observe(a,b),m}var k=[],l=window.mutationobserver||window.webkitmutationobserver,m=j();return{disconnect:function(){"disconnect"in m&&(h("disconnect body mutationobserver"),m.disconnect(),k.foreach(d))}}}function g(){var a=0>ka;window.mutationobserver||window.webkitmutationobserver?a?e():$=f():(h("mutationobserver not supported in this browser!"),e())}function h(a,b){function c(a){if(/^\d+(px)?$/i.test(a))return parseint(a,w);var c=b.style.left,d=b.runtimestyle.left;return b.runtimestyle.left=b.currentstyle.left,b.style.left=a||0,a=b.style.pixelleft,b.style.left=c,b.runtimestyle.left=d,a}var d=0;return b=b||document.body,"defaultview"in document&&"getcomputedstyle"in document.defaultview?(d=document.defaultview.getcomputedstyle(b,null),d=null!==d?d[a]:0):d=c(b.currentstyle[a]),parseint(d,w)}function i(a){a>ya/2&&(ya=2*a,h("event throttle increased to "+ya+"ms"))}function j(a,b){for(var c=b.length,d=0,f=0,g=e(a),i=la(),j=0;jf&&(f=d);return i=la()-i,h("parsed "+c+" html elements"),h("element position calculated in "+i+"ms"),i(i),f}function k(a){return[a.bodyoffset(),a.bodyscroll(),a.documentelementoffset(),a.documentelementscroll()]}function l(a,b){function c(){return i("no tagged elements ("+b+") found on page"),document.queryselectorall("body *")}var d=document.queryselectorall("["+b+"]");return 0===d.length&&c(),j(a,d)}function m(){return document.queryselectorall("body *")}function n(b,c,d,e){function f(){ea=m,za=n,s(ea,za,b)}function g(){function b(a,b){return!(math.abs(a-b)<=va)}return m=a!==d?d:ma[ga](),n=a!==e?e:na[ba](),b(ea,m)||aa&&b(za,n)}function i(){return!(b in{init:1,interval:1,size:1})}function j(){return ga in qa||aa&&ba in qa}function k(){h("no change in size detected")}function l(){i()&&j()?r(c):b in{interval:1}||k()}var m,n;g()||"init"===b?(p(),f()):l()}function o(a,b,c,d){function e(){a in{reset:1,resetpage:1,init:1}||h("trigger event: "+b)}function f(){return wa&&a in ba}f()?h("trigger event cancelled: "+a):(e(),"init"===a?n(a,b,c,d):oa(a,b,c,d))}function p(){wa||(wa=!0,h("trigger event lock on")),cleartimeout(xa),xa=settimeout(function(){wa=!1,h("trigger event lock off"),h("--")},ca)}function q(a){ea=ma[ga](),za=na[ba](),s(ea,za,a)}function r(a){var b=ga;ga=fa,h("reset trigger event: "+a),p(),q("reset"),ga=b}function s(b,c,d,e,f){function g(){a===f?f=ua:h("message targetorigin: "+f)}function i(){var g=b+":"+c,i=pa+":"+g+":"+d+(a!==e?":"+e:"");h("sending message to host page ("+i+")"),ta.postmessage(na+i,f)}!0===sa&&(g(),i())}function t(a){function b(){return na===(""+a.data).substr(0,oa)}function c(){return a.data.split("]")[1].split(":")[0]}function d(){return a.data.substr(a.data.indexof(":")+1)}function e(){return!("undefined"!=typeof module&&module.exports)&&"iframeresize"in window||"jquery"in window&&"iframeresize"in window.jquery.prototype}function f(){return a.data.split(":")[2]in{true:1,false:1}}function g(){var b=c();b in l?l[b]():e()||f()||i("unexpected message ("+a.data+")")}function k(){!1===da?g():f()?l.init():h('ignored message of type "'+c()+'". received before initialization.')}var l={init:function(){ia=a.data,ta=a.source,j(),da=!1,settimeout(function(){ha=!1},ca)},reset:function(){ha?h("page reset ignored by init"):(h("page size reset by host page"),q("resetpage"))},resize:function(){o("resizeparent","parent window requested size check")},movetoanchor:function(){ja.findtarget(d())},inpagelink:function(){this.movetoanchor()},pageinfo:function(){var a=d();h("pageinfofromparent called from parent: "+a),fa(json.parse(a)),h(" --")},message:function(){var a=d();h("messagecallback called from parent: "+a),da(json.parse(a)),h(" --")}};b()&&k()}function u(){"loading"!==document.readystate&&window.parent.postmessage("[iframeresizerchild]ready","*")}if("undefined"!=typeof window){var v=!0,w=10,x="",y=0,z="",$=null,_="",aa=!1,ba={resize:1,click:1},ca=128,da=!0,ea=1,fa="bodyoffset",ga=fa,ha=!0,ia="",ja={},ka=32,la=null,ma=!1,na="[iframesizer]",oa=na.length,pa="",qa={max:1,min:1,bodyscroll:1,documentelementscroll:1},ra="child",sa=!0,ta=window.parent,ua="*",va=0,wa=!1,xa=null,ya=16,za=1,aa="scroll",ba=aa,ca=window,da=function(){i("messagecallback function not defined")},ea=function(){},fa=function(){},ga={height:function(){return i("custom height calculation function not defined"),document.documentelement.offsetheight},width:function(){return i("custom width calculation function not defined"),document.body.scrollwidth}},ha={},ia=!1,ja=!1;try{var ka=object.create({},{passive:{get:function(){ia=!0}},once:{get:function(){ja=!0}}});window.addeventlistener("test",b,ka),window.removeeventlistener("test",b,ka)}catch(pa){}var la=date.now||function(){return(new date).gettime()},ma={bodyoffset:function(){return document.body.offsetheight+h("margintop")+h("marginbottom")},offset:function(){return ma.bodyoffset()},bodyscroll:function(){return document.body.scrollheight},custom:function(){return ga.height()},documentelementoffset:function(){return document.documentelement.offsetheight},documentelementscroll:function(){return document.documentelement.scrollheight},max:function(){return math.max.apply(null,k(ma))},min:function(){return math.min.apply(null,k(ma))},grow:function(){return ma.max()},lowestelement:function(){return math.max(ma.bodyoffset()||ma.documentelementoffset(),j("bottom",m()))},taggedelement:function(){return l("bottom","data-iframe-height")}},na={bodyscroll:function(){return document.body.scrollwidth},bodyoffset:function(){return document.body.offsetwidth},custom:function(){return ga.width()},documentelementscroll:function(){return document.documentelement.scrollwidth},documentelementoffset:function(){return document.documentelement.offsetwidth},scroll:function(){return math.max(na.bodyscroll(),na.documentelementscroll())},max:function(){return math.max.apply(null,k(na))},min:function(){return math.min.apply(null,k(na))},rightmostelement:function(){return j("right",m())},taggedelement:function(){return l("right","data-iframe-width")}},oa=f(n);c(window,"message",t),c(window,"readystatechange",u),u()}}(); //# sourcemappingurl=iframeresizer.contentwindow.map