아이프레임을 크기에 맞게 호출하는 스크립트
/*! iFrame Resizer (iframeSizer.contentWindow.min.js) - v3.6.5 - 2019-02-03
* 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) 2019 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
EmoticonEmoticon