j1m_app 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.md +21 -0
- data/README.md +41 -0
- data/_data/modules/default/j1_app-0.0.1/j1_iframe_resizer.yml +270 -0
- data/_data/resources/default/j1_app-0.0.1/resource.yml +22 -0
- data/assets/themes/j1/iframe_resizer/.npmignore +9 -0
- data/assets/themes/j1/iframe_resizer/.travis.yml +6 -0
- data/assets/themes/j1/iframe_resizer/CONTRIBUTING.md +86 -0
- data/assets/themes/j1/iframe_resizer/Iframe-resizer by davidjbradshaw.url +2 -0
- data/assets/themes/j1/iframe_resizer/LICENSE +21 -0
- data/assets/themes/j1/iframe_resizer/README.md +608 -0
- data/assets/themes/j1/iframe_resizer/bower.json +45 -0
- data/assets/themes/j1/iframe_resizer/example/frame.absolute.html +88 -0
- data/assets/themes/j1/iframe_resizer/example/frame.content.html +58 -0
- data/assets/themes/j1/iframe_resizer/example/frame.hover.html +51 -0
- data/assets/themes/j1/iframe_resizer/example/frame.nested.html +72 -0
- data/assets/themes/j1/iframe_resizer/example/frame.textarea.html +46 -0
- data/assets/themes/j1/iframe_resizer/example/frame.tolerance.html +79 -0
- data/assets/themes/j1/iframe_resizer/example/index.html +70 -0
- data/assets/themes/j1/iframe_resizer/example/two.html +71 -0
- data/assets/themes/j1/iframe_resizer/gruntfile.js +215 -0
- data/assets/themes/j1/iframe_resizer/iframeResizer.jquery.json +41 -0
- data/assets/themes/j1/iframe_resizer/index.js +4 -0
- data/assets/themes/j1/iframe_resizer/js/_client.js +1131 -0
- data/assets/themes/j1/iframe_resizer/js/_server.js +1126 -0
- data/assets/themes/j1/iframe_resizer/js/ie8.polyfils.js +85 -0
- data/assets/themes/j1/iframe_resizer/js/ie8.polyfils.map +1 -0
- data/assets/themes/j1/iframe_resizer/js/ie8.polyfils.min.js +4 -0
- data/assets/themes/j1/iframe_resizer/js/iframeResizer.contentWindow.js +1104 -0
- data/assets/themes/j1/iframe_resizer/js/iframeResizer.contentWindow.map +1 -0
- data/assets/themes/j1/iframe_resizer/js/iframeResizer.contentWindow.min.js +10 -0
- data/assets/themes/j1/iframe_resizer/js/iframeResizer.js +1007 -0
- data/assets/themes/j1/iframe_resizer/js/iframeResizer.js.modified +1004 -0
- data/assets/themes/j1/iframe_resizer/js/iframeResizer.map +1 -0
- data/assets/themes/j1/iframe_resizer/js/iframeResizer.min.js +9 -0
- data/assets/themes/j1/iframe_resizer/js/index.js +2 -0
- data/assets/themes/j1/iframe_resizer/karma.conf.js +92 -0
- data/assets/themes/j1/iframe_resizer/package.json +111 -0
- data/assets/themes/j1/iframe_resizer/spec/_initSpec.js +63 -0
- data/assets/themes/j1/iframe_resizer/spec/anchorSpec.js +62 -0
- data/assets/themes/j1/iframe_resizer/spec/childSpec.js +403 -0
- data/assets/themes/j1/iframe_resizer/spec/closeSpecSpec.js +44 -0
- data/assets/themes/j1/iframe_resizer/spec/getPageInfoSpec.js +32 -0
- data/assets/themes/j1/iframe_resizer/spec/initCssSpec.js +28 -0
- data/assets/themes/j1/iframe_resizer/spec/initDomSpec.js +27 -0
- data/assets/themes/j1/iframe_resizer/spec/initDoubleCallSpec.js +33 -0
- data/assets/themes/j1/iframe_resizer/spec/initErrorSpec.js +57 -0
- data/assets/themes/j1/iframe_resizer/spec/initJQuerySpec.js +29 -0
- data/assets/themes/j1/iframe_resizer/spec/initUndefinedDomSpec.js +25 -0
- data/assets/themes/j1/iframe_resizer/spec/javascripts/fixtures/iframe.html +2 -0
- data/assets/themes/j1/iframe_resizer/spec/javascripts/fixtures/iframe600.html +4 -0
- data/assets/themes/j1/iframe_resizer/spec/javascripts/fixtures/iframe600WithId.html +4 -0
- data/assets/themes/j1/iframe_resizer/spec/lib/common.js +59 -0
- data/assets/themes/j1/iframe_resizer/spec/parentSpec.js +88 -0
- data/assets/themes/j1/iframe_resizer/spec/resources/djb.jpg +0 -0
- data/assets/themes/j1/iframe_resizer/spec/resources/frame.content.html +176 -0
- data/assets/themes/j1/iframe_resizer/spec/resources/frame.lateload.html +33 -0
- data/assets/themes/j1/iframe_resizer/spec/resources/frame.nested.html +40 -0
- data/assets/themes/j1/iframe_resizer/spec/scrollSpec.js +53 -0
- data/assets/themes/j1/iframe_resizer/spec/sendMessageSpec.js +58 -0
- data/assets/themes/j1/iframe_resizer/spec/support/jasmine.json +9 -0
- data/assets/themes/j1/iframe_resizer/src/ie8.polyfils.js +64 -0
- data/assets/themes/j1/iframe_resizer/src/iframeResizer.contentWindow.js +1123 -0
- data/assets/themes/j1/iframe_resizer/src/iframeResizer.js +1002 -0
- data/assets/themes/j1/iframe_resizer/test-main.js +33 -0
- data/assets/themes/j1/iframe_resizer/test/_init.html +44 -0
- data/assets/themes/j1/iframe_resizer/test/_init_once.html +45 -0
- data/assets/themes/j1/iframe_resizer/test/_init_once_async.html +72 -0
- data/assets/themes/j1/iframe_resizer/test/background.html +47 -0
- data/assets/themes/j1/iframe_resizer/test/changePage.html +50 -0
- data/assets/themes/j1/iframe_resizer/test/close.html +44 -0
- data/assets/themes/j1/iframe_resizer/test/getId.html +44 -0
- data/assets/themes/j1/iframe_resizer/test/interval.html +56 -0
- data/assets/themes/j1/iframe_resizer/test/jqueryNoConflict.html +47 -0
- data/assets/themes/j1/iframe_resizer/test/lateImageLoad.html +90 -0
- data/assets/themes/j1/iframe_resizer/test/margin.html +73 -0
- data/assets/themes/j1/iframe_resizer/test/mutationObserver.html +63 -0
- data/assets/themes/j1/iframe_resizer/test/nested.html +46 -0
- data/assets/themes/j1/iframe_resizer/test/resize.contentWidth.html +51 -0
- data/assets/themes/j1/iframe_resizer/test/resize.width.html +63 -0
- data/assets/themes/j1/iframe_resizer/test/resources/djb.jpg +0 -0
- data/assets/themes/j1/iframe_resizer/test/resources/frame.content.html +191 -0
- data/assets/themes/j1/iframe_resizer/test/resources/frame.lateload.html +33 -0
- data/assets/themes/j1/iframe_resizer/test/resources/frame.nested.html +40 -0
- data/assets/themes/j1/iframe_resizer/test/resources/jquery.js +6 -0
- data/assets/themes/j1/iframe_resizer/test/resources/qunit.css +244 -0
- data/assets/themes/j1/iframe_resizer/test/resources/qunit.js +2212 -0
- data/assets/themes/j1/iframe_resizer/test/resources/require.js +2103 -0
- data/assets/themes/j1/iframe_resizer/test/resources/testLib.js +9 -0
- data/assets/themes/j1/iframe_resizer/test/scrolling.html +65 -0
- data/assets/themes/j1/iframe_resizer/test/sendMessage.html +61 -0
- data/assets/themes/j1/iframe_resizer/test/setHeightCalculationMethod.html +51 -0
- data/assets/themes/j1/iframe_resizer/test/size.html +64 -0
- data/assets/themes/j1/iframe_resizer/test/v1.html +189 -0
- data/exe/console +14 -0
- data/exe/setup +8 -0
- data/lib/j1m_app.rb +5 -0
- data/lib/j1m_app/version.rb +3 -0
- metadata +187 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["iframeResizer.contentWindow.js"],"names":["window","undefined","addEventListener","el","evt","func","attachEvent","removeEventListener","detachEvent","capitalizeFirstLetter","string","charAt","toUpperCase","slice","throttle","context","args","result","timeout","previous","later","getNow","apply","now","remaining","throttledTimer","this","arguments","clearTimeout","setTimeout","formatLogMsg","msg","msgID","myID","log","logging","console","warn","init","readDataFromParent","location","href","readDataFromPage","setMargin","setBodyStyle","bodyBackground","bodyPadding","injectClearFixIntoBodyElement","checkHeightMode","checkWidthMode","stopInfiniteResizingOfIFrame","setupPublicMethods","startEventListeners","inPageLinks","setupInPageLinks","sendSize","readyCallback","strBool","str","data","initMsg","substr","msgIdLen","split","bodyMargin","Number","calculateWidth","interval","autoResize","bodyMarginStr","heightCalcMode","tolerance","enable","resizeFrom","widthCalcMode","readData","iFrameResizer","JSON","stringify","messageCallback","targetOriginDefault","targetOrigin","heightCalculationMethod","widthCalculationMethod","setupCustomCalcMethods","calcMode","calcFunc","customCalcMethods","Object","constructor","chkCSS","attr","value","indexOf","document","body","style","documentElement","height","manageTriggerEvent","options","listener","add","eventName","handleEvent","eventType","eventHandlersByName","remove","eventNames","Array","prototype","map","method","manageEventListeners","checkCalcMode","calcModeDefault","modes","type","heightCalcModeDefault","getHeight","widthCalcModeDefault","getWidth","setupMutationObserver","stopMsgsToParent","sendPermit","removeMsgListener","receiver","disconnectMutationObserver","bodyObserver","disconnect","stopEventListeners","clearInterval","intervalTimer","teardown","clearFix","createElement","clear","display","appendChild","getPagePosition","x","pageXOffset","scrollLeft","y","pageYOffset","scrollTop","getElementPosition","elPosition","getBoundingClientRect","pagePosition","parseInt","left","top","findTarget","jumpToTarget","target","jumpPosition","hash","sendMsg","hashData","decodeURIComponent","getElementById","getElementsByName","checkLocationHash","bindAnchors","setupLink","linkClicked","e","preventDefault","getAttribute","forEach","call","querySelectorAll","bindLocationHash","initCheck","eventCancelTimer","enableInPageLinks","win","parentIFrame","resize","close","getId","getPageInfo","callback","pageInfoCallback","moveToAnchor","reset","resetIFrame","scrollTo","scrollToOffset","sendMessage","setHeightCalculationMethod","setWidthCalculationMethod","setTargetOrigin","size","customHeight","customWidth","valString","initInterval","setInterval","Math","abs","setupBodyMutationObserver","addImageLoadListners","mutation","addImageLoadListener","element","complete","src","imageLoaded","imageError","elements","push","attributeName","removeFromArray","splice","removeImageLoadListener","imageEventTriggered","event","typeDesc","mutationObserved","mutations","createMutationObserver","querySelector","config","attributes","attributeOldValue","characterData","characterDataOldValue","childList","subtree","observer","MutationObserver","observe","WebKitMutationObserver","forceIntervalTimer","getComputedStyle","prop","convertUnitsToPxForIE8","PIXEL","test","base","runtimeStyle","currentStyle","pixelLeft","retVal","defaultView","chkEventThottle","timer","getMaxElement","side","elementsLength","length","elVal","maxVal","Side","i","getAllMeasurements","dimention","bodyOffset","bodyScroll","documentElementOffset","documentElementScroll","getTaggedElements","tag","noTaggedElementsFound","getAllElements","sizeIFrame","triggerEvent","triggerEventDesc","resizeIFrame","currentHeight","width","currentWidth","isSizeChangeDetected","checkTolarance","a","b","isForceResizableEvent","isForceResizableCalcMode","resetRequiredMethods","logIgnored","checkDownSizing","lockTrigger","recordTrigger","resetPage","isDoubleFiredEvent","triggerLocked","doubleEventList","sizeIFrameThrottled","triggerLockedTimer","triggerReset","hcm","sendToParent","message","postMessage","isMessageForUs","getMessageType","getData","isMiddleTier","isInitMsg","true","false","callFromParent","messageType","processRequestFromParent","processMessage","firstRun","fireInit","source","initLock","initFromParent","inPageLink","pageInfo","msgBody","parse","chkLateLoaded","readyState","parent","click","max","min","offsetHeight","scrollWidth","Date","getTime","offset","scrollHeight","custom","grow","lowestElement","taggedElement","offsetWidth","scroll","rightMostElement"],"mappings":";;;;;;;;CAYC,SAAUA,EAAQC,GAClB,YAwDA,SAASC,GAAiBC,EAAGC,EAAIC,GAE5B,oBAAsBL,GACzBG,EAAGD,iBAAiBE,EAAIC,GAAM,GACpB,eAAiBL,IAC3BG,EAAGG,YAAY,KAAKF,EAAIC,GAI1B,QAASE,GAAoBJ,EAAGC,EAAIC,GAE/B,uBAAyBL,GAC5BG,EAAGI,oBAAoBH,EAAIC,GAAM,GACvB,eAAiBL,IAC3BG,EAAGK,YAAY,KAAKJ,EAAIC,GAI1B,QAASI,GAAsBC,GAC9B,MAAOA,GAAOC,OAAO,GAAGC,cAAgBF,EAAOG,MAAM,GAItD,QAASC,GAAST,GACjB,GACCU,GAASC,EAAMC,EACfC,EAAU,KACVC,EAAW,EACXC,EAAQ,WACPD,EAAWE,KACXH,EAAU,KACVD,EAASZ,EAAKiB,MAAMP,EAASC,GACxBE,IACJH,EAAUC,EAAO,MAIpB,OAAO,YACN,GAAIO,GAAMF,IAELF,KACJA,EAAWI,EAGZ,IAAIC,GAAYC,IAAkBF,EAAMJ,EAsBxC,OApBAJ,GAAUW,KACVV,EAAOW,UAEU,GAAbH,GAAkBA,EAAYC,IAC7BP,IACHU,aAAaV,GACbA,EAAU,MAGXC,EAAWI,EACXN,EAASZ,EAAKiB,MAAMP,EAASC,GAExBE,IACJH,EAAUC,EAAO,OAGPE,IACXA,EAAUW,WAAWT,EAAOI,IAGtBP,GAST,QAASa,GAAaC,GACrB,MAAOC,IAAQ,IAAMC,GAAO,KAAYF,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2I,aAAc3I,GAAS6I,0BAGjD0D,IAAK,WACJ,MAAOxH,MAAKwH,IAAI1S,MAAM,KAAK2O,EAAmBxI,MAG/CwM,IAAK,WACJ,MAAOzH,MAAKyH,IAAI3S,MAAM,KAAK2O,EAAmBxI,MAG/CqN,iBAAkB,WACjB,MAAOrF,GAAc,QAASiB,MAG/BiE,cAAe,WACd,MAAOpE,GAAkB,QAAS,uBAwDjC0B,GAAsBnR,EAAS6P,EAyLnCzQ,GAAiBF,EAAQ,UAAW8H,GACpC8L,KAIE5T","file":"iframeResizer.contentWindow.min.js","sourcesContent":["/*\n * File: iframeResizer.contentWindow.js\n * Desc: Include this file in any page being loaded into an iframe\n * to force the iframe to resize to the content size.\n * Requires: iframeResizer.js on host page.\n * Doc: https://github.com/davidjbradshaw/iframe-resizer\n * Author: David J. Bradshaw - dave@bradshaw.net\n * Contributor: Jure Mav - jure.mav@gmail.com\n * Contributor: Ian Caunce - ian@hallnet.co.uk\n */\n\n\n;(function(window, undefined) {\n\t'use strict';\n\n\tvar\n\t\tautoResize = true,\n\t\tbase = 10,\n\t\tbodyBackground = '',\n\t\tbodyMargin = 0,\n\t\tbodyMarginStr = '',\n\t\tbodyObserver = null,\n\t\tbodyPadding = '',\n\t\tcalculateWidth = false,\n\t\tdoubleEventList = {'resize':1,'click':1},\n\t\teventCancelTimer = 128,\n\t\tfirstRun = true,\n\t\theight = 1,\n\t\theightCalcModeDefault = 'bodyOffset',\n\t\theightCalcMode = heightCalcModeDefault,\n\t\tinitLock = true,\n\t\tinitMsg = '',\n\t\tinPageLinks = {},\n\t\tinterval = 32,\n\t\tintervalTimer = null,\n\t\tlogging = false,\n\t\tmsgID = '[iFrameSizer]', //Must match host page msg ID\n\t\tmsgIdLen = msgID.length,\n\t\tmyID = '',\n\t\tobserver = null,\n\t\tresetRequiredMethods = {max:1,min:1,bodyScroll:1,documentElementScroll:1},\n\t\tresizeFrom = 'child',\n\t\tsendPermit = true,\n\t\ttarget = window.parent,\n\t\ttargetOriginDefault = '*',\n\t\ttolerance = 0,\n\t\ttriggerLocked = false,\n\t\ttriggerLockedTimer = null,\n\t\tthrottledTimer = 16,\n\t\twidth = 1,\n\t\twidthCalcModeDefault = 'scroll',\n\t\twidthCalcMode = widthCalcModeDefault,\n\t\twin = window,\n\t\tmessageCallback = function(){ warn('MessageCallback function not defined'); },\n\t\treadyCallback = function(){},\n\t\tpageInfoCallback = function(){},\n\t\tcustomCalcMethods = {\n\t\t\theight: function(){\n\t\t\t\twarn('Custom height calculation function not defined');\n\t\t\t\treturn document.documentElement.offsetHeight;\n\t\t\t},\n\t\t\twidth: function(){\n\t\t\t\twarn('Custom width calculation function not defined');\n\t\t\t\treturn document.body.scrollWidth;\n\t\t\t}\n\t\t},\n\t\teventHandlersByName = {};\n\n\n\tfunction addEventListener(el,evt,func){\n\t\t/* istanbul ignore else */ // Not testable in phantonJS\n\t\tif ('addEventListener' in window){\n\t\t\tel.addEventListener(evt,func, false);\n\t\t} else if ('attachEvent' in window){ //IE\n\t\t\tel.attachEvent('on'+evt,func);\n\t\t}\n\t}\n\n\tfunction removeEventListener(el,evt,func){\n\t\t/* istanbul ignore else */ // Not testable in phantonJS\n\t\tif ('removeEventListener' in window){\n\t\t\tel.removeEventListener(evt,func, false);\n\t\t} else if ('detachEvent' in window){ //IE\n\t\t\tel.detachEvent('on'+evt,func);\n\t\t}\n\t}\n\n\tfunction capitalizeFirstLetter(string) {\n\t\treturn string.charAt(0).toUpperCase() + string.slice(1);\n\t}\n\n\t//Based on underscore.js\n\tfunction throttle(func) {\n\t\tvar\n\t\t\tcontext, args, result,\n\t\t\ttimeout = null,\n\t\t\tprevious = 0,\n\t\t\tlater = function() {\n\t\t\t\tprevious = getNow();\n\t\t\t\ttimeout = null;\n\t\t\t\tresult = func.apply(context, args);\n\t\t\t\tif (!timeout) {\n\t\t\t\t\tcontext = args = null;\n\t\t\t\t}\n\t\t\t};\n\n\t\treturn function() {\n\t\t\tvar now = getNow();\n\n\t\t\tif (!previous) {\n\t\t\t\tprevious = now;\n\t\t\t}\n\n\t\t\tvar remaining = throttledTimer - (now - previous);\n\n\t\t\tcontext = this;\n\t\t\targs = arguments;\n\n\t\t\tif (remaining <= 0 || remaining > throttledTimer) {\n\t\t\t\tif (timeout) {\n\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\ttimeout = null;\n\t\t\t\t}\n\n\t\t\t\tprevious = now;\n\t\t\t\tresult = func.apply(context, args);\n\n\t\t\t\tif (!timeout) {\n\t\t\t\t\tcontext = args = null;\n\t\t\t\t}\n\n\t\t\t} else if (!timeout) {\n\t\t\t\ttimeout = setTimeout(later, remaining);\n\t\t\t}\n\n\t\t\treturn result;\n\t\t};\n\t}\n\n\tvar getNow = Date.now || function() {\n\t\t/* istanbul ignore next */ // Not testable in PhantonJS\n\t\treturn new Date().getTime();\n\t};\n\n\tfunction formatLogMsg(msg){\n\t\treturn msgID + '[' + myID + ']' + ' ' + msg;\n\t}\n\n\tfunction log(msg){\n\t\tif (logging && ('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\n\tfunction init(){\n\t\treadDataFromParent();\n\t\tlog('Initialising iFrame ('+location.href+')');\n\t\treadDataFromPage();\n\t\tsetMargin();\n\t\tsetBodyStyle('background',bodyBackground);\n\t\tsetBodyStyle('padding',bodyPadding);\n\t\tinjectClearFixIntoBodyElement();\n\t\tcheckHeightMode();\n\t\tcheckWidthMode();\n\t\tstopInfiniteResizingOfIFrame();\n\t\tsetupPublicMethods();\n\t\tstartEventListeners();\n\t\tinPageLinks = setupInPageLinks();\n\t\tsendSize('init','Init message from host page');\n\t\treadyCallback();\n\t}\n\n\tfunction readDataFromParent(){\n\n\t\tfunction strBool(str){\n\t\t\treturn 'true' === str ? true : false;\n\t\t}\n\n\t\tvar data = initMsg.substr(msgIdLen).split(':');\n\n\t\tmyID = data[0];\n\t\tbodyMargin = (undefined !== data[1]) ? Number(data[1]) : bodyMargin; //For V1 compatibility\n\t\tcalculateWidth = (undefined !== data[2]) ? strBool(data[2]) : calculateWidth;\n\t\tlogging = (undefined !== data[3]) ? strBool(data[3]) : logging;\n\t\tinterval = (undefined !== data[4]) ? Number(data[4]) : interval;\n\t\tautoResize = (undefined !== data[6]) ? strBool(data[6]) : autoResize;\n\t\tbodyMarginStr = data[7];\n\t\theightCalcMode = (undefined !== data[8]) ? data[8] : heightCalcMode;\n\t\tbodyBackground = data[9];\n\t\tbodyPadding = data[10];\n\t\ttolerance = (undefined !== data[11]) ? Number(data[11]) : tolerance;\n\t\tinPageLinks.enable = (undefined !== data[12]) ? strBool(data[12]): false;\n\t\tresizeFrom = (undefined !== data[13]) ? data[13] : resizeFrom;\n\t\twidthCalcMode = (undefined !== data[14]) ? data[14] : widthCalcMode;\n\t}\n\n\tfunction readDataFromPage(){\n\t\tfunction readData(){\n\t\t\tvar data = window.iFrameResizer;\n\n\t\t\tlog('Reading data from page: ' + JSON.stringify(data));\n\n\t\t\tmessageCallback = ('messageCallback' in data) ? data.messageCallback : messageCallback;\n\t\t\treadyCallback = ('readyCallback' in data) ? data.readyCallback : readyCallback;\n\t\t\ttargetOriginDefault = ('targetOrigin' in data) ? data.targetOrigin : targetOriginDefault;\n\t\t\theightCalcMode = ('heightCalculationMethod' in data) ? data.heightCalculationMethod : heightCalcMode;\n\t\t\twidthCalcMode = ('widthCalculationMethod' in data) ? data.widthCalculationMethod : widthCalcMode;\n\t\t}\n\n\t\tfunction setupCustomCalcMethods(calcMode, calcFunc){\n\t\t\tif ('function' === typeof calcMode) {\n\t\t\t\tlog('Setup custom ' + calcFunc + 'CalcMethod');\n\t\t\t\tcustomCalcMethods[calcFunc] = calcMode;\n\t\t\t\tcalcMode = 'custom';\n\t\t\t}\n\n\t\t\treturn calcMode;\n\t\t}\n\n\t\tif(('iFrameResizer' in window) && (Object === window.iFrameResizer.constructor)) {\n\t\t\treadData();\n\t\t\theightCalcMode = setupCustomCalcMethods(heightCalcMode, 'height');\n\t\t\twidthCalcMode = setupCustomCalcMethods(widthCalcMode, 'width');\n\t\t}\n\n\t\tlog('TargetOrigin for parent set to: ' + targetOriginDefault);\n\t}\n\n\n\tfunction chkCSS(attr,value){\n\t\tif (-1 !== value.indexOf('-')){\n\t\t\twarn('Negative CSS value ignored for '+attr);\n\t\t\tvalue='';\n\t\t}\n\t\treturn value;\n\t}\n\n\tfunction setBodyStyle(attr,value){\n\t\tif ((undefined !== value) && ('' !== value) && ('null' !== value)){\n\t\t\tdocument.body.style[attr] = value;\n\t\t\tlog('Body '+attr+' set to \"'+value+'\"');\n\t\t}\n\t}\n\n\tfunction setMargin(){\n\t\t//If called via V1 script, convert bodyMargin from int to str\n\t\tif (undefined === bodyMarginStr){\n\t\t\tbodyMarginStr = bodyMargin+'px';\n\t\t}\n\n\t\tsetBodyStyle('margin',chkCSS('margin',bodyMarginStr));\n\t}\n\n\tfunction stopInfiniteResizingOfIFrame(){\n\t\tdocument.documentElement.style.height = '';\n\t\tdocument.body.style.height = '';\n\t\tlog('HTML & body height set to \"auto\"');\n\t}\n\n\n\tfunction manageTriggerEvent(options){\n\n\t\tvar listener = {\n\t\t\tadd: function(eventName){\n\t\t\t\tfunction handleEvent(){\n\t\t\t\t\tsendSize(options.eventName,options.eventType);\n\t\t\t\t}\n\n\t\t\t\teventHandlersByName[eventName] = handleEvent;\n\n\t\t\t\taddEventListener(window,eventName,handleEvent);\n\t\t\t},\n\t\t\tremove: function(eventName){\n\t\t\t\tvar handleEvent = eventHandlersByName[eventName];\n\t\t\t\tdelete eventHandlersByName[eventName];\n\n\t\t\t\tremoveEventListener(window,eventName,handleEvent);\n\t\t\t}\n\t\t};\n\n\t\tif(options.eventNames && Array.prototype.map){\n\t\t\toptions.eventName = options.eventNames[0];\n\t\t\toptions.eventNames.map(listener[options.method]);\n\t\t} else {\n\t\t\tlistener[options.method](options.eventName);\n\t\t}\n\n\t\tlog(capitalizeFirstLetter(options.method) + ' event listener: ' + options.eventType);\n\t}\n\n\tfunction manageEventListeners(method){\n\t\tmanageTriggerEvent({method:method, eventType: 'Animation Start', eventNames: ['animationstart','webkitAnimationStart'] });\n\t\tmanageTriggerEvent({method:method, eventType: 'Animation Iteration', eventNames: ['animationiteration','webkitAnimationIteration'] });\n\t\tmanageTriggerEvent({method:method, eventType: 'Animation End', eventNames: ['animationend','webkitAnimationEnd'] });\n\t\tmanageTriggerEvent({method:method, eventType: 'Input', eventName: 'input' });\n\t\tmanageTriggerEvent({method:method, eventType: 'Mouse Up', eventName: 'mouseup' });\n\t\tmanageTriggerEvent({method:method, eventType: 'Mouse Down', eventName: 'mousedown' });\n\t\tmanageTriggerEvent({method:method, eventType: 'Orientation Change', eventName: 'orientationchange' });\n\t\tmanageTriggerEvent({method:method, eventType: 'Print', eventName: ['afterprint', 'beforeprint'] });\n\t\tmanageTriggerEvent({method:method, eventType: 'Ready State Change', eventName: 'readystatechange' });\n\t\tmanageTriggerEvent({method:method, eventType: 'Touch Start', eventName: 'touchstart' });\n\t\tmanageTriggerEvent({method:method, eventType: 'Touch End', eventName: 'touchend' });\n\t\tmanageTriggerEvent({method:method, eventType: 'Touch Cancel', eventName: 'touchcancel' });\n\t\tmanageTriggerEvent({method:method, eventType: 'Transition Start', eventNames: ['transitionstart','webkitTransitionStart','MSTransitionStart','oTransitionStart','otransitionstart'] });\n\t\tmanageTriggerEvent({method:method, eventType: 'Transition Iteration', eventNames: ['transitioniteration','webkitTransitionIteration','MSTransitionIteration','oTransitionIteration','otransitioniteration'] });\n\t\tmanageTriggerEvent({method:method, eventType: 'Transition End', eventNames: ['transitionend','webkitTransitionEnd','MSTransitionEnd','oTransitionEnd','otransitionend'] });\n\t\tif('child' === resizeFrom){\n\t\t\tmanageTriggerEvent({method:method, eventType: 'IFrame Resized', eventName: 'resize' });\n\t\t}\n\t}\n\n\tfunction checkCalcMode(calcMode,calcModeDefault,modes,type){\n\t\tif (calcModeDefault !== calcMode){\n\t\t\tif (!(calcMode in modes)){\n\t\t\t\twarn(calcMode + ' is not a valid option for '+type+'CalculationMethod.');\n\t\t\t\tcalcMode=calcModeDefault;\n\t\t\t}\n\t\t\tlog(type+' calculation method set to \"'+calcMode+'\"');\n\t\t}\n\n\t\treturn calcMode;\n\t}\n\n\tfunction checkHeightMode(){\n\t\theightCalcMode = checkCalcMode(heightCalcMode,heightCalcModeDefault,getHeight,'height');\n\t}\n\n\tfunction checkWidthMode(){\n\t\twidthCalcMode = checkCalcMode(widthCalcMode,widthCalcModeDefault,getWidth,'width');\n\t}\n\n\tfunction startEventListeners(){\n\t\tif ( true === autoResize ) {\n\t\t\tmanageEventListeners('add');\n\t\t\tsetupMutationObserver();\n\t\t}\n\t\telse {\n\t\t\tlog('Auto Resize disabled');\n\t\t}\n\t}\n\n\tfunction stopMsgsToParent(){\n\t\tlog('Disable outgoing messages');\n\t\tsendPermit = false;\n\t}\n\n\tfunction removeMsgListener(){\n\t\tlog('Remove event listener: Message');\n\t\tremoveEventListener(window, 'message', receiver);\n\t}\n\n\tfunction disconnectMutationObserver(){\n\t\tif (null !== bodyObserver){\n\t\t\t/* istanbul ignore next */ // Not testable in PhantonJS\n\t\t\tbodyObserver.disconnect();\n\t\t}\n\t}\n\n\tfunction stopEventListeners(){\n\t\tmanageEventListeners('remove');\n\t\tdisconnectMutationObserver();\n\t\tclearInterval(intervalTimer);\n\t}\n\n\tfunction teardown(){\n\t\tstopMsgsToParent();\n\t\tremoveMsgListener();\n\t\tif (true === autoResize) stopEventListeners();\n\t}\n\n\tfunction injectClearFixIntoBodyElement(){\n\t\tvar clearFix = document.createElement('div');\n\t\tclearFix.style.clear = 'both';\n\t\tclearFix.style.display = 'block'; //Guard against this having been globally redefined in CSS.\n\t\tdocument.body.appendChild(clearFix);\n\t}\n\n\tfunction setupInPageLinks(){\n\n\t\tfunction getPagePosition (){\n\t\t\treturn {\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}\n\n\t\tfunction getElementPosition(el){\n\t\t\tvar\n\t\t\t\telPosition = el.getBoundingClientRect(),\n\t\t\t\tpagePosition = getPagePosition();\n\n\t\t\treturn {\n\t\t\t\tx: parseInt(elPosition.left,10) + parseInt(pagePosition.x,10),\n\t\t\t\ty: parseInt(elPosition.top,10) + parseInt(pagePosition.y,10)\n\t\t\t};\n\t\t}\n\n\t\tfunction findTarget(location){\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\tsendMsg(jumpPosition.y, jumpPosition.x, 'scrollToOffset'); // X&Y reversed at sendMsg uses height/width\n\t\t\t}\n\n\t\t\tvar\n\t\t\t\thash = location.split('#')[1] || location, //Remove # if present\n\t\t\t\thashData = decodeURIComponent(hash),\n\t\t\t\ttarget = document.getElementById(hashData) || document.getElementsByName(hashData)[0];\n\n\t\t\tif (undefined !== target){\n\t\t\t\tjumpToTarget(target);\n\t\t\t} else {\n\t\t\t\tlog('In page link (#' + hash + ') not found in iFrame, so sending to parent');\n\t\t\t\tsendMsg(0,0,'inPageLink','#'+hash);\n\t\t\t}\n\t\t}\n\n\t\tfunction checkLocationHash(){\n\t\t\tif ('' !== location.hash && '#' !== location.hash){\n\t\t\t\tfindTarget(location.href);\n\t\t\t}\n\t\t}\n\n\t\tfunction bindAnchors(){\n\t\t\tfunction setupLink(el){\n\t\t\t\tfunction linkClicked(e){\n\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\t/*jshint validthis:true */\n\t\t\t\t\tfindTarget(this.getAttribute('href'));\n\t\t\t\t}\n\n\t\t\t\tif ('#' !== el.getAttribute('href')){\n\t\t\t\t\taddEventListener(el,'click',linkClicked);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tArray.prototype.forEach.call( document.querySelectorAll( 'a[href^=\"#\"]' ), setupLink );\n\t\t}\n\n\t\tfunction bindLocationHash(){\n\t\t\taddEventListener(window,'hashchange',checkLocationHash);\n\t\t}\n\n\t\tfunction initCheck(){ //check if page loaded with location hash after init resize\n\t\t\tsetTimeout(checkLocationHash,eventCancelTimer);\n\t\t}\n\n\t\tfunction enableInPageLinks(){\n\t\t\t/* istanbul ignore else */ // Not testable in phantonJS\n\t\t\tif(Array.prototype.forEach && document.querySelectorAll){\n\t\t\t\tlog('Setting up location.hash handlers');\n\t\t\t\tbindAnchors();\n\t\t\t\tbindLocationHash();\n\t\t\t\tinitCheck();\n\t\t\t} else {\n\t\t\t\twarn('In page linking not fully supported in this browser! (See README.md for IE8 workaround)');\n\t\t\t}\n\t\t}\n\n\t\tif(inPageLinks.enable){\n\t\t\tenableInPageLinks();\n\t\t} else {\n\t\t\tlog('In page linking not enabled');\n\t\t}\n\n\t\treturn {\n\t\t\tfindTarget:findTarget\n\t\t};\n\t}\n\n\tfunction setupPublicMethods(){\n\t\tlog('Enable public methods');\n\n\t\twin.parentIFrame = {\n\n\t\t\tautoResize: function autoResizeF(resize){\n\t\t\t\tif (true === resize && false === autoResize) {\n\t\t\t\t\tautoResize=true;\n\t\t\t\t\tstartEventListeners();\n\t\t\t\t\t//sendSize('autoResize','Auto Resize enabled');\n\t\t\t\t} else if (false === resize && true === autoResize) {\n\t\t\t\t\tautoResize=false;\n\t\t\t\t\tstopEventListeners();\n\t\t\t\t}\n\n\t\t\t\treturn autoResize;\n\t\t\t},\n\n\t\t\tclose: function closeF(){\n\t\t\t\tsendMsg(0,0,'close');\n\t\t\t\tteardown();\n\t\t\t},\n\n\t\t\tgetId: function getIdF(){\n\t\t\t\treturn myID;\n\t\t\t},\n\n\t\t\tgetPageInfo: function getPageInfoF(callback){\n\t\t\t\tif ('function' === typeof callback){\n\t\t\t\t\tpageInfoCallback = callback;\n\t\t\t\t\tsendMsg(0,0,'pageInfo');\n\t\t\t\t} else {\n\t\t\t\t\tpageInfoCallback = function(){};\n\t\t\t\t\tsendMsg(0,0,'pageInfoStop');\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tmoveToAnchor: function moveToAnchorF(hash){\n\t\t\t\tinPageLinks.findTarget(hash);\n\t\t\t},\n\n\t\t\treset: function resetF(){\n\t\t\t\tresetIFrame('parentIFrame.reset');\n\t\t\t},\n\n\t\t\tscrollTo: function scrollToF(x,y){\n\t\t\t\tsendMsg(y,x,'scrollTo'); // X&Y reversed at sendMsg uses height/width\n\t\t\t},\n\n\t\t\tscrollToOffset: function scrollToF(x,y){\n\t\t\t\tsendMsg(y,x,'scrollToOffset'); // X&Y reversed at sendMsg uses height/width\n\t\t\t},\n\n\t\t\tsendMessage: function sendMessageF(msg,targetOrigin){\n\t\t\t\tsendMsg(0,0,'message',JSON.stringify(msg),targetOrigin);\n\t\t\t},\n\n\t\t\tsetHeightCalculationMethod: function setHeightCalculationMethodF(heightCalculationMethod){\n\t\t\t\theightCalcMode = heightCalculationMethod;\n\t\t\t\tcheckHeightMode();\n\t\t\t},\n\n\t\t\tsetWidthCalculationMethod: function setWidthCalculationMethodF(widthCalculationMethod){\n\t\t\t\twidthCalcMode = widthCalculationMethod;\n\t\t\t\tcheckWidthMode();\n\t\t\t},\n\n\t\t\tsetTargetOrigin: function setTargetOriginF(targetOrigin){\n\t\t\t\tlog('Set targetOrigin: '+targetOrigin);\n\t\t\t\ttargetOriginDefault = targetOrigin;\n\t\t\t},\n\n\t\t\tsize: function sizeF(customHeight, customWidth){\n\t\t\t\tvar valString = ''+(customHeight?customHeight:'')+(customWidth?','+customWidth:'');\n\t\t\t\t//lockTrigger();\n\t\t\t\tsendSize('size','parentIFrame.size('+valString+')', customHeight, customWidth);\n\t\t\t}\n\t\t};\n\t}\n\n\tfunction initInterval(){\n\t\tif ( 0 !== interval ){\n\t\t\tlog('setInterval: '+interval+'ms');\n\t\t\tintervalTimer = setInterval(function(){\n\t\t\t\tsendSize('interval','setInterval: '+interval);\n\t\t\t},Math.abs(interval));\n\t\t}\n\t}\n\n\t/* istanbul ignore next */ //Not testable in PhantomJS\n\tfunction setupBodyMutationObserver(){\n\t\tfunction addImageLoadListners(mutation) {\n\t\t\tfunction addImageLoadListener(element){\n\t\t\t\tif (false === element.complete) {\n\t\t\t\t\tlog('Attach listeners to ' + element.src);\n\t\t\t\t\telement.addEventListener('load', imageLoaded, false);\n\t\t\t\t\telement.addEventListener('error', imageError, false);\n\t\t\t\t\telements.push(element);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (mutation.type === 'attributes' && mutation.attributeName === 'src'){\n\t\t\t\taddImageLoadListener(mutation.target);\n\t\t\t} else if (mutation.type === 'childList'){\n\t\t\t\tArray.prototype.forEach.call(\n\t\t\t\t\tmutation.target.querySelectorAll('img'),\n\t\t\t\t\taddImageLoadListener\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tfunction removeFromArray(element){\n\t\t\telements.splice(elements.indexOf(element),1);\n\t\t}\n\n\t\tfunction removeImageLoadListener(element){\n\t\t\tlog('Remove listeners from ' + element.src);\n\t\t\telement.removeEventListener('load', imageLoaded, false);\n\t\t\telement.removeEventListener('error', imageError, false);\n\t\t\tremoveFromArray(element);\n\t\t}\n\n\t\tfunction imageEventTriggered(event,type,typeDesc){\n\t\t\tremoveImageLoadListener(event.target);\n\t\t\tsendSize(type, typeDesc + ': ' + event.target.src, undefined, undefined);\n\t\t}\n\n\t\tfunction imageLoaded(event) {\n\t\t\timageEventTriggered(event,'imageLoad','Image loaded');\n\t\t}\n\n\t\tfunction imageError(event) {\n\t\t\timageEventTriggered(event,'imageLoadFailed','Image load failed');\n\t\t}\n\n\t\tfunction mutationObserved(mutations) {\n\t\t\tsendSize('mutationObserver','mutationObserver: ' + mutations[0].target + ' ' + mutations[0].type);\n\n\t\t\t//Deal with WebKit asyncing image loading when tags are injected into the page\n\t\t\tmutations.forEach(addImageLoadListners);\n\t\t}\n\n\t\tfunction createMutationObserver(){\n\t\t\tvar\n\t\t\t\ttarget = document.querySelector('body'),\n\n\t\t\t\tconfig = {\n\t\t\t\t\tattributes : true,\n\t\t\t\t\tattributeOldValue : false,\n\t\t\t\t\tcharacterData : true,\n\t\t\t\t\tcharacterDataOldValue : false,\n\t\t\t\t\tchildList : true,\n\t\t\t\t\tsubtree : true\n\t\t\t\t};\n\n\t\t\tobserver = new MutationObserver(mutationObserved);\n\n\t\t\tlog('Create body MutationObserver');\n\t\t\tobserver.observe(target, config);\n\n\t\t\treturn observer;\n\t\t}\n\n\t\tvar\n\t\t\telements = [],\n\t\t\tMutationObserver = window.MutationObserver || window.WebKitMutationObserver,\n\t\t\tobserver = createMutationObserver();\n\n\t\treturn {\n\t\t\tdisconnect: function (){\n\t\t\t\tif ('disconnect' in observer){\n\t\t\t\t\tlog('Disconnect body MutationObserver');\n\t\t\t\t\tobserver.disconnect();\n\t\t\t\t\telements.forEach(removeImageLoadListener);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n\tfunction setupMutationObserver(){\n\t\tvar\tforceIntervalTimer = 0 > interval;\n\n\t\t/* istanbul ignore if */ // Not testable in PhantomJS\n\t\tif (window.MutationObserver || window.WebKitMutationObserver){\n\t\t\tif (forceIntervalTimer) {\n\t\t\t\tinitInterval();\n\t\t\t} else {\n\t\t\t\tbodyObserver = setupBodyMutationObserver();\n\t\t\t}\n\t\t} else {\n\t\t\tlog('MutationObserver not supported in this browser!');\n\t\t\tinitInterval();\n\t\t}\n\t}\n\n\n\t// document.documentElement.offsetHeight is not reliable, so\n\t// we have to jump through hoops to get a better value.\n\tfunction getComputedStyle(prop,el) {\n\t\t/* istanbul ignore next */ //Not testable in PhantomJS\n\t\tfunction convertUnitsToPxForIE8(value) {\n\t\t\tvar PIXEL = /^\\d+(px)?$/i;\n\n\t\t\tif (PIXEL.test(value)) {\n\t\t\t\treturn parseInt(value,base);\n\t\t\t}\n\n\t\t\tvar\n\t\t\t\tstyle = el.style.left,\n\t\t\t\truntimeStyle = el.runtimeStyle.left;\n\n\t\t\tel.runtimeStyle.left = el.currentStyle.left;\n\t\t\tel.style.left = value || 0;\n\t\t\tvalue = el.style.pixelLeft;\n\t\t\tel.style.left = style;\n\t\t\tel.runtimeStyle.left = runtimeStyle;\n\n\t\t\treturn value;\n\t\t}\n\n\t\tvar retVal = 0;\n\t\tel = el || document.body;\n\n\t\t/* istanbul ignore else */ // Not testable in phantonJS\n\t\tif (('defaultView' in document) && ('getComputedStyle' in document.defaultView)) {\n\t\t\tretVal = document.defaultView.getComputedStyle(el, null);\n\t\t\tretVal = (null !== retVal) ? retVal[prop] : 0;\n\t\t} else {//IE8\n\t\t\tretVal = convertUnitsToPxForIE8(el.currentStyle[prop]);\n\t\t}\n\n\t\treturn parseInt(retVal,base);\n\t}\n\n\tfunction chkEventThottle(timer){\n\t\tif(timer > throttledTimer/2){\n\t\t\tthrottledTimer = 2*timer;\n\t\t\tlog('Event throttle increased to ' + throttledTimer + 'ms');\n\t\t}\n\t}\n\n\t//Idea from https://github.com/guardian/iframe-messenger\n\tfunction getMaxElement(side,elements) {\n\t\tvar\n\t\t\telementsLength = elements.length,\n\t\t\telVal = 0,\n\t\t\tmaxVal = 0,\n\t\t\tSide = capitalizeFirstLetter(side),\n\t\t\ttimer = getNow();\n\n\t\tfor (var i = 0; i < elementsLength; i++) {\n\t\t\telVal = elements[i].getBoundingClientRect()[side] + getComputedStyle('margin'+Side,elements[i]);\n\t\t\tif (elVal > maxVal) {\n\t\t\t\tmaxVal = elVal;\n\t\t\t}\n\t\t}\n\n\t\ttimer = getNow() - timer;\n\n\t\tlog('Parsed '+elementsLength+' HTML elements');\n\t\tlog('Element position calculated in ' + timer + 'ms');\n\n\t\tchkEventThottle(timer);\n\n\t\treturn maxVal;\n\t}\n\n\tfunction getAllMeasurements(dimention){\n\t\treturn [\n\t\t\tdimention.bodyOffset(),\n\t\t\tdimention.bodyScroll(),\n\t\t\tdimention.documentElementOffset(),\n\t\t\tdimention.documentElementScroll()\n\t\t];\n\t}\n\n\tfunction getTaggedElements(side,tag){\n\t\tfunction noTaggedElementsFound(){\n\t\t\twarn('No tagged elements ('+tag+') found on page');\n\t\t\treturn document.querySelectorAll('body *');\n\t\t}\n\n\t\tvar elements = document.querySelectorAll('['+tag+']');\n\n\t\tif (0 === elements.length) noTaggedElementsFound();\n\n\t\treturn getMaxElement(side,elements);\n\t}\n\n\tfunction getAllElements(){\n\t\treturn document.querySelectorAll('body *');\n\t}\n\n\tvar\n\t\tgetHeight = {\n\t\t\tbodyOffset: function getBodyOffsetHeight(){\n\t\t\t\treturn document.body.offsetHeight + getComputedStyle('marginTop') + getComputedStyle('marginBottom');\n\t\t\t},\n\n\t\t\toffset: function(){\n\t\t\t\treturn getHeight.bodyOffset(); //Backwards compatability\n\t\t\t},\n\n\t\t\tbodyScroll: function getBodyScrollHeight(){\n\t\t\t\treturn document.body.scrollHeight;\n\t\t\t},\n\n\t\t\tcustom: function getCustomWidth(){\n\t\t\t\treturn customCalcMethods.height();\n\t\t\t},\n\n\t\t\tdocumentElementOffset: function getDEOffsetHeight(){\n\t\t\t\treturn document.documentElement.offsetHeight;\n\t\t\t},\n\n\t\t\tdocumentElementScroll: function getDEScrollHeight(){\n\t\t\t\treturn document.documentElement.scrollHeight;\n\t\t\t},\n\n\t\t\tmax: function getMaxHeight(){\n\t\t\t\treturn Math.max.apply(null,getAllMeasurements(getHeight));\n\t\t\t},\n\n\t\t\tmin: function getMinHeight(){\n\t\t\t\treturn Math.min.apply(null,getAllMeasurements(getHeight));\n\t\t\t},\n\n\t\t\tgrow: function growHeight(){\n\t\t\t\treturn getHeight.max(); //Run max without the forced downsizing\n\t\t\t},\n\n\t\t\tlowestElement: function getBestHeight(){\n\t\t\t\treturn Math.max(getHeight.bodyOffset(), getMaxElement('bottom',getAllElements()));\n\t\t\t},\n\n\t\t\ttaggedElement: function getTaggedElementsHeight(){\n\t\t\t\treturn getTaggedElements('bottom','data-iframe-height');\n\t\t\t}\n\t\t},\n\n\t\tgetWidth = {\n\t\t\tbodyScroll: function getBodyScrollWidth(){\n\t\t\t\treturn document.body.scrollWidth;\n\t\t\t},\n\n\t\t\tbodyOffset: function getBodyOffsetWidth(){\n\t\t\t\treturn document.body.offsetWidth;\n\t\t\t},\n\n\t\t\tcustom: function getCustomWidth(){\n\t\t\t\treturn customCalcMethods.width();\n\t\t\t},\n\n\t\t\tdocumentElementScroll: function getDEScrollWidth(){\n\t\t\t\treturn document.documentElement.scrollWidth;\n\t\t\t},\n\n\t\t\tdocumentElementOffset: function getDEOffsetWidth(){\n\t\t\t\treturn document.documentElement.offsetWidth;\n\t\t\t},\n\n\t\t\tscroll: function getMaxWidth(){\n\t\t\t\treturn Math.max(getWidth.bodyScroll(), getWidth.documentElementScroll());\n\t\t\t},\n\n\t\t\tmax: function getMaxWidth(){\n\t\t\t\treturn Math.max.apply(null,getAllMeasurements(getWidth));\n\t\t\t},\n\n\t\t\tmin: function getMinWidth(){\n\t\t\t\treturn Math.min.apply(null,getAllMeasurements(getWidth));\n\t\t\t},\n\n\t\t\trightMostElement: function rightMostElement(){\n\t\t\t\treturn getMaxElement('right', getAllElements());\n\t\t\t},\n\n\t\t\ttaggedElement: function getTaggedElementsWidth(){\n\t\t\t\treturn getTaggedElements('right', 'data-iframe-width');\n\t\t\t}\n\t\t};\n\n\n\tfunction sizeIFrame(triggerEvent, triggerEventDesc, customHeight, customWidth){\n\n\t\tfunction resizeIFrame(){\n\t\t\theight = currentHeight;\n\t\t\twidth = currentWidth;\n\n\t\t\tsendMsg(height,width,triggerEvent);\n\t\t}\n\n\t\tfunction isSizeChangeDetected(){\n\t\t\tfunction checkTolarance(a,b){\n\t\t\t\tvar retVal = Math.abs(a-b) <= tolerance;\n\t\t\t\treturn !retVal;\n\t\t\t}\n\n\t\t\tcurrentHeight = (undefined !== customHeight) ? customHeight : getHeight[heightCalcMode]();\n\t\t\tcurrentWidth = (undefined !== customWidth ) ? customWidth : getWidth[widthCalcMode]();\n\n\t\t\treturn\tcheckTolarance(height,currentHeight) || (calculateWidth && checkTolarance(width,currentWidth));\n\t\t}\n\n\t\tfunction isForceResizableEvent(){\n\t\t\treturn !(triggerEvent in {'init':1,'interval':1,'size':1});\n\t\t}\n\n\t\tfunction isForceResizableCalcMode(){\n\t\t\treturn (heightCalcMode in resetRequiredMethods) || (calculateWidth && widthCalcMode in resetRequiredMethods);\n\t\t}\n\n\t\tfunction logIgnored(){\n\t\t\tlog('No change in size detected');\n\t\t}\n\n\t\tfunction checkDownSizing(){\n\t\t\tif (isForceResizableEvent() && isForceResizableCalcMode()){\n\t\t\t\tresetIFrame(triggerEventDesc);\n\t\t\t} else if (!(triggerEvent in {'interval':1})){\n\t\t\t\tlogIgnored();\n\t\t\t}\n\t\t}\n\n\t\tvar\tcurrentHeight,currentWidth;\n\n\t\tif (isSizeChangeDetected() || 'init' === triggerEvent){\n\t\t\tlockTrigger();\n\t\t\tresizeIFrame();\n\t\t} else {\n\t\t\tcheckDownSizing();\n\t\t}\n\t}\n\n\tvar sizeIFrameThrottled = throttle(sizeIFrame);\n\n\tfunction sendSize(triggerEvent, triggerEventDesc, customHeight, customWidth){\n\t\tfunction recordTrigger(){\n\t\t\tif (!(triggerEvent in {'reset':1,'resetPage':1,'init':1})){\n\t\t\t\tlog( 'Trigger event: ' + triggerEventDesc );\n\t\t\t}\n\t\t}\n\n\t\tfunction isDoubleFiredEvent(){\n\t\t\treturn triggerLocked && (triggerEvent in doubleEventList);\n\t\t}\n\n\t\tif (!isDoubleFiredEvent()){\n\t\t\trecordTrigger();\n\t\t\tsizeIFrameThrottled(triggerEvent, triggerEventDesc, customHeight, customWidth);\n\t\t} else {\n\t\t\tlog('Trigger event cancelled: '+triggerEvent);\n\t\t}\n\t}\n\n\tfunction lockTrigger(){\n\t\tif (!triggerLocked){\n\t\t\ttriggerLocked = true;\n\t\t\tlog('Trigger event lock on');\n\t\t}\n\t\tclearTimeout(triggerLockedTimer);\n\t\ttriggerLockedTimer = setTimeout(function(){\n\t\t\ttriggerLocked = false;\n\t\t\tlog('Trigger event lock off');\n\t\t\tlog('--');\n\t\t},eventCancelTimer);\n\t}\n\n\tfunction triggerReset(triggerEvent){\n\t\theight = getHeight[heightCalcMode]();\n\t\twidth = getWidth[widthCalcMode]();\n\n\t\tsendMsg(height,width,triggerEvent);\n\t}\n\n\tfunction resetIFrame(triggerEventDesc){\n\t\tvar hcm = heightCalcMode;\n\t\theightCalcMode = heightCalcModeDefault;\n\n\t\tlog('Reset trigger event: ' + triggerEventDesc);\n\t\tlockTrigger();\n\t\ttriggerReset('reset');\n\n\t\theightCalcMode = hcm;\n\t}\n\n\tfunction sendMsg(height,width,triggerEvent,msg,targetOrigin){\n\t\tfunction setTargetOrigin(){\n\t\t\tif (undefined === targetOrigin){\n\t\t\t\ttargetOrigin = targetOriginDefault;\n\t\t\t} else {\n\t\t\t\tlog('Message targetOrigin: '+targetOrigin);\n\t\t\t}\n\t\t}\n\n\t\tfunction sendToParent(){\n\t\t\tvar\n\t\t\t\tsize = height + ':' + width,\n\t\t\t\tmessage = myID + ':' + size + ':' + triggerEvent + (undefined !== msg ? ':' + msg : '');\n\n\t\t\tlog('Sending message to host page (' + message + ')');\n\t\t\ttarget.postMessage( msgID + message, targetOrigin);\n\t\t}\n\n\t\tif(true === sendPermit){\n\t\t\tsetTargetOrigin();\n\t\t\tsendToParent();\n\t\t}\n\t}\n\n\tfunction receiver(event) {\n\t\tvar processRequestFromParent = {\n\t\t\tinit: function initFromParent(){\n\t\t\t\tfunction fireInit(){\n\t\t\t\t\tinitMsg = event.data;\n\t\t\t\t\ttarget = event.source;\n\n\t\t\t\t\tinit();\n\t\t\t\t\tfirstRun = false;\n\t\t\t\t\tsetTimeout(function(){ initLock = false;},eventCancelTimer);\n\t\t\t\t}\n\n\t\t\t\tif (document.body){\n\t\t\t\t\tfireInit();\n\t\t\t\t} else {\n\t\t\t\t\tlog('Waiting for page ready');\n\t\t\t\t\taddEventListener(window,'readystatechange',processRequestFromParent.initFromParent);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\treset: function resetFromParent(){\n\t\t\t\tif (!initLock){\n\t\t\t\t\tlog('Page size reset by host page');\n\t\t\t\t\ttriggerReset('resetPage');\n\t\t\t\t} else {\n\t\t\t\t\tlog('Page reset ignored by init');\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tresize: function resizeFromParent(){\n\t\t\t\tsendSize('resizeParent','Parent window requested size check');\n\t\t\t},\n\n\t\t\tmoveToAnchor: function moveToAnchorF(){\n\t\t\t\tinPageLinks.findTarget(getData());\n\t\t\t},\n\t\t\tinPageLink: function inPageLinkF() {this.moveToAnchor();}, //Backward compatability\n\n\t\t\tpageInfo: function pageInfoFromParent(){\n\t\t\t\tvar msgBody = getData();\n\t\t\t\tlog('PageInfoFromParent called from parent: ' + msgBody );\n\t\t\t\tpageInfoCallback(JSON.parse(msgBody));\n\t\t\t\tlog(' --');\n\t\t\t},\n\n\t\t\tmessage: function messageFromParent(){\n\t\t\t\tvar msgBody = getData();\n\n\t\t\t\tlog('MessageCallback called from parent: ' + msgBody );\n\t\t\t\tmessageCallback(JSON.parse(msgBody));\n\t\t\t\tlog(' --');\n\t\t\t}\n\t\t};\n\n\t\tfunction isMessageForUs(){\n\t\t\treturn msgID === (''+event.data).substr(0,msgIdLen); //''+ Protects against non-string messages\n\t\t}\n\n\t\tfunction getMessageType(){\n\t\t\treturn event.data.split(']')[1].split(':')[0];\n\t\t}\n\n\t\tfunction getData(){\n\t\t\treturn event.data.substr(event.data.indexOf(':')+1);\n\t\t}\n\n\t\tfunction isMiddleTier(){\n\t\t\treturn ('iFrameResize' in window);\n\t\t}\n\n\t\tfunction isInitMsg(){\n\t\t\t//Test if this message is from a child below us. This is an ugly test, however, updating\n\t\t\t//the message format would break backwards compatibity.\n\t\t\treturn event.data.split(':')[2] in {'true':1,'false':1};\n\t\t}\n\n\t\tfunction callFromParent(){\n\t\t\tvar messageType = getMessageType();\n\n\t\t\tif (messageType in processRequestFromParent){\n\t\t\t\tprocessRequestFromParent[messageType]();\n\t\t\t} else if (!isMiddleTier() && !isInitMsg()){\n\t\t\t\twarn('Unexpected message ('+event.data+')');\n\t\t\t}\n\t\t}\n\n\t\tfunction processMessage(){\n\t\t\tif (false === firstRun) {\n\t\t\t\tcallFromParent();\n\t\t\t} else if (isInitMsg()) {\n\t\t\t\tprocessRequestFromParent.init();\n\t\t\t} else {\n\t\t\t\tlog('Ignored message of type \"' + getMessageType() + '\". Received before initialization.');\n\t\t\t}\n\t\t}\n\n\t\tif (isMessageForUs()){\n\t\t\tprocessMessage();\n\t\t}\n\t}\n\n\t//Normally the parent kicks things off when it detects the iFrame has loaded.\n\t//If this script is async-loaded, then tell parent page to retry init.\n\tfunction chkLateLoaded(){\n\t\tif('loading' !== document.readyState){\n\t\t\twindow.parent.postMessage('[iFrameResizerChild]Ready','*');\n\t\t}\n\t}\n\n\taddEventListener(window, 'message', receiver);\n\tchkLateLoaded();\n\n\t\n\n})(window || {});\n"]}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
/*! iFrame Resizer (iframeSizer.contentWindow.min.js) - v3.5.7 - 2016-12-16
|
2
|
+
* Desc: Include this file in any page being loaded into an iframe
|
3
|
+
* to force the iframe to resize to the content size.
|
4
|
+
* Requires: iframeResizer.min.js on host page.
|
5
|
+
* Copyright: (c) 2016 David J. Bradshaw - dave@bradshaw.net
|
6
|
+
* License: MIT
|
7
|
+
*/
|
8
|
+
|
9
|
+
!function(a,b){"use strict";function c(b,c,d){"addEventListener"in a?b.addEventListener(c,d,!1):"attachEvent"in a&&b.attachEvent("on"+c,d)}function d(b,c,d){"removeEventListener"in a?b.removeEventListener(c,d,!1):"detachEvent"in a&&b.detachEvent("on"+c,d)}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=Ia(),e=null,d=a.apply(b,c),e||(b=c=null)};return function(){var h=Ia();f||(f=h);var i=ya-(h-f);return b=this,c=arguments,0>=i||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(b){ma&&"object"==typeof a.console&&console.log(g(b))}function i(b){"object"==typeof a.console&&console.warn(g(b))}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 a(a){return"true"===a?!0:!1}var c=ia.substr(oa).split(":");pa=c[0],Y=b!==c[1]?Number(c[1]):Y,aa=b!==c[2]?a(c[2]):aa,ma=b!==c[3]?a(c[3]):ma,ka=b!==c[4]?Number(c[4]):ka,V=b!==c[6]?a(c[6]):V,Z=c[7],ga=b!==c[8]?c[8]:ga,X=c[9],_=c[10],va=b!==c[11]?Number(c[11]):va,ja.enable=b!==c[12]?a(c[12]):!1,ra=b!==c[13]?c[13]:ra,Ba=b!==c[14]?c[14]:Ba}function l(){function b(){var b=a.iFrameResizer;h("Reading data from page: "+JSON.stringify(b)),Da="messageCallback"in b?b.messageCallback:Da,Ea="readyCallback"in b?b.readyCallback:Ea,ua="targetOrigin"in b?b.targetOrigin:ua,ga="heightCalculationMethod"in b?b.heightCalculationMethod:ga,Ba="widthCalculationMethod"in b?b.widthCalculationMethod:Ba}function c(a,b){return"function"==typeof a&&(h("Setup custom "+b+"CalcMethod"),Ga[b]=a,a="custom"),a}"iFrameResizer"in a&&Object===a.iFrameResizer.constructor&&(b(),ga=c(ga,"height"),Ba=c(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(a,c){b!==c&&""!==c&&"null"!==c&&(document.body.style[a]=c,h("Body "+a+' set to "'+c+'"'))}function o(){b===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(b){var f={add:function(d){function e(){O(b.eventName,b.eventType)}Ha[d]=e,c(a,d,e)},remove:function(b){var c=Ha[b];delete Ha[b],d(a,b,c)}};b.eventNames&&Array.prototype.map?(b.eventName=b.eventNames[0],b.eventNames.map(f[b.method])):f[b.method](b.eventName),h(e(b.method)+" event listener: "+b.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,Ja,"height")}function u(){Ba=s(Ba,Aa,Ka,"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(a,"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 d(){return{x:a.pageXOffset!==b?a.pageXOffset:document.documentElement.scrollLeft,y:a.pageYOffset!==b?a.pageYOffset:document.documentElement.scrollTop}}function e(a){var b=a.getBoundingClientRect(),c=d();return{x:parseInt(b.left,10)+parseInt(c.x,10),y:parseInt(b.top,10)+parseInt(c.y,10)}}function f(a){function c(a){var b=e(a);h("Moving to in page link (#"+d+") at x: "+b.x+" y: "+b.y),S(b.y,b.x,"scrollToOffset")}var d=a.split("#")[1]||a,f=decodeURIComponent(d),g=document.getElementById(f)||document.getElementsByName(f)[0];b!==g?c(g):(h("In page link (#"+d+") not found in iFrame, so sending to parent"),S(0,0,"inPageLink","#"+d))}function g(){""!==location.hash&&"#"!==location.hash&&f(location.href)}function j(){function a(a){function b(a){a.preventDefault(),f(this.getAttribute("href"))}"#"!==a.getAttribute("href")&&c(a,"click",b)}Array.prototype.forEach.call(document.querySelectorAll('a[href^="#"]'),a)}function k(){c(a,"hashchange",g)}function l(){setTimeout(g,ca)}function m(){Array.prototype.forEach&&document.querySelectorAll?(h("Setting up location.hash handlers"),j(),k(),l()):i("In page linking not fully supported in this browser! (See README.md for IE8 workaround)")}return ja.enable?m():h("In page linking not enabled"),{findTarget:f}}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){var c=""+(a?a:"")+(b?","+b:"");O("size","parentIFrame.size("+c+")",a,b)}}}function E(){0!==ka&&(h("setInterval: "+ka+"ms"),la=setInterval(function(){O("interval","setInterval: "+ka)},Math.abs(ka)))}function F(){function c(a){function b(a){!1===a.complete&&(h("Attach listeners to "+a.src),a.addEventListener("load",g,!1),a.addEventListener("error",i,!1),l.push(a))}"attributes"===a.type&&"src"===a.attributeName?b(a.target):"childList"===a.type&&Array.prototype.forEach.call(a.target.querySelectorAll("img"),b)}function d(a){l.splice(l.indexOf(a),1)}function e(a){h("Remove listeners from "+a.src),a.removeEventListener("load",g,!1),a.removeEventListener("error",i,!1),d(a)}function f(a,c,d){e(a.target),O(c,d+": "+a.target.src,b,b)}function g(a){f(a,"imageLoad","Image loaded")}function i(a){f(a,"imageLoadFailed","Image load failed")}function j(a){O("mutationObserver","mutationObserver: "+a[0].target+" "+a[0].type),a.forEach(c)}function k(){var a=document.querySelector("body"),b={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0};return n=new m(j),h("Create body MutationObserver"),n.observe(a,b),n}var l=[],m=a.MutationObserver||a.WebKitMutationObserver,n=k();return{disconnect:function(){"disconnect"in n&&(h("Disconnect body MutationObserver"),n.disconnect(),l.forEach(e))}}}function G(){var b=0>ka;a.MutationObserver||a.WebKitMutationObserver?b?E():$=F():(h("MutationObserver not supported in this browser!"),E())}function H(a,b){function c(a){var c=/^\d+(px)?$/i;if(c.test(a))return parseInt(a,W);var d=b.style.left,e=b.runtimeStyle.left;return b.runtimeStyle.left=b.currentStyle.left,b.style.left=a||0,a=b.style.pixelLeft,b.style.left=d,b.runtimeStyle.left=e,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=Ia(),j=0;c>j;j++)d=b[j].getBoundingClientRect()[a]+H("margin"+g,b[j]),d>f&&(f=d);return i=Ia()-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(a,c,d,e){function f(){ea=m,za=n,S(ea,za,a)}function g(){function a(a,b){var c=Math.abs(a-b)<=va;return!c}return m=b!==d?d:Ja[ga](),n=b!==e?e:Ka[Ba](),a(ea,m)||aa&&a(za,n)}function i(){return!(a 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):a in{interval:1}||k()}var m,n;g()||"init"===a?(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(),La(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=Ja[ga](),za=Ka[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(a,c,d,e,f){function g(){b===f?f=ua:h("Message targetOrigin: "+f)}function i(){var g=a+":"+c,i=pa+":"+g+":"+d+(b!==e?":"+e:"");h("Sending message to host page ("+i+")"),ta.postMessage(na+i,f)}!0===sa&&(g(),i())}function T(b){function d(){return na===(""+b.data).substr(0,oa)}function e(){return b.data.split("]")[1].split(":")[0]}function f(){return b.data.substr(b.data.indexOf(":")+1)}function g(){return"iFrameResize"in a}function k(){return b.data.split(":")[2]in{"true":1,"false":1}}function l(){var a=e();a in n?n[a]():g()||k()||i("Unexpected message ("+b.data+")")}function m(){!1===da?l():k()?n.init():h('Ignored message of type "'+e()+'". Received before initialization.')}var n={init:function(){function d(){ia=b.data,ta=b.source,j(),da=!1,setTimeout(function(){ha=!1},ca)}document.body?d():(h("Waiting for page ready"),c(a,"readystatechange",n.initFromParent))},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(f())},inPageLink:function(){this.moveToAnchor()},pageInfo:function(){var a=f();h("PageInfoFromParent called from parent: "+a),Fa(JSON.parse(a)),h(" --")},message:function(){var a=f();h("MessageCallback called from parent: "+a),Da(JSON.parse(a)),h(" --")}};d()&&m()}function U(){"loading"!==document.readyState&&a.parent.postMessage("[iFrameResizerChild]Ready","*")}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=a.parent,ua="*",va=0,wa=!1,xa=null,ya=16,za=1,Aa="scroll",Ba=Aa,Ca=a,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=Date.now||function(){return(new Date).getTime()},Ja={bodyOffset:function(){return document.body.offsetHeight+H("marginTop")+H("marginBottom")},offset:function(){return Ja.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(Ja))},min:function(){return Math.min.apply(null,K(Ja))},grow:function(){return Ja.max()},lowestElement:function(){return Math.max(Ja.bodyOffset(),J("bottom",M()))},taggedElement:function(){return L("bottom","data-iframe-height")}},Ka={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(Ka.bodyScroll(),Ka.documentElementScroll())},max:function(){return Math.max.apply(null,K(Ka))},min:function(){return Math.min.apply(null,K(Ka))},rightMostElement:function(){return J("right",M())},taggedElement:function(){return L("right","data-iframe-width")}},La=f(N);c(a,"message",T),U()}(window||{});
|
10
|
+
//# sourceMappingURL=iframeResizer.contentWindow.map
|
@@ -0,0 +1,1007 @@
|
|
1
|
+
/*
|
2
|
+
* File: iframeResizer.js
|
3
|
+
* Desc: Force iframes to size to content.
|
4
|
+
* Requires: iframeResizer.contentWindow.js to be loaded into the target frame.
|
5
|
+
* Doc: https://github.com/davidjbradshaw/iframe-resizer
|
6
|
+
* Author: David J. Bradshaw - dave@bradshaw.net
|
7
|
+
* Contributor: Jure Mav - jure.mav@gmail.com
|
8
|
+
* Contributor: Reed Dadoune - reed@dadoune.com
|
9
|
+
*/
|
10
|
+
|
11
|
+
|
12
|
+
;(function(window) {
|
13
|
+
'use strict';
|
14
|
+
|
15
|
+
var
|
16
|
+
count = 0,
|
17
|
+
logEnabled = false,
|
18
|
+
hiddenCheckEnabled = false,
|
19
|
+
msgHeader = 'message',
|
20
|
+
msgHeaderLen = msgHeader.length,
|
21
|
+
msgId = '[iFrameSizer]', //Must match iframe msg ID
|
22
|
+
msgIdLen = msgId.length,
|
23
|
+
pagePosition = null,
|
24
|
+
requestAnimationFrame = window.requestAnimationFrame,
|
25
|
+
resetRequiredMethods = {max:1,scroll:1,bodyScroll:1,documentElementScroll:1},
|
26
|
+
settings = {},
|
27
|
+
timer = null,
|
28
|
+
logId = 'Host Page',
|
29
|
+
|
30
|
+
defaults = {
|
31
|
+
autoResize : true,
|
32
|
+
bodyBackground : null,
|
33
|
+
bodyMargin : null,
|
34
|
+
bodyMarginV1 : 8,
|
35
|
+
bodyPadding : null,
|
36
|
+
checkOrigin : true,
|
37
|
+
inPageLinks : false,
|
38
|
+
enablePublicMethods : true,
|
39
|
+
heightCalculationMethod : 'bodyOffset',
|
40
|
+
id : 'iFrameResizer',
|
41
|
+
interval : 32,
|
42
|
+
log : false,
|
43
|
+
maxHeight : Infinity,
|
44
|
+
maxWidth : Infinity,
|
45
|
+
minHeight : 0,
|
46
|
+
minWidth : 0,
|
47
|
+
resizeFrom : 'parent',
|
48
|
+
scrolling : false,
|
49
|
+
sizeHeight : true,
|
50
|
+
sizeWidth : false,
|
51
|
+
tolerance : 0,
|
52
|
+
widthCalculationMethod : 'scroll',
|
53
|
+
closedCallback : function(){},
|
54
|
+
initCallback : function(){},
|
55
|
+
messageCallback : function(){warn('MessageCallback function not defined');},
|
56
|
+
resizedCallback : function(){},
|
57
|
+
scrollCallback : function(){return true;}
|
58
|
+
};
|
59
|
+
|
60
|
+
function addEventListener(obj,evt,func){
|
61
|
+
/* istanbul ignore else */ // Not testable in PhantonJS
|
62
|
+
if ('addEventListener' in window){
|
63
|
+
obj.addEventListener(evt,func, false);
|
64
|
+
} else if ('attachEvent' in window){//IE
|
65
|
+
obj.attachEvent('on'+evt,func);
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
function removeEventListener(el,evt,func){
|
70
|
+
/* istanbul ignore else */ // Not testable in phantonJS
|
71
|
+
if ('removeEventListener' in window){
|
72
|
+
el.removeEventListener(evt,func, false);
|
73
|
+
} else if ('detachEvent' in window){ //IE
|
74
|
+
el.detachEvent('on'+evt,func);
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
function setupRequestAnimationFrame(){
|
79
|
+
var
|
80
|
+
vendors = ['moz', 'webkit', 'o', 'ms'],
|
81
|
+
x;
|
82
|
+
|
83
|
+
// Remove vendor prefixing if prefixed and break early if not
|
84
|
+
for (x = 0; x < vendors.length && !requestAnimationFrame; x += 1) {
|
85
|
+
requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
|
86
|
+
}
|
87
|
+
|
88
|
+
if (!(requestAnimationFrame)){
|
89
|
+
log('setup','RequestAnimationFrame not supported');
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
function getMyID(iframeId){
|
94
|
+
var retStr = 'Host page: '+iframeId;
|
95
|
+
|
96
|
+
if (window.top !== window.self){
|
97
|
+
if (window.parentIFrame && window.parentIFrame.getId){
|
98
|
+
retStr = window.parentIFrame.getId()+': '+iframeId;
|
99
|
+
} else {
|
100
|
+
retStr = 'Nested host page: '+iframeId;
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
return retStr;
|
105
|
+
}
|
106
|
+
|
107
|
+
function formatLogHeader(iframeId){
|
108
|
+
return msgId + '[' + getMyID(iframeId) + ']';
|
109
|
+
}
|
110
|
+
|
111
|
+
function isLogEnabled(iframeId){
|
112
|
+
return settings[iframeId] ? settings[iframeId].log : logEnabled;
|
113
|
+
}
|
114
|
+
|
115
|
+
function log(iframeId,msg){
|
116
|
+
output('log',iframeId,msg,isLogEnabled(iframeId));
|
117
|
+
}
|
118
|
+
|
119
|
+
function info(iframeId,msg){
|
120
|
+
output('info',iframeId,msg,isLogEnabled(iframeId));
|
121
|
+
}
|
122
|
+
|
123
|
+
function warn(iframeId,msg){
|
124
|
+
output('warn',iframeId,msg,true);
|
125
|
+
}
|
126
|
+
|
127
|
+
function output(type,iframeId,msg,enabled){
|
128
|
+
if (true === enabled && 'object' === typeof window.console){
|
129
|
+
console[type](formatLogHeader(iframeId),msg);
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
133
|
+
function iFrameListener(event){
|
134
|
+
function resizeIFrame(){
|
135
|
+
function resize(){
|
136
|
+
setSize(messageData);
|
137
|
+
setPagePosition(iframeId);
|
138
|
+
}
|
139
|
+
|
140
|
+
ensureInRange('Height');
|
141
|
+
ensureInRange('Width');
|
142
|
+
|
143
|
+
syncResize(resize,messageData,'init');
|
144
|
+
}
|
145
|
+
|
146
|
+
function processMsg(){
|
147
|
+
var data = msg.substr(msgIdLen).split(':');
|
148
|
+
|
149
|
+
return {
|
150
|
+
iframe: settings[data[0]].iframe,
|
151
|
+
id: data[0],
|
152
|
+
height: data[1],
|
153
|
+
width: data[2],
|
154
|
+
type: data[3]
|
155
|
+
};
|
156
|
+
}
|
157
|
+
|
158
|
+
function ensureInRange(Dimension){
|
159
|
+
var
|
160
|
+
max = Number(settings[iframeId]['max' + Dimension]),
|
161
|
+
min = Number(settings[iframeId]['min' + Dimension]),
|
162
|
+
dimension = Dimension.toLowerCase(),
|
163
|
+
size = Number(messageData[dimension]);
|
164
|
+
|
165
|
+
log(iframeId,'Checking ' + dimension + ' is in range ' + min + '-' + max);
|
166
|
+
|
167
|
+
if (size<min) {
|
168
|
+
size=min;
|
169
|
+
log(iframeId,'Set ' + dimension + ' to min value');
|
170
|
+
}
|
171
|
+
|
172
|
+
if (size>max) {
|
173
|
+
size=max;
|
174
|
+
log(iframeId,'Set ' + dimension + ' to max value');
|
175
|
+
}
|
176
|
+
|
177
|
+
messageData[dimension] = '' + size;
|
178
|
+
}
|
179
|
+
|
180
|
+
|
181
|
+
function isMessageFromIFrame(){
|
182
|
+
function checkAllowedOrigin(){
|
183
|
+
function checkList(){
|
184
|
+
var
|
185
|
+
i = 0,
|
186
|
+
retCode = false;
|
187
|
+
|
188
|
+
log(iframeId,'Checking connection is from allowed list of origins: ' + checkOrigin);
|
189
|
+
|
190
|
+
for (; i < checkOrigin.length; i++) {
|
191
|
+
if (checkOrigin[i] === origin) {
|
192
|
+
retCode = true;
|
193
|
+
break;
|
194
|
+
}
|
195
|
+
}
|
196
|
+
return retCode;
|
197
|
+
}
|
198
|
+
|
199
|
+
function checkSingle(){
|
200
|
+
var remoteHost = settings[iframeId].remoteHost;
|
201
|
+
log(iframeId,'Checking connection is from: '+remoteHost);
|
202
|
+
return origin === remoteHost;
|
203
|
+
}
|
204
|
+
|
205
|
+
return checkOrigin.constructor === Array ? checkList() : checkSingle();
|
206
|
+
}
|
207
|
+
|
208
|
+
var
|
209
|
+
origin = event.origin,
|
210
|
+
checkOrigin = settings[iframeId].checkOrigin;
|
211
|
+
|
212
|
+
if (checkOrigin && (''+origin !== 'null') && !checkAllowedOrigin()) {
|
213
|
+
throw new Error(
|
214
|
+
'Unexpected message received from: ' + origin +
|
215
|
+
' for ' + messageData.iframe.id +
|
216
|
+
'. Message was: ' + event.data +
|
217
|
+
'. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.'
|
218
|
+
);
|
219
|
+
}
|
220
|
+
|
221
|
+
return true;
|
222
|
+
}
|
223
|
+
|
224
|
+
function isMessageForUs(){
|
225
|
+
return msgId === (('' + msg).substr(0,msgIdLen)) && (msg.substr(msgIdLen).split(':')[0] in settings); //''+Protects against non-string msg
|
226
|
+
}
|
227
|
+
|
228
|
+
function isMessageFromMetaParent(){
|
229
|
+
//Test if this message is from a parent above us. This is an ugly test, however, updating
|
230
|
+
//the message format would break backwards compatibity.
|
231
|
+
var retCode = messageData.type in {'true':1,'false':1,'undefined':1};
|
232
|
+
|
233
|
+
if (retCode){
|
234
|
+
log(iframeId,'Ignoring init message from meta parent page');
|
235
|
+
}
|
236
|
+
|
237
|
+
return retCode;
|
238
|
+
}
|
239
|
+
|
240
|
+
function getMsgBody(offset){
|
241
|
+
return msg.substr(msg.indexOf(':')+msgHeaderLen+offset);
|
242
|
+
}
|
243
|
+
|
244
|
+
function forwardMsgFromIFrame(msgBody){
|
245
|
+
log(iframeId,'MessageCallback passed: {iframe: '+ messageData.iframe.id + ', message: ' + msgBody + '}');
|
246
|
+
callback('messageCallback',{
|
247
|
+
iframe: messageData.iframe,
|
248
|
+
message: JSON.parse(msgBody)
|
249
|
+
});
|
250
|
+
log(iframeId,'--');
|
251
|
+
}
|
252
|
+
|
253
|
+
function getPageInfo(){
|
254
|
+
var
|
255
|
+
bodyPosition = document.body.getBoundingClientRect(),
|
256
|
+
iFramePosition = messageData.iframe.getBoundingClientRect();
|
257
|
+
|
258
|
+
return JSON.stringify({
|
259
|
+
iframeHeight: iFramePosition.height,
|
260
|
+
iframeWidth: iFramePosition.width,
|
261
|
+
clientHeight: Math.max(document.documentElement.clientHeight, window.innerHeight || 0),
|
262
|
+
clientWidth: Math.max(document.documentElement.clientWidth, window.innerWidth || 0),
|
263
|
+
offsetTop: parseInt(iFramePosition.top - bodyPosition.top, 10),
|
264
|
+
offsetLeft: parseInt(iFramePosition.left - bodyPosition.left, 10),
|
265
|
+
scrollTop: window.pageYOffset,
|
266
|
+
scrollLeft: window.pageXOffset
|
267
|
+
});
|
268
|
+
}
|
269
|
+
|
270
|
+
function sendPageInfoToIframe(iframe,iframeId){
|
271
|
+
function debouncedTrigger(){
|
272
|
+
trigger(
|
273
|
+
'Send Page Info',
|
274
|
+
'pageInfo:' + getPageInfo(),
|
275
|
+
iframe,
|
276
|
+
iframeId
|
277
|
+
);
|
278
|
+
}
|
279
|
+
|
280
|
+
debouce(debouncedTrigger,32);
|
281
|
+
}
|
282
|
+
|
283
|
+
|
284
|
+
function startPageInfoMonitor(){
|
285
|
+
function setListener(type,func){
|
286
|
+
function sendPageInfo(){
|
287
|
+
if (settings[id]){
|
288
|
+
sendPageInfoToIframe(settings[id].iframe,id);
|
289
|
+
} else {
|
290
|
+
stop();
|
291
|
+
}
|
292
|
+
}
|
293
|
+
|
294
|
+
['scroll','resize'].forEach(function(evt){
|
295
|
+
log(id, type + evt + ' listener for sendPageInfo');
|
296
|
+
func(window,evt,sendPageInfo);
|
297
|
+
});
|
298
|
+
}
|
299
|
+
|
300
|
+
function stop(){
|
301
|
+
setListener('Remove ', removeEventListener);
|
302
|
+
}
|
303
|
+
|
304
|
+
function start(){
|
305
|
+
setListener('Add ', addEventListener);
|
306
|
+
}
|
307
|
+
|
308
|
+
var id = iframeId; //Create locally scoped copy of iFrame ID
|
309
|
+
|
310
|
+
start();
|
311
|
+
|
312
|
+
settings[id].stopPageInfo = stop;
|
313
|
+
}
|
314
|
+
|
315
|
+
function stopPageInfoMonitor(){
|
316
|
+
if (settings[iframeId] && settings[iframeId].stopPageInfo){
|
317
|
+
settings[iframeId].stopPageInfo();
|
318
|
+
delete settings[iframeId].stopPageInfo;
|
319
|
+
}
|
320
|
+
}
|
321
|
+
|
322
|
+
function checkIFrameExists(){
|
323
|
+
var retBool = true;
|
324
|
+
|
325
|
+
if (null === messageData.iframe) {
|
326
|
+
warn(iframeId,'IFrame ('+messageData.id+') not found');
|
327
|
+
retBool = false;
|
328
|
+
}
|
329
|
+
return retBool;
|
330
|
+
}
|
331
|
+
|
332
|
+
function getElementPosition(target){
|
333
|
+
var iFramePosition = target.getBoundingClientRect();
|
334
|
+
|
335
|
+
getPagePosition(iframeId);
|
336
|
+
|
337
|
+
return {
|
338
|
+
x: Math.floor( Number(iFramePosition.left) + Number(pagePosition.x) ),
|
339
|
+
y: Math.floor( Number(iFramePosition.top) + Number(pagePosition.y) )
|
340
|
+
};
|
341
|
+
}
|
342
|
+
|
343
|
+
function scrollRequestFromChild(addOffset){
|
344
|
+
/* istanbul ignore next */ //Not testable in Karma
|
345
|
+
function reposition(){
|
346
|
+
pagePosition = newPosition;
|
347
|
+
scrollTo();
|
348
|
+
log(iframeId,'--');
|
349
|
+
}
|
350
|
+
|
351
|
+
function calcOffset(){
|
352
|
+
return {
|
353
|
+
x: Number(messageData.width) + offset.x,
|
354
|
+
y: Number(messageData.height) + offset.y
|
355
|
+
};
|
356
|
+
}
|
357
|
+
|
358
|
+
function scrollParent(){
|
359
|
+
if (window.parentIFrame){
|
360
|
+
window.parentIFrame['scrollTo'+(addOffset?'Offset':'')](newPosition.x,newPosition.y);
|
361
|
+
} else {
|
362
|
+
warn(iframeId,'Unable to scroll to requested position, window.parentIFrame not found');
|
363
|
+
}
|
364
|
+
}
|
365
|
+
|
366
|
+
var
|
367
|
+
offset = addOffset ? getElementPosition(messageData.iframe) : {x:0,y:0},
|
368
|
+
newPosition = calcOffset();
|
369
|
+
|
370
|
+
log(iframeId,'Reposition requested from iFrame (offset x:'+offset.x+' y:'+offset.y+')');
|
371
|
+
|
372
|
+
if(window.top !== window.self){
|
373
|
+
scrollParent();
|
374
|
+
} else {
|
375
|
+
reposition();
|
376
|
+
}
|
377
|
+
}
|
378
|
+
|
379
|
+
function scrollTo(){
|
380
|
+
if (false !== callback('scrollCallback',pagePosition)){
|
381
|
+
setPagePosition(iframeId);
|
382
|
+
} else {
|
383
|
+
unsetPagePosition();
|
384
|
+
}
|
385
|
+
}
|
386
|
+
|
387
|
+
function findTarget(location){
|
388
|
+
function jumpToTarget(){
|
389
|
+
var jumpPosition = getElementPosition(target);
|
390
|
+
|
391
|
+
log(iframeId,'Moving to in page link (#'+hash+') at x: '+jumpPosition.x+' y: '+jumpPosition.y);
|
392
|
+
pagePosition = {
|
393
|
+
x: jumpPosition.x,
|
394
|
+
y: jumpPosition.y
|
395
|
+
};
|
396
|
+
|
397
|
+
scrollTo();
|
398
|
+
log(iframeId,'--');
|
399
|
+
}
|
400
|
+
|
401
|
+
function jumpToParent(){
|
402
|
+
if (window.parentIFrame){
|
403
|
+
window.parentIFrame.moveToAnchor(hash);
|
404
|
+
} else {
|
405
|
+
log(iframeId,'In page link #'+hash+' not found and window.parentIFrame not found');
|
406
|
+
}
|
407
|
+
}
|
408
|
+
|
409
|
+
var
|
410
|
+
hash = location.split('#')[1] || '',
|
411
|
+
hashData = decodeURIComponent(hash),
|
412
|
+
target = document.getElementById(hashData) || document.getElementsByName(hashData)[0];
|
413
|
+
|
414
|
+
if (target){
|
415
|
+
jumpToTarget();
|
416
|
+
} else if(window.top!==window.self){
|
417
|
+
jumpToParent();
|
418
|
+
} else {
|
419
|
+
log(iframeId,'In page link #'+hash+' not found');
|
420
|
+
}
|
421
|
+
}
|
422
|
+
|
423
|
+
function callback(funcName,val){
|
424
|
+
return chkCallback(iframeId,funcName,val);
|
425
|
+
}
|
426
|
+
|
427
|
+
function actionMsg(){
|
428
|
+
|
429
|
+
if(settings[iframeId].firstRun) firstRun();
|
430
|
+
|
431
|
+
switch(messageData.type){
|
432
|
+
case 'close':
|
433
|
+
closeIFrame(messageData.iframe);
|
434
|
+
break;
|
435
|
+
case 'message':
|
436
|
+
forwardMsgFromIFrame(getMsgBody(6));
|
437
|
+
break;
|
438
|
+
case 'scrollTo':
|
439
|
+
scrollRequestFromChild(false);
|
440
|
+
break;
|
441
|
+
case 'scrollToOffset':
|
442
|
+
scrollRequestFromChild(true);
|
443
|
+
break;
|
444
|
+
case 'pageInfo':
|
445
|
+
sendPageInfoToIframe(settings[iframeId].iframe,iframeId);
|
446
|
+
startPageInfoMonitor();
|
447
|
+
break;
|
448
|
+
case 'pageInfoStop':
|
449
|
+
stopPageInfoMonitor();
|
450
|
+
break;
|
451
|
+
case 'inPageLink':
|
452
|
+
findTarget(getMsgBody(9));
|
453
|
+
break;
|
454
|
+
case 'reset':
|
455
|
+
resetIFrame(messageData);
|
456
|
+
break;
|
457
|
+
case 'init':
|
458
|
+
resizeIFrame();
|
459
|
+
callback('initCallback',messageData.iframe);
|
460
|
+
callback('resizedCallback',messageData);
|
461
|
+
break;
|
462
|
+
default:
|
463
|
+
resizeIFrame();
|
464
|
+
callback('resizedCallback',messageData);
|
465
|
+
}
|
466
|
+
}
|
467
|
+
|
468
|
+
function hasSettings(iframeId){
|
469
|
+
var retBool = true;
|
470
|
+
|
471
|
+
if (!settings[iframeId]){
|
472
|
+
retBool = false;
|
473
|
+
warn(messageData.type + ' No settings for ' + iframeId + '. Message was: ' + msg);
|
474
|
+
}
|
475
|
+
|
476
|
+
return retBool;
|
477
|
+
}
|
478
|
+
|
479
|
+
function iFrameReadyMsgReceived(){
|
480
|
+
for (var iframeId in settings){
|
481
|
+
trigger('iFrame requested init',createOutgoingMsg(iframeId),document.getElementById(iframeId),iframeId);
|
482
|
+
}
|
483
|
+
}
|
484
|
+
|
485
|
+
function firstRun() {
|
486
|
+
settings[iframeId].firstRun = false;
|
487
|
+
}
|
488
|
+
|
489
|
+
var
|
490
|
+
msg = event.data,
|
491
|
+
messageData = {},
|
492
|
+
iframeId = null;
|
493
|
+
|
494
|
+
if('[iFrameResizerChild]Ready' === msg){
|
495
|
+
iFrameReadyMsgReceived();
|
496
|
+
} else if (isMessageForUs()){
|
497
|
+
messageData = processMsg();
|
498
|
+
iframeId = logId = messageData.id;
|
499
|
+
|
500
|
+
if (!isMessageFromMetaParent() && hasSettings(iframeId)){
|
501
|
+
log(iframeId,'Received: '+msg);
|
502
|
+
|
503
|
+
if ( checkIFrameExists() && isMessageFromIFrame() ){
|
504
|
+
actionMsg();
|
505
|
+
}
|
506
|
+
}
|
507
|
+
} else {
|
508
|
+
info(iframeId,'Ignored: '+msg);
|
509
|
+
}
|
510
|
+
|
511
|
+
}
|
512
|
+
|
513
|
+
|
514
|
+
function chkCallback(iframeId,funcName,val){
|
515
|
+
var
|
516
|
+
func = null,
|
517
|
+
retVal = null;
|
518
|
+
|
519
|
+
if(settings[iframeId]){
|
520
|
+
func = settings[iframeId][funcName];
|
521
|
+
|
522
|
+
if( 'function' === typeof func){
|
523
|
+
retVal = func(val);
|
524
|
+
} else {
|
525
|
+
throw new TypeError(funcName+' on iFrame['+iframeId+'] is not a function');
|
526
|
+
}
|
527
|
+
}
|
528
|
+
|
529
|
+
return retVal;
|
530
|
+
}
|
531
|
+
|
532
|
+
function closeIFrame(iframe){
|
533
|
+
var iframeId = iframe.id;
|
534
|
+
|
535
|
+
log(iframeId,'Removing iFrame: '+iframeId);
|
536
|
+
if (iframe.parentNode) { iframe.parentNode.removeChild(iframe); }
|
537
|
+
chkCallback(iframeId,'closedCallback',iframeId);
|
538
|
+
log(iframeId,'--');
|
539
|
+
delete settings[iframeId];
|
540
|
+
}
|
541
|
+
|
542
|
+
function getPagePosition(iframeId){
|
543
|
+
if(null === pagePosition){
|
544
|
+
pagePosition = {
|
545
|
+
x: (window.pageXOffset !== undefined) ? window.pageXOffset : document.documentElement.scrollLeft,
|
546
|
+
y: (window.pageYOffset !== undefined) ? window.pageYOffset : document.documentElement.scrollTop
|
547
|
+
};
|
548
|
+
log(iframeId,'Get page position: '+pagePosition.x+','+pagePosition.y);
|
549
|
+
}
|
550
|
+
}
|
551
|
+
|
552
|
+
function setPagePosition(iframeId){
|
553
|
+
if(null !== pagePosition){
|
554
|
+
window.scrollTo(pagePosition.x,pagePosition.y);
|
555
|
+
log(iframeId,'Set page position: '+pagePosition.x+','+pagePosition.y);
|
556
|
+
unsetPagePosition();
|
557
|
+
}
|
558
|
+
}
|
559
|
+
|
560
|
+
function unsetPagePosition(){
|
561
|
+
pagePosition = null;
|
562
|
+
}
|
563
|
+
|
564
|
+
function resetIFrame(messageData){
|
565
|
+
function reset(){
|
566
|
+
setSize(messageData);
|
567
|
+
trigger('reset','reset',messageData.iframe,messageData.id);
|
568
|
+
}
|
569
|
+
|
570
|
+
log(messageData.id,'Size reset requested by '+('init'===messageData.type?'host page':'iFrame'));
|
571
|
+
getPagePosition(messageData.id);
|
572
|
+
syncResize(reset,messageData,'reset');
|
573
|
+
}
|
574
|
+
|
575
|
+
function setSize(messageData){
|
576
|
+
function setDimension(dimension){
|
577
|
+
messageData.iframe.style[dimension] = messageData[dimension] + 'px';
|
578
|
+
log(
|
579
|
+
messageData.id,
|
580
|
+
'IFrame (' + iframeId +
|
581
|
+
') ' + dimension +
|
582
|
+
' set to ' + messageData[dimension] + 'px'
|
583
|
+
);
|
584
|
+
}
|
585
|
+
|
586
|
+
function chkZero(dimension){
|
587
|
+
//FireFox sets dimension of hidden iFrames to zero.
|
588
|
+
//So if we detect that set up an event to check for
|
589
|
+
//when iFrame becomes visible.
|
590
|
+
|
591
|
+
/* istanbul ignore next */ //Not testable in PhantomJS
|
592
|
+
if (!hiddenCheckEnabled && '0' === messageData[dimension]){
|
593
|
+
hiddenCheckEnabled = true;
|
594
|
+
log(iframeId,'Hidden iFrame detected, creating visibility listener');
|
595
|
+
fixHiddenIFrames();
|
596
|
+
}
|
597
|
+
}
|
598
|
+
|
599
|
+
function processDimension(dimension){
|
600
|
+
setDimension(dimension);
|
601
|
+
chkZero(dimension);
|
602
|
+
}
|
603
|
+
|
604
|
+
var iframeId = messageData.iframe.id;
|
605
|
+
|
606
|
+
if(settings[iframeId]){
|
607
|
+
if( settings[iframeId].sizeHeight) { processDimension('height'); }
|
608
|
+
if( settings[iframeId].sizeWidth ) { processDimension('width'); }
|
609
|
+
}
|
610
|
+
}
|
611
|
+
|
612
|
+
function syncResize(func,messageData,doNotSync){
|
613
|
+
/* istanbul ignore if */ //Not testable in PhantomJS
|
614
|
+
if(doNotSync!==messageData.type && requestAnimationFrame){
|
615
|
+
log(messageData.id,'Requesting animation frame');
|
616
|
+
requestAnimationFrame(func);
|
617
|
+
} else {
|
618
|
+
func();
|
619
|
+
}
|
620
|
+
}
|
621
|
+
|
622
|
+
function trigger(calleeMsg,msg,iframe,id){
|
623
|
+
function postMessageToIFrame(){
|
624
|
+
var target = settings[id].targetOrigin;
|
625
|
+
log(id,'[' + calleeMsg + '] Sending msg to iframe['+id+'] ('+msg+') targetOrigin: '+target);
|
626
|
+
iframe.contentWindow.postMessage( msgId + msg, target );
|
627
|
+
}
|
628
|
+
|
629
|
+
function iFrameNotFound(){
|
630
|
+
warn(id,'[' + calleeMsg + '] IFrame('+id+') not found');
|
631
|
+
}
|
632
|
+
|
633
|
+
function chkAndSend(){
|
634
|
+
if(iframe && 'contentWindow' in iframe && (null !== iframe.contentWindow)){ //Null test for PhantomJS
|
635
|
+
postMessageToIFrame();
|
636
|
+
} else {
|
637
|
+
iFrameNotFound();
|
638
|
+
}
|
639
|
+
}
|
640
|
+
|
641
|
+
id = id || iframe.id;
|
642
|
+
|
643
|
+
if(settings[id]) {
|
644
|
+
chkAndSend();
|
645
|
+
}
|
646
|
+
|
647
|
+
}
|
648
|
+
|
649
|
+
function createOutgoingMsg(iframeId){
|
650
|
+
return iframeId +
|
651
|
+
':' + settings[iframeId].bodyMarginV1 +
|
652
|
+
':' + settings[iframeId].sizeWidth +
|
653
|
+
':' + settings[iframeId].log +
|
654
|
+
':' + settings[iframeId].interval +
|
655
|
+
':' + settings[iframeId].enablePublicMethods +
|
656
|
+
':' + settings[iframeId].autoResize +
|
657
|
+
':' + settings[iframeId].bodyMargin +
|
658
|
+
':' + settings[iframeId].heightCalculationMethod +
|
659
|
+
':' + settings[iframeId].bodyBackground +
|
660
|
+
':' + settings[iframeId].bodyPadding +
|
661
|
+
':' + settings[iframeId].tolerance +
|
662
|
+
':' + settings[iframeId].inPageLinks +
|
663
|
+
':' + settings[iframeId].resizeFrom +
|
664
|
+
':' + settings[iframeId].widthCalculationMethod;
|
665
|
+
}
|
666
|
+
|
667
|
+
function setupIFrame(iframe,options){
|
668
|
+
function setLimits(){
|
669
|
+
function addStyle(style){
|
670
|
+
if ((Infinity !== settings[iframeId][style]) && (0 !== settings[iframeId][style])){
|
671
|
+
iframe.style[style] = settings[iframeId][style] + 'px';
|
672
|
+
log(iframeId,'Set '+style+' = '+settings[iframeId][style]+'px');
|
673
|
+
}
|
674
|
+
}
|
675
|
+
|
676
|
+
function chkMinMax(dimension){
|
677
|
+
if (settings[iframeId]['min'+dimension]>settings[iframeId]['max'+dimension]){
|
678
|
+
throw new Error('Value for min'+dimension+' can not be greater than max'+dimension);
|
679
|
+
}
|
680
|
+
}
|
681
|
+
|
682
|
+
chkMinMax('Height');
|
683
|
+
chkMinMax('Width');
|
684
|
+
|
685
|
+
addStyle('maxHeight');
|
686
|
+
addStyle('minHeight');
|
687
|
+
addStyle('maxWidth');
|
688
|
+
addStyle('minWidth');
|
689
|
+
}
|
690
|
+
|
691
|
+
function newId(){
|
692
|
+
var id = ((options && options.id) || defaults.id + count++);
|
693
|
+
if (null !== document.getElementById(id)){
|
694
|
+
id = id + count++;
|
695
|
+
}
|
696
|
+
return id;
|
697
|
+
}
|
698
|
+
|
699
|
+
function ensureHasId(iframeId){
|
700
|
+
logId=iframeId;
|
701
|
+
if (''===iframeId){
|
702
|
+
iframe.id = iframeId = newId();
|
703
|
+
logEnabled = (options || {}).log;
|
704
|
+
logId=iframeId;
|
705
|
+
log(iframeId,'Added missing iframe ID: '+ iframeId +' (' + iframe.src + ')');
|
706
|
+
}
|
707
|
+
|
708
|
+
|
709
|
+
return iframeId;
|
710
|
+
}
|
711
|
+
|
712
|
+
function setScrolling(){
|
713
|
+
log(iframeId,'IFrame scrolling ' + (settings[iframeId].scrolling ? 'enabled' : 'disabled') + ' for ' + iframeId);
|
714
|
+
iframe.style.overflow = false === settings[iframeId].scrolling ? 'hidden' : 'auto';
|
715
|
+
iframe.scrolling = false === settings[iframeId].scrolling ? 'no' : 'yes';
|
716
|
+
}
|
717
|
+
|
718
|
+
//The V1 iFrame script expects an int, where as in V2 expects a CSS
|
719
|
+
//string value such as '1px 3em', so if we have an int for V2, set V1=V2
|
720
|
+
//and then convert V2 to a string PX value.
|
721
|
+
function setupBodyMarginValues(){
|
722
|
+
if (('number'===typeof(settings[iframeId].bodyMargin)) || ('0'===settings[iframeId].bodyMargin)){
|
723
|
+
settings[iframeId].bodyMarginV1 = settings[iframeId].bodyMargin;
|
724
|
+
settings[iframeId].bodyMargin = '' + settings[iframeId].bodyMargin + 'px';
|
725
|
+
}
|
726
|
+
}
|
727
|
+
|
728
|
+
function checkReset(){
|
729
|
+
// Reduce scope of firstRun to function, because IE8's JS execution
|
730
|
+
// context stack is borked and this value gets externally
|
731
|
+
// changed midway through running this function!!!
|
732
|
+
var
|
733
|
+
firstRun = settings[iframeId].firstRun,
|
734
|
+
resetRequertMethod = settings[iframeId].heightCalculationMethod in resetRequiredMethods;
|
735
|
+
|
736
|
+
if (!firstRun && resetRequertMethod){
|
737
|
+
resetIFrame({iframe:iframe, height:0, width:0, type:'init'});
|
738
|
+
}
|
739
|
+
}
|
740
|
+
|
741
|
+
function setupIFrameObject(){
|
742
|
+
if(Function.prototype.bind){ //Ignore unpolyfilled IE8.
|
743
|
+
settings[iframeId].iframe.iFrameResizer = {
|
744
|
+
|
745
|
+
close : closeIFrame.bind(null,settings[iframeId].iframe),
|
746
|
+
|
747
|
+
resize : trigger.bind(null,'Window resize', 'resize', settings[iframeId].iframe),
|
748
|
+
|
749
|
+
moveToAnchor : function(anchor){
|
750
|
+
trigger('Move to anchor','moveToAnchor:'+anchor, settings[iframeId].iframe,iframeId);
|
751
|
+
},
|
752
|
+
|
753
|
+
sendMessage : function(message){
|
754
|
+
message = JSON.stringify(message);
|
755
|
+
trigger('Send Message','message:'+message, settings[iframeId].iframe,iframeId);
|
756
|
+
}
|
757
|
+
};
|
758
|
+
}
|
759
|
+
}
|
760
|
+
|
761
|
+
//We have to call trigger twice, as we can not be sure if all
|
762
|
+
//iframes have completed loading when this code runs. The
|
763
|
+
//event listener also catches the page changing in the iFrame.
|
764
|
+
function init(msg){
|
765
|
+
function iFrameLoaded(){
|
766
|
+
trigger('iFrame.onload',msg,iframe);
|
767
|
+
checkReset();
|
768
|
+
}
|
769
|
+
|
770
|
+
addEventListener(iframe,'load',iFrameLoaded);
|
771
|
+
trigger('init',msg,iframe);
|
772
|
+
}
|
773
|
+
|
774
|
+
function checkOptions(options){
|
775
|
+
if ('object' !== typeof options){
|
776
|
+
throw new TypeError('Options is not an object');
|
777
|
+
}
|
778
|
+
}
|
779
|
+
|
780
|
+
function copyOptions(options){
|
781
|
+
for (var option in defaults) {
|
782
|
+
if (defaults.hasOwnProperty(option)){
|
783
|
+
settings[iframeId][option] = options.hasOwnProperty(option) ? options[option] : defaults[option];
|
784
|
+
}
|
785
|
+
}
|
786
|
+
}
|
787
|
+
|
788
|
+
function getTargetOrigin (remoteHost){
|
789
|
+
return ('' === remoteHost || 'file://' === remoteHost) ? '*' : remoteHost;
|
790
|
+
}
|
791
|
+
|
792
|
+
function processOptions(options){
|
793
|
+
options = options || {};
|
794
|
+
settings[iframeId] = {
|
795
|
+
firstRun : true,
|
796
|
+
iframe : iframe,
|
797
|
+
remoteHost : iframe.src.split('/').slice(0,3).join('/')
|
798
|
+
};
|
799
|
+
|
800
|
+
checkOptions(options);
|
801
|
+
copyOptions(options);
|
802
|
+
|
803
|
+
settings[iframeId].targetOrigin = true === settings[iframeId].checkOrigin ? getTargetOrigin(settings[iframeId].remoteHost) : '*';
|
804
|
+
}
|
805
|
+
|
806
|
+
function beenHere(){
|
807
|
+
return (iframeId in settings && 'iFrameResizer' in iframe);
|
808
|
+
}
|
809
|
+
|
810
|
+
var iframeId = ensureHasId(iframe.id);
|
811
|
+
|
812
|
+
if (!beenHere()){
|
813
|
+
processOptions(options);
|
814
|
+
setScrolling();
|
815
|
+
setLimits();
|
816
|
+
setupBodyMarginValues();
|
817
|
+
init(createOutgoingMsg(iframeId));
|
818
|
+
setupIFrameObject();
|
819
|
+
} else {
|
820
|
+
warn(iframeId,'Ignored iFrame, already setup.');
|
821
|
+
}
|
822
|
+
}
|
823
|
+
|
824
|
+
function debouce(fn,time){
|
825
|
+
if (null === timer){
|
826
|
+
timer = setTimeout(function(){
|
827
|
+
timer = null;
|
828
|
+
fn();
|
829
|
+
}, time);
|
830
|
+
}
|
831
|
+
}
|
832
|
+
|
833
|
+
/* istanbul ignore next */ //Not testable in PhantomJS
|
834
|
+
function fixHiddenIFrames(){
|
835
|
+
function checkIFrames(){
|
836
|
+
function checkIFrame(settingId){
|
837
|
+
function chkDimension(dimension){
|
838
|
+
return '0px' === settings[settingId].iframe.style[dimension];
|
839
|
+
}
|
840
|
+
|
841
|
+
function isVisible(el) {
|
842
|
+
return (null !== el.offsetParent);
|
843
|
+
}
|
844
|
+
|
845
|
+
if (isVisible(settings[settingId].iframe) && (chkDimension('height') || chkDimension('width'))){
|
846
|
+
trigger('Visibility change', 'resize', settings[settingId].iframe,settingId);
|
847
|
+
}
|
848
|
+
}
|
849
|
+
|
850
|
+
for (var settingId in settings){
|
851
|
+
checkIFrame(settingId);
|
852
|
+
}
|
853
|
+
}
|
854
|
+
|
855
|
+
function mutationObserved(mutations){
|
856
|
+
log('window','Mutation observed: ' + mutations[0].target + ' ' + mutations[0].type);
|
857
|
+
debouce(checkIFrames,16);
|
858
|
+
}
|
859
|
+
|
860
|
+
function createMutationObserver(){
|
861
|
+
var
|
862
|
+
target = document.querySelector('body'),
|
863
|
+
|
864
|
+
config = {
|
865
|
+
attributes : true,
|
866
|
+
attributeOldValue : false,
|
867
|
+
characterData : true,
|
868
|
+
characterDataOldValue : false,
|
869
|
+
childList : true,
|
870
|
+
subtree : true
|
871
|
+
},
|
872
|
+
|
873
|
+
observer = new MutationObserver(mutationObserved);
|
874
|
+
|
875
|
+
observer.observe(target, config);
|
876
|
+
}
|
877
|
+
|
878
|
+
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
|
879
|
+
|
880
|
+
if (MutationObserver) createMutationObserver();
|
881
|
+
}
|
882
|
+
|
883
|
+
|
884
|
+
function resizeIFrames(event){
|
885
|
+
function resize(){
|
886
|
+
sendTriggerMsg('Window '+event,'resize');
|
887
|
+
}
|
888
|
+
|
889
|
+
log('window','Trigger event: '+event);
|
890
|
+
debouce(resize,16);
|
891
|
+
}
|
892
|
+
|
893
|
+
/* istanbul ignore next */ //Not testable in PhantomJS
|
894
|
+
function tabVisible() {
|
895
|
+
function resize(){
|
896
|
+
sendTriggerMsg('Tab Visable','resize');
|
897
|
+
}
|
898
|
+
|
899
|
+
if('hidden' !== document.visibilityState) {
|
900
|
+
log('document','Trigger event: Visiblity change');
|
901
|
+
debouce(resize,16);
|
902
|
+
}
|
903
|
+
}
|
904
|
+
|
905
|
+
function sendTriggerMsg(eventName,event){
|
906
|
+
function isIFrameResizeEnabled(iframeId) {
|
907
|
+
return 'parent' === settings[iframeId].resizeFrom &&
|
908
|
+
settings[iframeId].autoResize &&
|
909
|
+
!settings[iframeId].firstRun;
|
910
|
+
}
|
911
|
+
|
912
|
+
for (var iframeId in settings){
|
913
|
+
if(isIFrameResizeEnabled(iframeId)){
|
914
|
+
trigger(eventName,event,document.getElementById(iframeId),iframeId);
|
915
|
+
}
|
916
|
+
}
|
917
|
+
}
|
918
|
+
|
919
|
+
function setupEventListeners(){
|
920
|
+
addEventListener(window,'message',iFrameListener);
|
921
|
+
|
922
|
+
addEventListener(window,'resize', function(){resizeIFrames('resize');});
|
923
|
+
|
924
|
+
addEventListener(document,'visibilitychange',tabVisible);
|
925
|
+
addEventListener(document,'-webkit-visibilitychange',tabVisible); //Andriod 4.4
|
926
|
+
addEventListener(window,'focusin',function(){resizeIFrames('focus');}); //IE8-9
|
927
|
+
addEventListener(window,'focus',function(){resizeIFrames('focus');});
|
928
|
+
}
|
929
|
+
|
930
|
+
|
931
|
+
function factory(){
|
932
|
+
function init(options,element){
|
933
|
+
function chkType(){
|
934
|
+
if(!element.tagName) {
|
935
|
+
throw new TypeError('Object is not a valid DOM element');
|
936
|
+
} else if ('IFRAME' !== element.tagName.toUpperCase()) {
|
937
|
+
throw new TypeError('Expected <IFRAME> tag, found <'+element.tagName+'>');
|
938
|
+
}
|
939
|
+
}
|
940
|
+
|
941
|
+
if(element) {
|
942
|
+
chkType();
|
943
|
+
setupIFrame(element, options);
|
944
|
+
iFrames.push(element);
|
945
|
+
}
|
946
|
+
}
|
947
|
+
|
948
|
+
function warnDeprecatedOptions(options) {
|
949
|
+
if (options && options.enablePublicMethods) {
|
950
|
+
warn('enablePublicMethods option has been removed, public methods are now always available in the iFrame');
|
951
|
+
}
|
952
|
+
}
|
953
|
+
|
954
|
+
var iFrames;
|
955
|
+
|
956
|
+
setupRequestAnimationFrame();
|
957
|
+
setupEventListeners();
|
958
|
+
|
959
|
+
return function iFrameResizeF(options,target){
|
960
|
+
iFrames = []; //Only return iFrames past in on this call
|
961
|
+
|
962
|
+
warnDeprecatedOptions(options);
|
963
|
+
|
964
|
+
switch (typeof(target)){
|
965
|
+
case 'undefined':
|
966
|
+
case 'string':
|
967
|
+
Array.prototype.forEach.call(
|
968
|
+
document.querySelectorAll( target || 'iframe' ),
|
969
|
+
init.bind(undefined, options)
|
970
|
+
);
|
971
|
+
break;
|
972
|
+
case 'object':
|
973
|
+
init(options,target);
|
974
|
+
break;
|
975
|
+
default:
|
976
|
+
throw new TypeError('Unexpected data type ('+typeof(target)+')');
|
977
|
+
}
|
978
|
+
|
979
|
+
return iFrames;
|
980
|
+
};
|
981
|
+
}
|
982
|
+
|
983
|
+
function createJQueryPublicMethod($){
|
984
|
+
if (!$.fn) {
|
985
|
+
info('','Unable to bind to jQuery, it is not fully loaded.');
|
986
|
+
} else if (!$.fn.iFrameResize){
|
987
|
+
$.fn.iFrameResize = function $iFrameResizeF(options) {
|
988
|
+
function init(index, element) {
|
989
|
+
setupIFrame(element, options);
|
990
|
+
}
|
991
|
+
|
992
|
+
return this.filter('iframe').each(init).end();
|
993
|
+
};
|
994
|
+
}
|
995
|
+
}
|
996
|
+
|
997
|
+
if (window.jQuery) { createJQueryPublicMethod(jQuery); }
|
998
|
+
|
999
|
+
if (typeof define === 'function' && define.amd) {
|
1000
|
+
define([],factory);
|
1001
|
+
} else if (typeof module === 'object' && typeof module.exports === 'object') { //Node for browserfy
|
1002
|
+
module.exports = factory();
|
1003
|
+
} else {
|
1004
|
+
window.iFrameResize = window.iFrameResize || factory();
|
1005
|
+
}
|
1006
|
+
|
1007
|
+
})(window || {});
|