forked from davidjbradshaw/iframe-resizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iframeResizer.map
1 lines (1 loc) · 25.6 KB
/
iframeResizer.map
1
{"version":3,"file":"iframeResizer.min.js","sources":["../src/iframeResizer.js"],"names":["addEventListener","obj","evt","func","window","attachEvent","setupRequestAnimationFrame","x","vendors","length","requestAnimationFrame","log","getMyID","retStr","top","self","parentIFrame","getId","formatLogMsg","msg","msgId","settings","console","warn","iFrameListener","event","resizeIFrame","resize","setSize","messageData","setPagePosition","resizedCallback","ensureInRange","syncResize","closeIFrame","iframe","iframeID","id","parentNode","removeChild","closedCallback","processMsg","data","substr","msgIdLen","split","document","getElementById","height","width","type","Dimension","max","Number","min","dimension","toLowerCase","size","Error","isMessageFromIFrame","origin","remoteHost","src","slice","join","checkOrigin","isMessageForUs","isMessageFromMetaParent","retCode","true","false","getMsgBody","offset","indexOf","msgHeaderLen","forwardMsgFromIFrame","msgBody","messageCallback","message","JSON","parse","checkIFrameExists","page","getElementPosition","target","iFramePosition","getBoundingClientRect","getPagePosition","parseInt","left","pagePosition","y","scrollRequestFromChild","addOffset","reposition","newPosition","scrollTo","calcOffset","scrollToOffset","scrollCallback","findTarget","location","jumpToTarget","jumpPosition","hash","hashData","decodeURIComponent","getElementsByName","moveToAnchor","actionMsg","resetIFrame","initCallback","firstRun","undefined","pageXOffset","documentElement","scrollLeft","pageYOffset","scrollTop","reset","trigger","setDimension","style","sizeHeight","sizeWidth","doNotSync","calleeMsg","contentWindow","postMessage","setupIFrame","setLimits","addStyle","Infinity","ensureHasId","count","setScrolling","scrolling","overflow","setupBodyMarginValues","bodyMargin","bodyMarginV1","createOutgoingMsg","interval","enablePublicMethods","autoResize","heightCalculationMethod","bodyBackground","bodyPadding","tolerance","init","fr","resetRequiredMethods","this","checkOptions","options","TypeError","processOptions","option","defaults","hasOwnProperty","factory","element","tagName","toUpperCase","call","Array","prototype","forEach","querySelectorAll","createJQueryPublicMethod","$","fn","iFrameResize","filter","each","end","msgHeader","scroll","bodyScroll","documentElementScroll","maxHeight","maxWidth","minHeight","minWidth","jQuery","define","amd","exports","module"],"mappings":";;;;;;;CAOC,WACG,YAyCH,SAASA,GAAiBC,EAAIC,EAAIC,GAC7B,oBAAsBC,QACzBH,EAAID,iBAAiBE,EAAIC,GAAM,GACrB,eAAiBC,SAC3BH,EAAII,YAAY,KAAKH,EAAIC,GAI3B,QAASG,KACR,GAECC,GADAC,GAAW,MAAO,SAAU,IAAK,KAIlC,KAAKD,EAAI,EAAGA,EAAIC,EAAQC,SAAWC,EAAuBH,GAAK,EAC9DG,EAAwBN,OAAOI,EAAQD,GAAK,wBAGxC,IACJI,EAAI,wCAIN,QAASC,KACR,GAAIC,GAAS,WAUb,OARIT,QAAOU,MAAMV,OAAOW,OAEtBF,EADGT,OAAOY,aACDZ,OAAOY,aAAaC,QAEpB,oBAIJJ,EAGR,QAASK,GAAaC,GACrB,MAAOC,GAAQ,IAAMR,IAAY,IAAMO,EAGxC,QAASR,GAAIQ,GACRE,EAASV,KAAQ,gBAAoBP,QAAOkB,SAC/CA,QAAQX,IAAIO,EAAaC,IAI3B,QAASI,GAAKJ,GACT,gBAAoBf,QAAOkB,SAC9BA,QAAQC,KAAKL,EAAaC,IAI5B,QAASK,GAAeC,GACvB,QAASC,KACR,QAASC,KACRC,EAAQC,GACRC,IACAT,EAASU,gBAAgBF,GAG1BG,EAAc,UACdA,EAAc,SAEdC,EAAWN,EAAOE,EAAY,aAG/B,QAASK,GAAYC,GACpB,GAAIC,GAAWD,EAAOE,EAEtB1B,GAAI,qBAAqByB,GACzBD,EAAOG,WAAWC,YAAYJ,GAC9Bd,EAASmB,eAAeJ,GACxBzB,EAAI,OAGL,QAAS8B,KACR,GAAIC,GAAOvB,EAAIwB,OAAOC,GAAUC,MAAM,IAEtC,QACCV,OAAQW,SAASC,eAAeL,EAAK,IACrCL,GAAQK,EAAK,GACbM,OAAQN,EAAK,GACbO,MAAQP,EAAK,GACbQ,KAAQR,EAAK,IAIf,Q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X,OAC9ByE,EAAyB,GACzBQ,EAAwB,KACxBhF,EAAwBN,OAAOM,sBAC/B6I,GAAyBnG,IAAI,EAAE6H,OAAO,EAAEC,WAAW,EAAEC,sBAAsB,GAC3E9J,KAEAyI,GACCd,YAA4B,EAC5BE,eAA4B,KAC5BP,WAA4B,KAC5BC,aAA4B,EAC5BO,YAA4B,KAC5BlF,aAA4B,EAC5B8E,qBAA4B,EAC5BE,wBAA4B,SAC5BH,SAA4B,GAC5BnI,KAA4B,EAC5ByK,UAA4BhD,IAC5BiD,SAA4BjD,IAC5BkD,UAA4B,EAC5BC,SAA4B,EAC5B/C,WAA4B,EAC5Bb,YAA4B,EAC5BC,WAA4B,EAC5BwB,UAA4B,EAC5B5G,eAA4B,aAC5BuE,aAA4B,aAC5BlC,gBAA4B,aAC5B9C,gBAA4B,aAC5BoE,eAA4B,WAAW,OAAO,GAyfhD7F,KACAN,EAAiBI,OAAO,UAAUoB,GAE9BpB,OAAOoL,QAAUf,EAAyBe,QAExB,kBAAXC,SAAyBA,OAAOC,IAC1CD,UAAUzB,GACmB,gBAAZ2B,SACjBC,OAAOD,QAAU3B,IAEjB5J,OAAOwK,aAAeZ","sourcesContent":["/*\n * File: iframeReizer.js\n * Desc: Force iframes to size to content.\n * Requires: iframeResizer.contentWindow.js to be loaded into the target frame.\n * Author: David J. Bradshaw - [email protected]\n * Contributor: Jure Mav - [email protected]\n */\n;(function() {\n 'use strict';\n\n\tvar\n\t\tcount = 0,\n\t\tfirstRun = true,\n\t\tmsgHeader = 'message',\n\t\tmsgHeaderLen = msgHeader.length,\n\t\tmsgId = '[iFrameSizer]', //Must match iframe msg ID\n\t\tmsgIdLen = msgId.length,\n\t\tpage = '', //:'+location.href, //Uncoment to debug nested iFrames\n\t\tpagePosition = null,\n\t\trequestAnimationFrame = window.requestAnimationFrame,\n\t\tresetRequiredMethods = {max:1,scroll:1,bodyScroll:1,documentElementScroll:1},\n\t\tsettings = {},\n\n\t\tdefaults = {\n\t\t\tautoResize : true,\n\t\t\tbodyBackground : null,\n\t\t\tbodyMargin : null,\n\t\t\tbodyMarginV1 : 8,\n\t\t\tbodyPadding : null,\n\t\t\tcheckOrigin : true,\n\t\t\tenablePublicMethods : false,\n\t\t\theightCalculationMethod : 'offset',\n\t\t\tinterval : 32,\n\t\t\tlog : false,\n\t\t\tmaxHeight : Infinity,\n\t\t\tmaxWidth : Infinity,\n\t\t\tminHeight : 0,\n\t\t\tminWidth : 0,\n\t\t\tscrolling : false,\n\t\t\tsizeHeight : true,\n\t\t\tsizeWidth : false,\n\t\t\ttolerance : 0,\n\t\t\tclosedCallback : function(){},\n\t\t\tinitCallback : function(){},\n\t\t\tmessageCallback : function(){},\n\t\t\tresizedCallback : function(){},\n\t\t\tscrollCallback : function(){return true;}\n\t\t};\n\n\tfunction addEventListener(obj,evt,func){\n\t\tif ('addEventListener' in window){\n\t\t\tobj.addEventListener(evt,func, false);\n\t\t} else if ('attachEvent' in window){//IE\n\t\t\tobj.attachEvent('on'+evt,func);\n\t\t}\n\t}\n\n\tfunction setupRequestAnimationFrame(){\n\t\tvar\n\t\t\tvendors = ['moz', 'webkit', 'o', 'ms'],\n\t\t\tx;\n\n\t\t// Remove vendor prefixing if prefixed and break early if not\n\t\tfor (x = 0; x < vendors.length && !requestAnimationFrame; x += 1) {\n\t\t\trequestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];\n\t\t}\n\n\t\tif (!(requestAnimationFrame)){\n\t\t\tlog(' RequestAnimationFrame not supported');\n\t\t}\n\t}\n\n\tfunction getMyID(){\n\t\tvar retStr = 'Host page';\n\n\t\tif (window.top!==window.self){\n\t\t\tif (window.parentIFrame){\n\t\t\t\tretStr = window.parentIFrame.getId();\n\t\t\t} else {\n\t\t\t\tretStr = 'Nested host page';\n\t\t\t}\n\t\t}\n\n\t\treturn retStr;\n\t}\n\n\tfunction formatLogMsg(msg){\n\t\treturn msgId + '[' + getMyID() + ']' + msg;\n\t}\n\n\tfunction log(msg){\n\t\tif (settings.log && ('object' === typeof window.console)){\n\t\t\tconsole.log(formatLogMsg(msg));\n\t\t}\n\t}\n\n\tfunction warn(msg){\n\t\tif ('object' === typeof window.console){\n\t\t\tconsole.warn(formatLogMsg(msg));\n\t\t}\n\t}\n\n\tfunction iFrameListener(event){\n\t\tfunction resizeIFrame(){\n\t\t\tfunction resize(){\n\t\t\t\tsetSize(messageData);\n\t\t\t\tsetPagePosition();\n\t\t\t\tsettings.resizedCallback(messageData);\n\t\t\t}\n\n\t\t\tensureInRange('Height');\n\t\t\tensureInRange('Width');\n\t\t\t\n\t\t\tsyncResize(resize,messageData,'resetPage');\n\t\t}\n\n\t\tfunction closeIFrame(iframe){\n\t\t\tvar iframeID = iframe.id;\n\n\t\t\tlog(' Removing iFrame: '+iframeID);\n\t\t\tiframe.parentNode.removeChild(iframe);\n\t\t\tsettings.closedCallback(iframeID);\n\t\t\tlog(' --');\n\t\t}\n\n\t\tfunction processMsg(){\n\t\t\tvar data = msg.substr(msgIdLen).split(':');\n\n\t\t\treturn {\n\t\t\t\tiframe: document.getElementById(data[0]),\n\t\t\t\tid: data[0],\n\t\t\t\theight: data[1],\n\t\t\t\twidth: data[2],\n\t\t\t\ttype: data[3]\n\t\t\t};\n\t\t}\n\n\t\tfunction ensureInRange(Dimension){\n\t\t\tvar\n\t\t\t\tmax = Number(settings['max'+Dimension]),\n\t\t\t\tmin = Number(settings['min'+Dimension]),\n\t\t\t\tdimension = Dimension.toLowerCase(),\n\t\t\t\tsize = Number(messageData[dimension]);\n\n\t\t\tif (min>max){\n\t\t\t\tthrow new Error('Value for min'+Dimension+' can not be greater than max'+Dimension);\n\t\t\t}\n\n\t\t\tlog(' Checking '+dimension+' is in range '+min+'-'+max);\n\n\t\t\tif (size<min) {\n\t\t\t\tsize=min;\n\t\t\t\tlog(' Set '+dimension+' to min value');\n\t\t\t}\n\n\t\t\tif (size>max) {\n\t\t\t\tsize=max;\n\t\t\t\tlog(' Set '+dimension+' to max value');\n\t\t\t}\n\n\t\t\tmessageData[dimension]=''+size;\n\t\t}\n\n\t\tfunction isMessageFromIFrame(){\n\t\t\tvar\n\t\t\t\torigin = event.origin,\n\t\t\t\tremoteHost = messageData.iframe.src.split('/').slice(0,3).join('/');\n\n\t\t\tif (settings.checkOrigin) {\n\t\t\t\tlog(' Checking connection is from: '+remoteHost);\n\n\t\t\t\tif ((''+origin !== 'null') && (origin !== remoteHost)) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'Unexpected message received from: ' + origin +\n\t\t\t\t\t\t' for ' + messageData.iframe.id +\n\t\t\t\t\t\t'. Message was: ' + event.data +\n\t\t\t\t\t\t'. This error can be disabled by adding the checkOrigin: false option.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn true;\n\t\t}\n\n\t\tfunction isMessageForUs(){\n\t\t\treturn msgId === ('' + msg).substr(0,msgIdLen); //''+Protects against non-string msg\n\t\t}\n\n\t\tfunction isMessageFromMetaParent(){\n\t\t\t//test if this message is from a parent above us. This is an ugly test, however, updating\n\t\t\t//the message format would break backwards compatibity.\n\t\t\tvar retCode = messageData.type in {'true':1,'false':1};\n\n\t\t\tif (retCode){\n\t\t\t\tlog(' Ignoring init message from meta parent page');\n\t\t\t}\n\n\t\t\treturn retCode;\n\t\t}\n\n\t\tfunction getMsgBody(offset){\n\t\t\treturn msg.substr(msg.indexOf(':')+msgHeaderLen+offset);\n\t\t}\n\n\t\tfunction forwardMsgFromIFrame(msgBody){\n\t\t\tlog(' MessageCallback passed: {iframe: '+ messageData.iframe.id + ', message: ' + msgBody + '}');\n\t\t\tsettings.messageCallback({\n\t\t\t\tiframe: messageData.iframe,\n\t\t\t\tmessage: JSON.parse(msgBody)\n\t\t\t});\n\t\t\tlog(' --');\n\t\t}\n\n\t\tfunction checkIFrameExists(){\n\t\t\tif (null === messageData.iframe) {\n\t\t\t\tthrow new Error('iFrame ('+messageData.id+') does not exist on ' + page);\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\tfunction getElementPosition(target){\n\t\t\tvar\n\t\t\t\tiFramePosition = target.getBoundingClientRect();\n\n\t\t\tgetPagePosition();\n\n\t\t\treturn {\n\t\t\t\tx: parseInt(iFramePosition.left, 10) + parseInt(pagePosition.x, 10),\n\t\t\t\ty: parseInt(iFramePosition.top, 10) + parseInt(pagePosition.y, 10)\n\t\t\t};\n\t\t}\n\n\t\tfunction scrollRequestFromChild(addOffset){\n\t\t\tfunction reposition(){\n\t\t\t\tpagePosition = newPosition;\n\n\t\t\t\tscrollTo();\n\n\t\t\t\tlog(' --');\n\t\t\t}\n\n\t\t\tfunction calcOffset(){\n\t\t\t\treturn {\n\t\t\t\t\tx: Number(messageData.width) + offset.x,\n\t\t\t\t\ty: Number(messageData.height) + offset.y\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tvar \n\t\t\t\toffset = addOffset ? getElementPosition(messageData.iframe) : {x:0,y:0},\n\t\t\t\tnewPosition = calcOffset();\n\t\t\t\n\t\t\tlog(' Reposition requested from iFrame (offset x:'+offset.x+' y:'+offset.y+')');\n\n\t\t\tif(window.top!==window.self){\n\t\t\t\tif (window.parentIFrame){\n\t\t\t\t\tif (addOffset){\n\t\t\t\t\t\tparentIFrame.scrollToOffset(newPosition.x,newPosition.y);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tparentIFrame.scrollTo(messageData.width,messageData.height);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\twarn(' Unable to scroll to requested position, window.parentIFrame not found');\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treposition();\n\t\t\t}\n\n\t\t}\n\n\t\tfunction scrollTo(){\n\t\t\tif (false !== settings.scrollCallback(pagePosition)){\n\t\t\t\tsetPagePosition();\n\t\t\t}\n\t\t}\n\n\t\tfunction findTarget(location){\n\t\t\tvar hash = location.split(\"#\")[1] || \"\";\n\t\t\tvar hashData = decodeURIComponent(hash);\n\n\t\t\tfunction jumpToTarget(target){\n\t\t\t\tvar jumpPosition = getElementPosition(target);\n\n\t\t\t\tlog(' Moving to in page link (#'+hash+') at x: '+jumpPosition.x+' y: '+jumpPosition.y);\n\t\t\t\tpagePosition = {\n\t\t\t\t\tx: jumpPosition.x,\n\t\t\t\t\ty: jumpPosition.y\n\t\t\t\t};\n\n\t\t\t\tscrollTo();\n\t\t\t\tlog(' --');\n\t\t\t}\n\n\t\t\tvar target = document.getElementById(hashData) || document.getElementsByName(hashData)[0];\n\n\t\t\tif(window.top!==window.self){\n\t\t\t\tif (window.parentIFrame){\n\t\t\t\t\tparentIFrame.moveToAnchor(hash);\n\t\t\t\t} else {\n\t\t\t\t\tlog(' In page link #'+hash+' not found and window.parentIFrame not found');\n\t\t\t\t}\n\t\t\t} else if (target){\n\t\t\t\tjumpToTarget(target);\n\t\t\t} else {\n\t\t\t\tlog(' In page link #'+hash+' not found');\n\t\t\t}\n\t\t}\n\n\t\tfunction actionMsg(){\n\t\t\tswitch(messageData.type){\n\t\t\t\tcase 'close':\n\t\t\t\t\tcloseIFrame(messageData.iframe);\n\t\t\t\t\tsettings.resizedCallback(messageData); //To be removed.\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'message':\n\t\t\t\t\tforwardMsgFromIFrame(getMsgBody(6));\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'scrollTo':\n\t\t\t\t\tscrollRequestFromChild(false);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'scrollToOffset':\n\t\t\t\t\tscrollRequestFromChild(true);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'inPageLink':\n\t\t\t\t\tfindTarget(getMsgBody(9));\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'reset':\n\t\t\t\t\tresetIFrame(messageData);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'init':\n\t\t\t\t\tresizeIFrame();\n\t\t\t\t\tsettings.initCallback(messageData.iframe);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tresizeIFrame();\n\t\t\t}\n\t\t}\n\n\t\tvar\n\t\t\tmsg = event.data,\n\t\t\tmessageData = {};\n\n\t\tif (isMessageForUs()){\n\t\t\tlog(' Received: '+msg);\n\t\t\tmessageData = processMsg();\n\n\t\t\tif ( !isMessageFromMetaParent() && checkIFrameExists() && isMessageFromIFrame() ){\n\t\t\t\tactionMsg();\n\t\t\t\tfirstRun = false;\n\t\t\t}\n\t\t}\n\t}\n\n\n\tfunction getPagePosition (){\n\t\tif(null === pagePosition){\n\t\t\tpagePosition = {\n\t\t\t\tx: (window.pageXOffset !== undefined) ? window.pageXOffset : document.documentElement.scrollLeft,\n\t\t\t\ty: (window.pageYOffset !== undefined) ? window.pageYOffset : document.documentElement.scrollTop\n\t\t\t};\n\t\t\tlog(' Get page position: '+pagePosition.x+','+pagePosition.y);\n\t\t}\n\t}\n\n\tfunction setPagePosition(){\n\t\tif(null !== pagePosition){\n\t\t\twindow.scrollTo(pagePosition.x,pagePosition.y);\n\t\t\tlog(' Set page position: '+pagePosition.x+','+pagePosition.y);\n\t\t\tpagePosition = null;\n\t\t}\n\t}\n\n\tfunction resetIFrame(messageData){\n\t\tfunction reset(){\n\t\t\tsetSize(messageData);\n\t\t\ttrigger('reset','reset',messageData.iframe);\n\t\t}\n\n\t\tlog(' Size reset requested by '+('init'===messageData.type?'host page':'iFrame'));\n\t\tgetPagePosition();\n\t\tsyncResize(reset,messageData,'init');\n\t}\n\n\tfunction setSize(messageData){\n\t\tfunction setDimension(dimension){\n\t\t\tmessageData.iframe.style[dimension] = messageData[dimension] + 'px';\n\t\t\tlog(\n\t\t\t\t' IFrame (' + messageData.iframe.id +\n\t\t\t\t') ' + dimension +\n\t\t\t\t' set to ' + messageData[dimension] + 'px'\n\t\t\t);\n\t\t}\n\n\t\tif( settings.sizeHeight) { setDimension('height'); }\n\t\tif( settings.sizeWidth ) { setDimension('width'); }\n\t}\n\n\tfunction syncResize(func,messageData,doNotSync){\n\t\tif(doNotSync!==messageData.type && requestAnimationFrame){\n\t\t\tlog(' Requesting animation frame');\n\t\t\trequestAnimationFrame(func);\n\t\t} else {\n\t\t\tfunc();\n\t\t}\n\t}\n\n\tfunction trigger(calleeMsg,msg,iframe){\n\t\tlog('[' + calleeMsg + '] Sending msg to iframe ('+msg+')');\n\t\tiframe.contentWindow.postMessage( msgId + msg, '*' );\n\t}\n\n\n\tfunction setupIFrame(){\n\t\tfunction setLimits(){\n\t\t\tfunction addStyle(style){\n\t\t\t\tif ((Infinity !== settings[style]) && (0 !== settings[style])){\n\t\t\t\t\tiframe.style[style] = settings[style] + 'px';\n\t\t\t\t\tlog(' Set '+style+' = '+settings[style]+'px');\n\t\t\t\t}\n\t\t\t}\n\n\t\t\taddStyle('maxHeight');\n\t\t\taddStyle('minHeight');\n\t\t\taddStyle('maxWidth');\n\t\t\taddStyle('minWidth');\n\t\t}\n\n\t\tfunction ensureHasId(iframeID){\n\t\t\tif (''===iframeID){\n\t\t\t\tiframe.id = iframeID = 'iFrameResizer' + count++;\n\t\t\t\tlog(' Added missing iframe ID: '+ iframeID +' (' + iframe.src + ')');\n\t\t\t}\n\n\t\t\treturn iframeID;\n\t\t}\n\n\t\tfunction setScrolling(){\n\t\t\tlog(' IFrame scrolling ' + (settings.scrolling ? 'enabled' : 'disabled') + ' for ' + iframeID);\n\t\t\tiframe.style.overflow = false === settings.scrolling ? 'hidden' : 'auto';\n\t\t\tiframe.scrolling = false === settings.scrolling ? 'no' : 'yes';\n\t\t}\n\n\t\t//The V1 iFrame script expects an int, where as in V2 expects a CSS\n\t\t//string value such as '1px 3em', so if we have an int for V2, set V1=V2\n\t\t//and then convert V2 to a string PX value.\n\t\tfunction setupBodyMarginValues(){\n\t\t\tif (('number'===typeof(settings.bodyMargin)) || ('0'===settings.bodyMargin)){\n\t\t\t\tsettings.bodyMarginV1 = settings.bodyMargin;\n\t\t\t\tsettings.bodyMargin = '' + settings.bodyMargin + 'px';\n\t\t\t}\n\t\t}\n\n\t\tfunction createOutgoingMsg(){\n\t\t\treturn iframeID +\n\t\t\t\t':' + settings.bodyMarginV1 +\n\t\t\t\t':' + settings.sizeWidth +\n\t\t\t\t':' + settings.log +\n\t\t\t\t':' + settings.interval +\n\t\t\t\t':' + settings.enablePublicMethods +\n\t\t\t\t':' + settings.autoResize +\n\t\t\t\t':' + settings.bodyMargin +\n\t\t\t\t':' + settings.heightCalculationMethod +\n\t\t\t\t':' + settings.bodyBackground +\n\t\t\t\t':' + settings.bodyPadding +\n\t\t\t\t':' + settings.tolerance;\n\t\t}\n\n\t\tfunction init(msg){\n\t\t\t//We have to call trigger twice, as we can not be sure if all\n\t\t\t//iframes have completed loading when this code runs. The\n\t\t\t//event listener also catches the page changing in the iFrame.\n\t\t\taddEventListener(iframe,'load',function(){\n\t\t\t\tvar fr = firstRun; // Reduce scope of var to function, because IE8's JS execution\n // context stack is borked and this value gets externally\n // changed midway through running this function.\n\t\t\t\ttrigger('iFrame.onload',msg,iframe);\n\t\t\t\tif (!fr && settings.heightCalculationMethod in resetRequiredMethods){\n\t\t\t\t\tresetIFrame({\n\t\t\t\t\t\tiframe:iframe,\n\t\t\t\t\t\theight:0,\n\t\t\t\t\t\twidth:0,\n\t\t\t\t\t\ttype:'init'\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t\ttrigger('init',msg,iframe);\n\t\t}\n\n\t\tvar\n /*jshint validthis:true */\n\t\t\tiframe = this,\n\t\t\tiframeID = ensureHasId(iframe.id);\n\n\t\tsetScrolling();\n\t\tsetLimits();\n\t\tsetupBodyMarginValues();\n\t\tinit(createOutgoingMsg());\n\t}\n\n\tfunction checkOptions(options){\n\t\tif ('object' !== typeof options){\n\t\t\tthrow new TypeError('Options is not an object.');\n\t\t}\n\t}\n\n\tfunction processOptions(options){\n\t\toptions = options || {};\n\t\tcheckOptions(options);\n\n\t\tfor (var option in defaults) {\n\t\t\tif (defaults.hasOwnProperty(option)){\n\t\t\t\tsettings[option] = options.hasOwnProperty(option) ? options[option] : defaults[option];\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction factory(){\n\t\tfunction init(element){\n\t\t\tif(!element.tagName) {\n throw new TypeError('Object is not a valid DOM element');\n } else if ('IFRAME' !== element.tagName.toUpperCase()) {\n\t\t\t\tthrow new TypeError('Expected <IFRAME> tag, found <'+element.tagName+'>.');\n\t\t\t} else {\n\t\t\t\tsetupIFrame.call(element);\n\t\t\t}\n\t\t}\n\n\t\treturn function iFrameResizeF(options,target){\n\t\t\tprocessOptions(options);\n\t\t\tswitch (typeof(target)){\n\t\t\t\tcase 'undefined':\n\t\t\t\tcase 'string':\n\t\t\t\t\tArray.prototype.forEach.call( document.querySelectorAll( target || 'iframe' ), init );\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'object':\n\t\t\t\t\tinit(target);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new TypeError('Unexpected data type ('+typeof(target)+').');\n\t\t\t}\n\t\t\t\n\t\t};\n\t}\n\n\tfunction createJQueryPublicMethod($){\n\t\t$.fn.iFrameResize = function $iFrameResizeF(options) {\n\t\t\tprocessOptions(options);\n\t\t\treturn this.filter('iframe').each( setupIFrame ).end();\n\t\t};\n\t}\n\n\tsetupRequestAnimationFrame();\n\taddEventListener(window,'message',iFrameListener);\n\n\tif (window.jQuery) { createJQueryPublicMethod(jQuery); }\n\n\tif (typeof define === 'function' && define.amd) {\n\t\tdefine([],factory);\n\t} else if (typeof exports === 'object') { //Node for browserfy\n\t\tmodule.exports = factory();\n\t} else {\n\t\twindow.iFrameResize = factory();\n\t}\n\n})();\n"]}