{"version":3,"file":"iframeResizer.contentWindow.min.js","sources":["iframeResizer.contentWindow.js"],"names":["undefined","addEventListener","el","evt","func","window","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","module","exports","isInitMsg","true","false","callFromParent","messageType","processRequestFromParent","processMessage","firstRun","fireInit","source","initLock","readyState","initFromParent","inPageLink","pageInfo","msgBody","parse","chkLateLoaded","parent","click","max","min","offsetHeight","scrollWidth","Date","getTime","offset","scrollHeight","custom","grow","lowestElement","taggedElement","offsetWidth","scroll","rightMostElement"],"mappings":";;;;;;;;CAYC,SAAUA,GACT,YA0DA,SAASC,GAAiBC,EAAGC,EAAIC,GAE3B,oBAAsBC,QACxBH,EAAGD,iBAAiBE,EAAIC,GAAM,GACrB,eAAiBC,SAC1BH,EAAGI,YAAY,KAAKH,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pCiM","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(undefined) {\n  'use strict';\n\n  if(typeof window === 'undefined') return; // don't run for server side render\n\n  var\n    autoResize            = true,\n    base                  = 10,\n    bodyBackground        = '',\n    bodyMargin            = 0,\n    bodyMarginStr         = '',\n    bodyObserver          = null,\n    bodyPadding           = '',\n    calculateWidth        = false,\n    doubleEventList       = {'resize':1,'click':1},\n    eventCancelTimer      = 128,\n    firstRun              = true,\n    height                = 1,\n    heightCalcModeDefault = 'bodyOffset',\n    heightCalcMode        = heightCalcModeDefault,\n    initLock              = true,\n    initMsg               = '',\n    inPageLinks           = {},\n    interval              = 32,\n    intervalTimer         = null,\n    logging               = false,\n    msgID                 = '[iFrameSizer]',  //Must match host page msg ID\n    msgIdLen              = msgID.length,\n    myID                  = '',\n    observer              = null,\n    resetRequiredMethods  = {max:1,min:1,bodyScroll:1,documentElementScroll:1},\n    resizeFrom            = 'child',\n    sendPermit            = true,\n    target                = window.parent,\n    targetOriginDefault   = '*',\n    tolerance             = 0,\n    triggerLocked         = false,\n    triggerLockedTimer    = null,\n    throttledTimer        = 16,\n    width                 = 1,\n    widthCalcModeDefault  = 'scroll',\n    widthCalcMode         = widthCalcModeDefault,\n    win                   = window,\n    messageCallback       = function() { warn('MessageCallback function not defined'); },\n    readyCallback         = function() {},\n    pageInfoCallback      = function() {},\n    customCalcMethods     = {\n      height: function() {\n        warn('Custom height calculation function not defined');\n        return document.documentElement.offsetHeight;\n      },\n      width: function() {\n        warn('Custom width calculation function not defined');\n        return document.body.scrollWidth;\n      }\n    },\n    eventHandlersByName   = {};\n\n\n  function addEventListener(el,evt,func) {\n    /* istanbul ignore else */ // Not testable in phantonJS\n    if ('addEventListener' in window) {\n      el.addEventListener(evt,func, false);\n    } else if ('attachEvent' in window) { //IE\n      el.attachEvent('on'+evt,func);\n    }\n  }\n\n  function removeEventListener(el,evt,func) {\n    /* istanbul ignore else */ // Not testable in phantonJS\n    if ('removeEventListener' in window) {\n      el.removeEventListener(evt,func, false);\n    } else if ('detachEvent' in window) { //IE\n      el.detachEvent('on'+evt,func);\n    }\n  }\n\n  function capitalizeFirstLetter(string) {\n    return string.charAt(0).toUpperCase() + string.slice(1);\n  }\n\n  //Based on underscore.js\n  function throttle(func) {\n    var\n      context, args, result,\n      timeout = null,\n      previous = 0,\n      later = function() {\n        previous = getNow();\n        timeout = null;\n        result = func.apply(context, args);\n        if (!timeout) {\n          context = args = null;\n        }\n      };\n\n    return function() {\n      var now = getNow();\n\n      if (!previous) {\n        previous = now;\n      }\n\n      var remaining = throttledTimer - (now - previous);\n\n      context = this;\n      args = arguments;\n\n      if (remaining <= 0 || remaining > throttledTimer) {\n        if (timeout) {\n          clearTimeout(timeout);\n          timeout = null;\n        }\n\n        previous = now;\n        result = func.apply(context, args);\n\n        if (!timeout) {\n          context = args = null;\n        }\n\n      } else if (!timeout) {\n        timeout = setTimeout(later, remaining);\n      }\n\n      return result;\n    };\n  }\n\n  var getNow = Date.now || function() {\n    /* istanbul ignore next */ // Not testable in PhantonJS\n    return new Date().getTime();\n  };\n\n  function formatLogMsg(msg) {\n    return msgID + '[' + myID + ']' + ' ' + msg;\n  }\n\n  function log(msg) {\n    if (logging && ('object' === typeof window.console)) {\n      console.log(formatLogMsg(msg));\n    }\n  }\n\n  function warn(msg) {\n    if ('object' === typeof window.console) {\n      console.warn(formatLogMsg(msg));\n    }\n  }\n\n\n  function init() {\n    readDataFromParent();\n    log('Initialising iFrame ('+location.href+')');\n    readDataFromPage();\n    setMargin();\n    setBodyStyle('background',bodyBackground);\n    setBodyStyle('padding',bodyPadding);\n    injectClearFixIntoBodyElement();\n    checkHeightMode();\n    checkWidthMode();\n    stopInfiniteResizingOfIFrame();\n    setupPublicMethods();\n    startEventListeners();\n    inPageLinks = setupInPageLinks();\n    sendSize('init','Init message from host page');\n    readyCallback();\n  }\n\n  function readDataFromParent() {\n\n    function strBool(str) {\n      return 'true' === str ? true : false;\n    }\n\n    var data = initMsg.substr(msgIdLen).split(':');\n\n    myID               = data[0];\n    bodyMargin         = (undefined !== data[1]) ? Number(data[1])   : bodyMargin; //For V1 compatibility\n    calculateWidth     = (undefined !== data[2]) ? strBool(data[2])  : calculateWidth;\n    logging            = (undefined !== data[3]) ? strBool(data[3])  : logging;\n    interval           = (undefined !== data[4]) ? Number(data[4])   : interval;\n    autoResize         = (undefined !== data[6]) ? strBool(data[6])  : autoResize;\n    bodyMarginStr      = data[7];\n    heightCalcMode     = (undefined !== data[8]) ? data[8]           : heightCalcMode;\n    bodyBackground     = data[9];\n    bodyPadding        = data[10];\n    tolerance          = (undefined !== data[11]) ? Number(data[11]) : tolerance;\n    inPageLinks.enable = (undefined !== data[12]) ? strBool(data[12]): false;\n    resizeFrom         = (undefined !== data[13]) ? data[13]         : resizeFrom;\n    widthCalcMode      = (undefined !== data[14]) ? data[14]         : widthCalcMode;\n  }\n\n  function readDataFromPage() {\n    function readData() {\n      var data = window.iFrameResizer;\n\n      log('Reading data from page: ' + JSON.stringify(data));\n\n      messageCallback     = ('messageCallback'         in data) ? data.messageCallback         : messageCallback;\n      readyCallback       = ('readyCallback'           in data) ? data.readyCallback           : readyCallback;\n      targetOriginDefault = ('targetOrigin'            in data) ? data.targetOrigin            : targetOriginDefault;\n      heightCalcMode      = ('heightCalculationMethod' in data) ? data.heightCalculationMethod : heightCalcMode;\n      widthCalcMode       = ('widthCalculationMethod'  in data) ? data.widthCalculationMethod  : widthCalcMode;\n    }\n\n    function setupCustomCalcMethods(calcMode, calcFunc) {\n      if ('function' === typeof calcMode) {\n        log('Setup custom ' + calcFunc + 'CalcMethod');\n        customCalcMethods[calcFunc] = calcMode;\n        calcMode = 'custom';\n      }\n\n      return calcMode;\n    }\n\n    if(('iFrameResizer' in window) && (Object === window.iFrameResizer.constructor)) {\n      readData();\n      heightCalcMode = setupCustomCalcMethods(heightCalcMode, 'height');\n      widthCalcMode  = setupCustomCalcMethods(widthCalcMode,  'width');\n    }\n\n    log('TargetOrigin for parent set to: ' + targetOriginDefault);\n  }\n\n\n  function chkCSS(attr,value) {\n    if (-1 !== value.indexOf('-')) {\n      warn('Negative CSS value ignored for '+attr);\n      value='';\n    }\n    return value;\n  }\n\n  function setBodyStyle(attr,value) {\n    if ((undefined !== value) && ('' !== value) && ('null' !== value)) {\n      document.body.style[attr] = value;\n      log('Body '+attr+' set to \"'+value+'\"');\n    }\n  }\n\n  function setMargin() {\n    //If called via V1 script, convert bodyMargin from int to str\n    if (undefined === bodyMarginStr) {\n      bodyMarginStr = bodyMargin+'px';\n    }\n\n    setBodyStyle('margin',chkCSS('margin',bodyMarginStr));\n  }\n\n  function stopInfiniteResizingOfIFrame() {\n    document.documentElement.style.height = '';\n    document.body.style.height = '';\n    log('HTML & body height set to \"auto\"');\n  }\n\n\n  function manageTriggerEvent(options) {\n\n    var listener = {\n      add:    function(eventName) {\n        function handleEvent() {\n          sendSize(options.eventName,options.eventType);\n        }\n\n        eventHandlersByName[eventName] = handleEvent;\n\n        addEventListener(window,eventName,handleEvent);\n      },\n      remove: function(eventName) {\n        var handleEvent = eventHandlersByName[eventName];\n        delete eventHandlersByName[eventName];\n\n        removeEventListener(window,eventName,handleEvent);\n      }\n    };\n\n    if(options.eventNames && Array.prototype.map) {\n      options.eventName = options.eventNames[0];\n      options.eventNames.map(listener[options.method]);\n    } else {\n      listener[options.method](options.eventName);\n    }\n\n    log(capitalizeFirstLetter(options.method) + ' event listener: ' + options.eventType);\n  }\n\n  function manageEventListeners(method) {\n    manageTriggerEvent({method:method, eventType: 'Animation Start',           eventNames: ['animationstart','webkitAnimationStart'] });\n    manageTriggerEvent({method:method, eventType: 'Animation Iteration',       eventNames: ['animationiteration','webkitAnimationIteration'] });\n    manageTriggerEvent({method:method, eventType: 'Animation End',             eventNames: ['animationend','webkitAnimationEnd'] });\n    manageTriggerEvent({method:method, eventType: 'Input',                     eventName:  'input' });\n    manageTriggerEvent({method:method, eventType: 'Mouse Up',                  eventName:  'mouseup' });\n    manageTriggerEvent({method:method, eventType: 'Mouse Down',                eventName:  'mousedown' });\n    manageTriggerEvent({method:method, eventType: 'Orientation Change',        eventName:  'orientationchange' });\n    manageTriggerEvent({method:method, eventType: 'Print',                     eventName:  ['afterprint', 'beforeprint'] });\n    manageTriggerEvent({method:method, eventType: 'Ready State Change',        eventName:  'readystatechange' });\n    manageTriggerEvent({method:method, eventType: 'Touch Start',               eventName:  'touchstart' });\n    manageTriggerEvent({method:method, eventType: 'Touch End',                 eventName:  'touchend' });\n    manageTriggerEvent({method:method, eventType: 'Touch Cancel',              eventName:  'touchcancel' });\n    manageTriggerEvent({method:method, eventType: 'Transition Start',          eventNames: ['transitionstart','webkitTransitionStart','MSTransitionStart','oTransitionStart','otransitionstart'] });\n    manageTriggerEvent({method:method, eventType: 'Transition Iteration',      eventNames: ['transitioniteration','webkitTransitionIteration','MSTransitionIteration','oTransitionIteration','otransitioniteration'] });\n    manageTriggerEvent({method:method, eventType: 'Transition End',            eventNames: ['transitionend','webkitTransitionEnd','MSTransitionEnd','oTransitionEnd','otransitionend'] });\n    if('child' === resizeFrom) {\n      manageTriggerEvent({method:method, eventType: 'IFrame Resized',        eventName:  'resize' });\n    }\n  }\n\n  function checkCalcMode(calcMode,calcModeDefault,modes,type) {\n    if (calcModeDefault !== calcMode) {\n      if (!(calcMode in modes)) {\n        warn(calcMode + ' is not a valid option for '+type+'CalculationMethod.');\n        calcMode=calcModeDefault;\n      }\n      log(type+' calculation method set to \"'+calcMode+'\"');\n    }\n\n    return calcMode;\n  }\n\n  function checkHeightMode() {\n    heightCalcMode = checkCalcMode(heightCalcMode,heightCalcModeDefault,getHeight,'height');\n  }\n\n  function checkWidthMode() {\n    widthCalcMode = checkCalcMode(widthCalcMode,widthCalcModeDefault,getWidth,'width');\n  }\n\n  function startEventListeners() {\n    if ( true === autoResize ) {\n      manageEventListeners('add');\n      setupMutationObserver();\n    }\n    else {\n      log('Auto Resize disabled');\n    }\n  }\n\n  function stopMsgsToParent() {\n    log('Disable outgoing messages');\n    sendPermit = false;\n  }\n\n  function removeMsgListener() {\n    log('Remove event listener: Message');\n    removeEventListener(window, 'message', receiver);\n  }\n\n  function disconnectMutationObserver() {\n    if (null !== bodyObserver) {\n      /* istanbul ignore next */ // Not testable in PhantonJS\n      bodyObserver.disconnect();\n    }\n  }\n\n  function stopEventListeners() {\n    manageEventListeners('remove');\n    disconnectMutationObserver();\n    clearInterval(intervalTimer);\n  }\n\n  function teardown() {\n    stopMsgsToParent();\n    removeMsgListener();\n    if (true === autoResize) stopEventListeners();\n  }\n\n  function injectClearFixIntoBodyElement() {\n    var clearFix = document.createElement('div');\n    clearFix.style.clear   = 'both';\n    clearFix.style.display = 'block'; //Guard against this having been globally redefined in CSS.\n    document.body.appendChild(clearFix);\n  }\n\n  function setupInPageLinks() {\n\n    function getPagePosition () {\n      return {\n        x: (window.pageXOffset !== undefined) ? window.pageXOffset : document.documentElement.scrollLeft,\n        y: (window.pageYOffset !== undefined) ? window.pageYOffset : document.documentElement.scrollTop\n      };\n    }\n\n    function getElementPosition(el) {\n      var\n        elPosition   = el.getBoundingClientRect(),\n        pagePosition = getPagePosition();\n\n      return {\n        x: parseInt(elPosition.left,10) + parseInt(pagePosition.x,10),\n        y: parseInt(elPosition.top,10)  + parseInt(pagePosition.y,10)\n      };\n    }\n\n    function findTarget(location) {\n      function jumpToTarget(target) {\n        var jumpPosition = getElementPosition(target);\n\n        log('Moving to in page link (#'+hash+') at x: '+jumpPosition.x+' y: '+jumpPosition.y);\n        sendMsg(jumpPosition.y, jumpPosition.x, 'scrollToOffset'); // X&Y reversed at sendMsg uses height/width\n      }\n\n      var\n        hash     = location.split('#')[1] || location, //Remove # if present\n        hashData = decodeURIComponent(hash),\n        target   = document.getElementById(hashData) || document.getElementsByName(hashData)[0];\n\n      if (undefined !== target) {\n        jumpToTarget(target);\n      } else {\n        log('In page link (#' + hash + ') not found in iFrame, so sending to parent');\n        sendMsg(0,0,'inPageLink','#'+hash);\n      }\n    }\n\n    function checkLocationHash() {\n      if ('' !== location.hash && '#' !== location.hash) {\n        findTarget(location.href);\n      }\n    }\n\n    function bindAnchors() {\n      function setupLink(el) {\n        function linkClicked(e) {\n          e.preventDefault();\n\n          /*jshint validthis:true */\n          findTarget(this.getAttribute('href'));\n        }\n\n        if ('#' !== el.getAttribute('href')) {\n          addEventListener(el,'click',linkClicked);\n        }\n      }\n\n      Array.prototype.forEach.call( document.querySelectorAll( 'a[href^=\"#\"]' ), setupLink );\n    }\n\n    function bindLocationHash() {\n      addEventListener(window,'hashchange',checkLocationHash);\n    }\n\n    function initCheck() { //check if page loaded with location hash after init resize\n      setTimeout(checkLocationHash,eventCancelTimer);\n    }\n\n    function enableInPageLinks() {\n      /* istanbul ignore else */ // Not testable in phantonJS\n      if(Array.prototype.forEach && document.querySelectorAll) {\n        log('Setting up location.hash handlers');\n        bindAnchors();\n        bindLocationHash();\n        initCheck();\n      } else {\n        warn('In page linking not fully supported in this browser! (See README.md for IE8 workaround)');\n      }\n    }\n\n    if(inPageLinks.enable) {\n      enableInPageLinks();\n    } else {\n      log('In page linking not enabled');\n    }\n\n    return {\n      findTarget:findTarget\n    };\n  }\n\n  function setupPublicMethods() {\n    log('Enable public methods');\n\n    win.parentIFrame = {\n\n      autoResize: function autoResizeF(resize) {\n        if (true === resize && false === autoResize) {\n          autoResize=true;\n          startEventListeners();\n          //sendSize('autoResize','Auto Resize enabled');\n        } else if (false === resize && true === autoResize) {\n          autoResize=false;\n          stopEventListeners();\n        }\n\n        return autoResize;\n      },\n\n      close: function closeF() {\n        sendMsg(0,0,'close');\n        teardown();\n      },\n\n      getId: function getIdF() {\n        return myID;\n      },\n\n      getPageInfo: function getPageInfoF(callback) {\n        if ('function' === typeof callback) {\n          pageInfoCallback = callback;\n          sendMsg(0,0,'pageInfo');\n        } else {\n          pageInfoCallback = function() {};\n          sendMsg(0,0,'pageInfoStop');\n        }\n      },\n\n      moveToAnchor: function moveToAnchorF(hash) {\n        inPageLinks.findTarget(hash);\n      },\n\n      reset: function resetF() {\n        resetIFrame('parentIFrame.reset');\n      },\n\n      scrollTo: function scrollToF(x,y) {\n        sendMsg(y,x,'scrollTo'); // X&Y reversed at sendMsg uses height/width\n      },\n\n      scrollToOffset: function scrollToF(x,y) {\n        sendMsg(y,x,'scrollToOffset'); // X&Y reversed at sendMsg uses height/width\n      },\n\n      sendMessage: function sendMessageF(msg,targetOrigin) {\n        sendMsg(0,0,'message',JSON.stringify(msg),targetOrigin);\n      },\n\n      setHeightCalculationMethod: function setHeightCalculationMethodF(heightCalculationMethod) {\n        heightCalcMode = heightCalculationMethod;\n        checkHeightMode();\n      },\n\n      setWidthCalculationMethod: function setWidthCalculationMethodF(widthCalculationMethod) {\n        widthCalcMode = widthCalculationMethod;\n        checkWidthMode();\n      },\n\n      setTargetOrigin: function setTargetOriginF(targetOrigin) {\n        log('Set targetOrigin: '+targetOrigin);\n        targetOriginDefault = targetOrigin;\n      },\n\n      size: function sizeF(customHeight, customWidth) {\n        var valString = ''+(customHeight?customHeight:'')+(customWidth?','+customWidth:'');\n        //lockTrigger();\n        sendSize('size','parentIFrame.size('+valString+')', customHeight, customWidth);\n      }\n    };\n  }\n\n  function initInterval() {\n    if ( 0 !== interval ) {\n      log('setInterval: '+interval+'ms');\n      intervalTimer = setInterval(function() {\n        sendSize('interval','setInterval: '+interval);\n      },Math.abs(interval));\n    }\n  }\n\n  /* istanbul ignore next */  //Not testable in PhantomJS\n  function setupBodyMutationObserver() {\n    function addImageLoadListners(mutation) {\n      function addImageLoadListener(element) {\n        if (false === element.complete) {\n          log('Attach listeners to ' + element.src);\n          element.addEventListener('load', imageLoaded, false);\n          element.addEventListener('error', imageError, false);\n          elements.push(element);\n        }\n      }\n\n      if (mutation.type === 'attributes' && mutation.attributeName === 'src') {\n        addImageLoadListener(mutation.target);\n      } else if (mutation.type === 'childList') {\n        Array.prototype.forEach.call(\n          mutation.target.querySelectorAll('img'),\n          addImageLoadListener\n        );\n      }\n    }\n\n    function removeFromArray(element) {\n      elements.splice(elements.indexOf(element),1);\n    }\n\n    function removeImageLoadListener(element) {\n      log('Remove listeners from ' + element.src);\n      element.removeEventListener('load', imageLoaded, false);\n      element.removeEventListener('error', imageError, false);\n      removeFromArray(element);\n    }\n\n    function imageEventTriggered(event,type,typeDesc) {\n      removeImageLoadListener(event.target);\n      sendSize(type, typeDesc + ': ' + event.target.src, undefined, undefined);\n    }\n\n    function imageLoaded(event) {\n      imageEventTriggered(event,'imageLoad','Image loaded');\n    }\n\n    function imageError(event) {\n      imageEventTriggered(event,'imageLoadFailed','Image load failed');\n    }\n\n    function mutationObserved(mutations) {\n      sendSize('mutationObserver','mutationObserver: ' + mutations[0].target + ' ' + mutations[0].type);\n\n      //Deal with WebKit asyncing image loading when tags are injected into the page\n      mutations.forEach(addImageLoadListners);\n    }\n\n    function createMutationObserver() {\n      var\n        target = document.querySelector('body'),\n\n        config = {\n          attributes            : true,\n          attributeOldValue     : false,\n          characterData         : true,\n          characterDataOldValue : false,\n          childList             : true,\n          subtree               : true\n        };\n\n      observer = new MutationObserver(mutationObserved);\n\n      log('Create body MutationObserver');\n      observer.observe(target, config);\n\n      return observer;\n    }\n\n    var\n      elements         = [],\n      MutationObserver = window.MutationObserver || window.WebKitMutationObserver,\n      observer         = createMutationObserver();\n\n    return {\n      disconnect: function () {\n        if ('disconnect' in observer) {\n          log('Disconnect body MutationObserver');\n          observer.disconnect();\n          elements.forEach(removeImageLoadListener);\n        }\n      }\n    };\n  }\n\n  function setupMutationObserver() {\n    var\tforceIntervalTimer = 0 > interval;\n\n    /* istanbul ignore if */ // Not testable in PhantomJS\n    if (window.MutationObserver || window.WebKitMutationObserver) {\n      if (forceIntervalTimer) {\n        initInterval();\n      } else {\n        bodyObserver = setupBodyMutationObserver();\n      }\n    } else {\n      log('MutationObserver not supported in this browser!');\n      initInterval();\n    }\n  }\n\n\n  // document.documentElement.offsetHeight is not reliable, so\n  // we have to jump through hoops to get a better value.\n  function getComputedStyle(prop,el) {\n    /* istanbul ignore next */  //Not testable in PhantomJS\n    function convertUnitsToPxForIE8(value) {\n      var PIXEL = /^\\d+(px)?$/i;\n\n      if (PIXEL.test(value)) {\n        return parseInt(value,base);\n      }\n\n      var\n        style = el.style.left,\n        runtimeStyle = el.runtimeStyle.left;\n\n      el.runtimeStyle.left = el.currentStyle.left;\n      el.style.left = value || 0;\n      value = el.style.pixelLeft;\n      el.style.left = style;\n      el.runtimeStyle.left = runtimeStyle;\n\n      return value;\n    }\n\n    var retVal = 0;\n    el =  el || document.body;\n\n    /* istanbul ignore else */ // Not testable in phantonJS\n    if (('defaultView' in document) && ('getComputedStyle' in document.defaultView)) {\n      retVal = document.defaultView.getComputedStyle(el, null);\n      retVal = (null !== retVal) ? retVal[prop] : 0;\n    } else {//IE8\n      retVal =  convertUnitsToPxForIE8(el.currentStyle[prop]);\n    }\n\n    return parseInt(retVal,base);\n  }\n\n  function chkEventThottle(timer) {\n    if(timer > throttledTimer/2) {\n      throttledTimer = 2*timer;\n      log('Event throttle increased to ' + throttledTimer + 'ms');\n    }\n  }\n\n  //Idea from https://github.com/guardian/iframe-messenger\n  function getMaxElement(side,elements) {\n    var\n      elementsLength = elements.length,\n      elVal          = 0,\n      maxVal         = 0,\n      Side           = capitalizeFirstLetter(side),\n      timer          = getNow();\n\n    for (var i = 0; i < elementsLength; i++) {\n      elVal = elements[i].getBoundingClientRect()[side] + getComputedStyle('margin'+Side,elements[i]);\n      if (elVal > maxVal) {\n        maxVal = elVal;\n      }\n    }\n\n    timer = getNow() - timer;\n\n    log('Parsed '+elementsLength+' HTML elements');\n    log('Element position calculated in ' + timer + 'ms');\n\n    chkEventThottle(timer);\n\n    return maxVal;\n  }\n\n  function getAllMeasurements(dimention) {\n    return [\n      dimention.bodyOffset(),\n      dimention.bodyScroll(),\n      dimention.documentElementOffset(),\n      dimention.documentElementScroll()\n    ];\n  }\n\n  function getTaggedElements(side,tag) {\n    function noTaggedElementsFound() {\n      warn('No tagged elements ('+tag+') found on page');\n      return document.querySelectorAll('body *');\n    }\n\n    var elements = document.querySelectorAll('['+tag+']');\n\n    if (0 === elements.length) noTaggedElementsFound();\n\n    return getMaxElement(side,elements);\n  }\n\n  function getAllElements() {\n    return document.querySelectorAll('body *');\n  }\n\n  var\n    getHeight = {\n      bodyOffset: function getBodyOffsetHeight() {\n        return  document.body.offsetHeight + getComputedStyle('marginTop') + getComputedStyle('marginBottom');\n      },\n\n      offset: function() {\n        return getHeight.bodyOffset(); //Backwards compatability\n      },\n\n      bodyScroll: function getBodyScrollHeight() {\n        return document.body.scrollHeight;\n      },\n\n      custom: function getCustomWidth() {\n        return customCalcMethods.height();\n      },\n\n      documentElementOffset: function getDEOffsetHeight() {\n        return document.documentElement.offsetHeight;\n      },\n\n      documentElementScroll: function getDEScrollHeight() {\n        return document.documentElement.scrollHeight;\n      },\n\n      max: function getMaxHeight() {\n        return Math.max.apply(null,getAllMeasurements(getHeight));\n      },\n\n      min: function getMinHeight() {\n        return Math.min.apply(null,getAllMeasurements(getHeight));\n      },\n\n      grow: function growHeight() {\n        return getHeight.max(); //Run max without the forced downsizing\n      },\n\n      lowestElement: function getBestHeight() {\n        return Math.max(getHeight.bodyOffset(), getMaxElement('bottom',getAllElements()));\n      },\n\n      taggedElement: function getTaggedElementsHeight() {\n        return getTaggedElements('bottom','data-iframe-height');\n      }\n    },\n\n    getWidth = {\n      bodyScroll: function getBodyScrollWidth() {\n        return document.body.scrollWidth;\n      },\n\n      bodyOffset: function getBodyOffsetWidth() {\n        return document.body.offsetWidth;\n      },\n\n      custom: function getCustomWidth() {\n        return customCalcMethods.width();\n      },\n\n      documentElementScroll: function getDEScrollWidth() {\n        return document.documentElement.scrollWidth;\n      },\n\n      documentElementOffset: function getDEOffsetWidth() {\n        return document.documentElement.offsetWidth;\n      },\n\n      scroll: function getMaxWidth() {\n        return Math.max(getWidth.bodyScroll(), getWidth.documentElementScroll());\n      },\n\n      max: function getMaxWidth() {\n        return Math.max.apply(null,getAllMeasurements(getWidth));\n      },\n\n      min: function getMinWidth() {\n        return Math.min.apply(null,getAllMeasurements(getWidth));\n      },\n\n      rightMostElement: function rightMostElement() {\n        return getMaxElement('right', getAllElements());\n      },\n\n      taggedElement: function getTaggedElementsWidth() {\n        return getTaggedElements('right', 'data-iframe-width');\n      }\n    };\n\n\n  function sizeIFrame(triggerEvent, triggerEventDesc, customHeight, customWidth) {\n\n    function resizeIFrame() {\n      height = currentHeight;\n      width  = currentWidth;\n\n      sendMsg(height,width,triggerEvent);\n    }\n\n    function isSizeChangeDetected() {\n      function checkTolarance(a,b) {\n        var retVal = Math.abs(a-b) <= tolerance;\n        return !retVal;\n      }\n\n      currentHeight = (undefined !== customHeight)  ? customHeight : getHeight[heightCalcMode]();\n      currentWidth  = (undefined !== customWidth )  ? customWidth  : getWidth[widthCalcMode]();\n\n      return\tcheckTolarance(height,currentHeight) || (calculateWidth && checkTolarance(width,currentWidth));\n    }\n\n    function isForceResizableEvent() {\n      return !(triggerEvent in {'init':1,'interval':1,'size':1});\n    }\n\n    function isForceResizableCalcMode() {\n      return (heightCalcMode in resetRequiredMethods) || (calculateWidth && widthCalcMode in resetRequiredMethods);\n    }\n\n    function logIgnored() {\n      log('No change in size detected');\n    }\n\n    function checkDownSizing() {\n      if (isForceResizableEvent() && isForceResizableCalcMode()) {\n        resetIFrame(triggerEventDesc);\n      } else if (!(triggerEvent in {'interval':1})) {\n        logIgnored();\n      }\n    }\n\n    var\tcurrentHeight,currentWidth;\n\n    if (isSizeChangeDetected() || 'init' === triggerEvent) {\n      lockTrigger();\n      resizeIFrame();\n    } else {\n      checkDownSizing();\n    }\n  }\n\n  var sizeIFrameThrottled = throttle(sizeIFrame);\n\n  function sendSize(triggerEvent, triggerEventDesc, customHeight, customWidth) {\n    function recordTrigger() {\n      if (!(triggerEvent in {'reset':1,'resetPage':1,'init':1})) {\n        log( 'Trigger event: ' + triggerEventDesc );\n      }\n    }\n\n    function isDoubleFiredEvent() {\n      return  triggerLocked && (triggerEvent in doubleEventList);\n    }\n\n    if (!isDoubleFiredEvent()) {\n      recordTrigger();\n      if (triggerEvent === 'init') {\n        sizeIFrame(triggerEvent, triggerEventDesc, customHeight, customWidth);\n      } else {\n        sizeIFrameThrottled(triggerEvent, triggerEventDesc, customHeight, customWidth);\n      }\n    } else {\n      log('Trigger event cancelled: '+triggerEvent);\n    }\n  }\n\n  function lockTrigger() {\n    if (!triggerLocked) {\n      triggerLocked = true;\n      log('Trigger event lock on');\n    }\n    clearTimeout(triggerLockedTimer);\n    triggerLockedTimer = setTimeout(function() {\n      triggerLocked = false;\n      log('Trigger event lock off');\n      log('--');\n    },eventCancelTimer);\n  }\n\n  function triggerReset(triggerEvent) {\n    height = getHeight[heightCalcMode]();\n    width  = getWidth[widthCalcMode]();\n\n    sendMsg(height,width,triggerEvent);\n  }\n\n  function resetIFrame(triggerEventDesc) {\n    var hcm = heightCalcMode;\n    heightCalcMode = heightCalcModeDefault;\n\n    log('Reset trigger event: ' + triggerEventDesc);\n    lockTrigger();\n    triggerReset('reset');\n\n    heightCalcMode = hcm;\n  }\n\n  function sendMsg(height,width,triggerEvent,msg,targetOrigin) {\n    function setTargetOrigin() {\n      if (undefined === targetOrigin) {\n        targetOrigin = targetOriginDefault;\n      } else {\n        log('Message targetOrigin: '+targetOrigin);\n      }\n    }\n\n    function sendToParent() {\n      var\n        size  = height + ':' + width,\n        message = myID + ':' +  size + ':' + triggerEvent + (undefined !== msg ? ':' + msg : '');\n\n      log('Sending message to host page (' + message + ')');\n      target.postMessage( msgID + message, targetOrigin);\n    }\n\n    if(true === sendPermit) {\n      setTargetOrigin();\n      sendToParent();\n    }\n  }\n\n  function receiver(event) {\n    var processRequestFromParent = {\n      init: function initFromParent() {\n        function fireInit() {\n          initMsg = event.data;\n          target  = event.source;\n\n          init();\n          firstRun = false;\n          setTimeout(function() { initLock = false;},eventCancelTimer);\n        }\n\n        if (document.readyState === \"interactive\" || document.readyState === \"complete\") {\n          fireInit();\n        } else {\n          log('Waiting for page ready');\n          addEventListener(window,'readystatechange',processRequestFromParent.initFromParent);\n        }\n      },\n\n      reset: function resetFromParent() {\n        if (!initLock) {\n          log('Page size reset by host page');\n          triggerReset('resetPage');\n        } else {\n          log('Page reset ignored by init');\n        }\n      },\n\n      resize: function resizeFromParent() {\n        sendSize('resizeParent','Parent window requested size check');\n      },\n\n      moveToAnchor: function moveToAnchorF() {\n        inPageLinks.findTarget(getData());\n      },\n      inPageLink: function inPageLinkF() {this.moveToAnchor();}, //Backward compatability\n\n      pageInfo: function pageInfoFromParent() {\n        var msgBody = getData();\n        log('PageInfoFromParent called from parent: ' + msgBody );\n        pageInfoCallback(JSON.parse(msgBody));\n        log(' --');\n      },\n\n      message: function messageFromParent() {\n        var msgBody = getData();\n\n        log('MessageCallback called from parent: ' + msgBody );\n        messageCallback(JSON.parse(msgBody));\n        log(' --');\n      }\n    };\n\n    function isMessageForUs() {\n      return msgID === (''+event.data).substr(0,msgIdLen); //''+ Protects against non-string messages\n    }\n\n    function getMessageType() {\n      return event.data.split(']')[1].split(':')[0];\n    }\n\n    function getData() {\n      return event.data.substr(event.data.indexOf(':')+1);\n    }\n\n    function isMiddleTier() {\n      return !(typeof module !== 'undefined' && module.exports) && ('iFrameResize' in window);\n    }\n\n    function isInitMsg() {\n      //Test if this message is from a child below us. This is an ugly test, however, updating\n      //the message format would break backwards compatibity.\n      return event.data.split(':')[2] in {'true':1,'false':1};\n    }\n\n    function callFromParent() {\n      var messageType = getMessageType();\n\n      if (messageType in processRequestFromParent) {\n        processRequestFromParent[messageType]();\n      } else if (!isMiddleTier() && !isInitMsg()) {\n        warn('Unexpected message ('+event.data+')');\n      }\n    }\n\n    function processMessage() {\n      if (false === firstRun) {\n        callFromParent();\n      } else if (isInitMsg()) {\n        processRequestFromParent.init();\n      } else {\n        log('Ignored message of type \"' + getMessageType() + '\". Received before initialization.');\n      }\n    }\n\n    if (isMessageForUs()) {\n      processMessage();\n    }\n  }\n\n  //Normally the parent kicks things off when it detects the iFrame has loaded.\n  //If this script is async-loaded, then tell parent page to retry init.\n  function chkLateLoaded() {\n    if('loading' !== document.readyState) {\n      window.parent.postMessage('[iFrameResizerChild]Ready','*');\n    }\n  }\n\n  addEventListener(window, 'message', receiver);\n  chkLateLoaded();\n\n  \n\n})();\n"]}