From 21fc6268ea0d4903b261721ad6071fae37caf8f0 Mon Sep 17 00:00:00 2001 From: Greg Howdeshell Date: Mon, 5 Dec 2016 14:17:22 -0600 Subject: [PATCH] initial example of the iframe-resizer not functioning with height: 100% --- assets/foundation.css | 42 + frame.absolute.html | 88 ++ frame.content.html | 213 +++++ frame.hover.html | 51 ++ frame.nested.html | 72 ++ frame.textarea.html | 46 + frame.tolerance.html | 79 ++ index.html | 70 ++ js/ie8.polyfils.map | 1 + js/ie8.polyfils.min.js | 4 + js/iframeResizer.contentWindow.js | 1108 +++++++++++++++++++++++++ js/iframeResizer.contentWindow.map | 1 + js/iframeResizer.contentWindow.min.js | 10 + js/iframeResizer.js | 1002 ++++++++++++++++++++++ js/iframeResizer.map | 1 + js/iframeResizer.min.js | 9 + js/index.js | 2 + two.html | 71 ++ 18 files changed, 2870 insertions(+) create mode 100644 assets/foundation.css create mode 100644 frame.absolute.html create mode 100644 frame.content.html create mode 100644 frame.hover.html create mode 100644 frame.nested.html create mode 100644 frame.textarea.html create mode 100644 frame.tolerance.html create mode 100644 index.html create mode 100644 js/ie8.polyfils.map create mode 100644 js/ie8.polyfils.min.js create mode 100644 js/iframeResizer.contentWindow.js create mode 100644 js/iframeResizer.contentWindow.map create mode 100644 js/iframeResizer.contentWindow.min.js create mode 100644 js/iframeResizer.js create mode 100644 js/iframeResizer.map create mode 100644 js/iframeResizer.min.js create mode 100644 js/index.js create mode 100644 two.html diff --git a/assets/foundation.css b/assets/foundation.css new file mode 100644 index 0000000..ab30633 --- /dev/null +++ b/assets/foundation.css @@ -0,0 +1,42 @@ +html { + word-wrap: break-word; + word-break: break-word; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 87.5%; + -ms-text-size-adjust: 100%; + -webkit-text-size-adjust: 100%; + text-size-adjust: 100%; + height: 100%; +} +h1, +h2, +h3, +h4, +h5, +h6, +dl, +ol, +ul, +p, +table { + margin: 0; +} +ol, +ul { + padding-left: 0; + padding-right: 0; + list-style: none; +} +dd { + margin-left: 0; + margin-right: 0; +} +body { + line-height: 20px; + line-height: 1.4285714285714286rem; + margin: 0; + font-size: 1em; + background-color: #ffffff; + color: #1c1f21; + height: 100%; +} \ No newline at end of file diff --git a/frame.absolute.html b/frame.absolute.html new file mode 100644 index 0000000..e3858df --- /dev/null +++ b/frame.absolute.html @@ -0,0 +1,88 @@ + + + + + iFrame message passing test + + + + + + + +

+ iFrame + + Back to page 1 +   + Bottom +   + Scroll to iFrame +   + Jump to iFrame anchor + Jump to parent anchor +

+

+ This page has an absolute position elemnt that take it out side the normal document body, which is marked with a red border on this page. This prevents the normal height calculation, which is based on the body tag from returning the correct height. To work around this you can set the heightCalculationMethod option to use one of the other page height propeties. +

+

+ Use the dropdown to change the sizing method of the page, select the different sizing options to see how the effect the page. Note that they can have different effects in different browsers, so you are normally best off selecting max if you need to change away from the default bodyOffset option. +

+

+ Height Calculation Method + +

+

+ This option should be used sparingly, as the alternate methods can be less acurate at working out the correct page size, can cause screen flicker and can sometimes fail to reduce in size when the frame content changes in browsers that do not support mutationObservers (See caniuse.com for details). +

+ Test in page anchor + +
+ Absolute positioned element + Top +
+ + + + + + + + \ No newline at end of file diff --git a/frame.content.html b/frame.content.html new file mode 100644 index 0000000..0ed5092 --- /dev/null +++ b/frame.content.html @@ -0,0 +1,213 @@ + + + + + iFrame message passing test + + + + + + + + + +
+
+
+ +
+
+
+

Visit List

+
+
+
+
+
+
    +
  • +
    +

    Future

    +
    +
  • +
  • +
    +

    No future visits for this patient

    +
    +
  • +
  • +
    +

    Previous

    +
    +
  • +
  • +
    +
    +
    +
    +
    +
    +
    +
    Apr 7, 2016 5:20 PM
    +
    +
    +
    Inpatient
    +
    +
    +
    +
    +
    --
    +
    +
    +
    Foo, Bar
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    Apr 7, 2016 5:20 PM
    +
    +
    +
    Inpatient
    +
    +
    +
    --
    +
    +
    +
    Foo, Bar
    +
    +
    +
    +
    +
  • +
  • +
    +
    +
    +
    +
    +
    +
    +
    Mar 30, 2016 3:38 PM
    +
    +
    +
    Inpatient
    +
    +
    +
    +
    +
    --
    +
    +
    +
    Baz, Bar
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    Mar 30, 2016 3:38 PM
    +
    +
    +
    Inpatient
    +
    +
    +
    --
    +
    +
    +
    Baz, Bar
    +
    +
    +
    +
    +
  • +
  • +
    +
    +
    +
    +
    +
    +
    +
    Mar 29, 2016 8:35 PM
    +
    +
    +
    Inpatient
    +
    +
    +
    +
    +
    --
    +
    +
    +
    FooBar, Baz
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    Mar 29, 2016 8:35 PM
    +
    +
    +
    Inpatient
    +
    +
    +
    --
    +
    +
    +
    FooBar, Baz
    +
    +
    +
    +
    +
  • +
  • +
    +
    +
    +
    +
    +
    +
    +
    View More...
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    View More...
    +
    +
    +
    +
    +
  • +
+
+
+
+
+
+ +
+ + +
+ + + \ No newline at end of file diff --git a/frame.hover.html b/frame.hover.html new file mode 100644 index 0000000..647484e --- /dev/null +++ b/frame.hover.html @@ -0,0 +1,51 @@ + + + + + iFrame message passing test + + + + + + + iFrame :Hover Example + Back to page 1 + +

+ Mouse over the code example below. +

+ + <!-- #code --> + + + + + + +
+ + +
+ + + + \ No newline at end of file diff --git a/frame.nested.html b/frame.nested.html new file mode 100644 index 0000000..52adf08 --- /dev/null +++ b/frame.nested.html @@ -0,0 +1,72 @@ + + + + + iFrame message passing test + + + + + + + Back to page 1 +

Nested iFrame

+

Resize window or click one of the links in the nested iFrame to watch it resize.

+
+ +
+

+

+ + + + + + + + + \ No newline at end of file diff --git a/frame.textarea.html b/frame.textarea.html new file mode 100644 index 0000000..9d12fdb --- /dev/null +++ b/frame.textarea.html @@ -0,0 +1,46 @@ + + + + + iFrame message passing test + + + + + + + iFrame TextArea Example + Back to page 1 + + +

+ Resize the textarea below. +

+ + + + + + + + + + \ No newline at end of file diff --git a/frame.tolerance.html b/frame.tolerance.html new file mode 100644 index 0000000..ce5b517 --- /dev/null +++ b/frame.tolerance.html @@ -0,0 +1,79 @@ + + + + + iFrame message passing test + + + + + +

+ iFrame + + Back to page 1 +   + Bottom +

+

+ This page has an absolute position elemnt that take it out side the normal document body, which is marked with a red border on this page. This prevents the normal height calculation, which is based on the body tag from returning the correct height. To work around this you can set the heightCalculationMethod option to use one of the other page height propeties. +

+

+ Use the dropdown to change the sizing method of the page, select the different sizing options to see how the effect the page. Note that they can have different effects in different browsers, so you are normally best off selecting max if you need to change away from the default bodyOffset option. +

+

+ Height Calculation Method + +

+

+ This option should be used sparingly, as the alternate methods can be less acurate at working out the correct page size, can cause screen flicker and can sometimes fail to reduce in size when the frame content changes in browsers that do not support mutationObservers (See caniuse.com for details). +

+ +
+ Absolute positioned element + Top +
+ + + + + + + \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..63bea51 --- /dev/null +++ b/index.html @@ -0,0 +1,70 @@ + + + + + iFrame message passing test + + + + + +

Automagically resizing iFrame

+

Resize window or click one of the links in the iFrame to watch it resize. Or try with two iFrames.

+
+ +
+

+

+
+ For details on how this works, see + http://davidjbradshaw.github.io/iframe-resizer/. +
+ + + + + + + + + \ No newline at end of file diff --git a/js/ie8.polyfils.map b/js/ie8.polyfils.map new file mode 100644 index 0000000..eb0ef37 --- /dev/null +++ b/js/ie8.polyfils.map @@ -0,0 +1 @@ +{"version":3,"file":"ie8.polyfils.min.js","sources":["../src/ie8.polyfils.js"],"names":["Array","prototype","forEach","fun","this","TypeError","t","Object","len","length","thisArg","arguments","i","call","Function","bind","oThis","aArgs","slice","fToBind","fNOP","fBound","apply","concat","callback","O","k"],"mappings":";;AAOMA,MAAMC,UAAUC,UACrBF,MAAMC,UAAUC,QAAU,SAASC,GAClC,YACA,IAAa,SAATC,MAA4B,OAATA,MAAgC,kBAARD,GAAoB,KAAM,IAAIE,UAO7E,KAAK,GAJJC,GAAIC,OAAOH,MACXI,EAAMF,EAAEG,SAAW,EACnBC,EAAUC,UAAUF,QAAU,EAAIE,UAAU,GAAK,OAEzCC,EAAI,EAAOJ,EAAJI,EAASA,IACpBA,IAAKN,IACRH,EAAIU,KAAKH,EAASJ,EAAEM,GAAIA,EAAGN,KAK1BQ,SAASb,UAAUc,OACtBD,SAASb,UAAUc,KAAO,SAASC,GACjC,GAAoB,kBAATZ,MAGT,KAAM,IAAIC,WAAU,uEAGtB,IAAIY,GAAUjB,MAAMC,UAAUiB,MAAML,KAAKF,UAAW,GAChDQ,EAAUf,KACVgB,EAAU,aACVC,EAAU,WACR,MAAOF,GAAQG,MAAMlB,eAAgBgB,GAAOhB,KAAOY,EAC5CC,EAAMM,OAAOvB,MAAMC,UAAUiB,MAAML,KAAKF,aAMrD,OAHAS,GAAKnB,UAAYG,KAAKH,UACtBoB,EAAOpB,UAAY,GAAImB,GAEhBC,IAINrB,MAAMC,UAAUC,UACnBF,MAAMC,UAAUC,QAAU,SAASsB,EAAUd,GAC3C,GAAa,OAATN,KAAe,KAAM,IAAIC,WAAU,+BACvC,IAAwB,kBAAbmB,GAAyB,KAAM,IAAInB,WAAUmB,EAAW,qBAMnE,KAAK,GAHHC,GAAIlB,OAAOH,MACXI,EAAMiB,EAAEhB,SAAW,EAEZiB,EAAE,EAAQlB,EAAJkB,EAAUA,IACnBA,IAAKD,IACPD,EAASX,KAAKH,EAASe,EAAEC,GAAIA,EAAGD","sourcesContent":["/*\n * IE8 Polyfils for iframeResizer.js\n *\n * Public domain code - Mozilla Contributors\n * https://developer.mozilla.org/\n */\n\n if (!Array.prototype.forEach){\n\tArray.prototype.forEach = function(fun /*, thisArg */){\n\t\t\"use strict\";\n\t\tif (this === void 0 || this === null || typeof fun !== \"function\") throw new TypeError();\n\n\t\tvar\n\t\t\tt = Object(this),\n\t\t\tlen = t.length >>> 0,\n\t\t\tthisArg = arguments.length >= 2 ? arguments[1] : void 0;\n\n\t\tfor (var i = 0; i < len; i++)\n\t\t\tif (i in t)\n\t\t\t\tfun.call(thisArg, t[i], i, t);\n\t};\n}\n\n\nif (!Function.prototype.bind) {\n Function.prototype.bind = function(oThis) {\n if (typeof this !== 'function') {\n // closest thing possible to the ECMAScript 5\n // internal IsCallable function\n throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');\n }\n\n var aArgs = Array.prototype.slice.call(arguments, 1),\n fToBind = this,\n fNOP = function() {},\n fBound = function() {\n return fToBind.apply(this instanceof fNOP ? this : oThis,\n aArgs.concat(Array.prototype.slice.call(arguments)));\n };\n\n fNOP.prototype = this.prototype;\n fBound.prototype = new fNOP();\n\n return fBound;\n };\n}\n\nif (!Array.prototype.forEach) {\n Array.prototype.forEach = function(callback, thisArg) {\n if (this === null) throw new TypeError(' this is null or not defined');\n if (typeof callback !== 'function') throw new TypeError(callback + ' is not a function');\n\n var\n O = Object(this),\n len = O.length >>> 0;\n\n for (var k=0 ; k < len ; k++) {\n if (k in O)\n callback.call(thisArg, O[k], k, O);\n }\n };\n}\n\n\n"]} \ No newline at end of file diff --git a/js/ie8.polyfils.min.js b/js/ie8.polyfils.min.js new file mode 100644 index 0000000..5836bac --- /dev/null +++ b/js/ie8.polyfils.min.js @@ -0,0 +1,4 @@ +// IE8 polyfils for iframeResizer.js + +Array.prototype.forEach||(Array.prototype.forEach=function(a){"use strict";if(void 0===this||null===this||"function"!=typeof a)throw new TypeError;for(var b=Object(this),c=b.length>>>0,d=arguments.length>=2?arguments[1]:void 0,e=0;c>e;e++)e in b&&a.call(d,b[e],e,b)}),Function.prototype.bind||(Function.prototype.bind=function(a){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var b=Array.prototype.slice.call(arguments,1),c=this,d=function(){},e=function(){return c.apply(this instanceof d?this:a,b.concat(Array.prototype.slice.call(arguments)))};return d.prototype=this.prototype,e.prototype=new d,e}),Array.prototype.forEach||(Array.prototype.forEach=function(a,b){if(null===this)throw new TypeError(" this is null or not defined");if("function"!=typeof a)throw new TypeError(a+" is not a function");for(var c=Object(this),d=c.length>>>0,e=0;d>e;e++)e in c&&a.call(b,c[e],e,c)}); +//# sourceMappingURL=ie8.polyfils.map \ No newline at end of file diff --git a/js/iframeResizer.contentWindow.js b/js/iframeResizer.contentWindow.js new file mode 100644 index 0000000..bfb4a41 --- /dev/null +++ b/js/iframeResizer.contentWindow.js @@ -0,0 +1,1108 @@ +/* + * File: iframeResizer.contentWindow.js + * Desc: Include this file in any page being loaded into an iframe + * to force the iframe to resize to the content size. + * Requires: iframeResizer.js on host page. + * Doc: https://github.com/davidjbradshaw/iframe-resizer + * Author: David J. Bradshaw - dave@bradshaw.net + * Contributor: Jure Mav - jure.mav@gmail.com + * Contributor: Ian Caunce - ian@hallnet.co.uk + */ + + +;(function(window, undefined) { + 'use strict'; + + var + autoResize = true, + base = 10, + bodyBackground = '', + bodyMargin = 0, + bodyMarginStr = '', + bodyObserver = null, + bodyPadding = '', + calculateWidth = false, + doubleEventList = {'resize':1,'click':1}, + eventCancelTimer = 128, + firstRun = true, + height = 1, + heightCalcModeDefault = 'bodyOffset', + heightCalcMode = heightCalcModeDefault, + initLock = true, + initMsg = '', + inPageLinks = {}, + interval = 32, + intervalTimer = null, + logging = false, + msgID = '[iFrameSizer]', //Must match host page msg ID + msgIdLen = msgID.length, + myID = '', + observer = null, + resetRequiredMethods = {max:1,min:1,bodyScroll:1,documentElementScroll:1}, + resizeFrom = 'child', + sendPermit = true, + target = window.parent, + targetOriginDefault = '*', + tolerance = 0, + triggerLocked = false, + triggerLockedTimer = null, + throttledTimer = 16, + width = 1, + widthCalcModeDefault = 'scroll', + widthCalcMode = widthCalcModeDefault, + win = window, + messageCallback = function(){ warn('MessageCallback function not defined'); }, + readyCallback = function(){}, + pageInfoCallback = function(){}, + customCalcMethods = { + height: function(){ + warn('Custom height calculation function not defined'); + return document.documentElement.offsetHeight; + }, + width: function(){ + warn('Custom width calculation function not defined'); + return document.body.scrollWidth; + } + }; + + + function addEventListener(el,evt,func){ + /* istanbul ignore else */ // Not testable in phantonJS + if ('addEventListener' in window){ + el.addEventListener(evt,func, false); + } else if ('attachEvent' in window){ //IE + el.attachEvent('on'+evt,func); + } + } + + function removeEventListener(el,evt,func){ + /* istanbul ignore else */ // Not testable in phantonJS + if ('removeEventListener' in window){ + el.removeEventListener(evt,func, false); + } else if ('detachEvent' in window){ //IE + el.detachEvent('on'+evt,func); + } + } + + function capitalizeFirstLetter(string) { + return string.charAt(0).toUpperCase() + string.slice(1); + } + + //Based on underscore.js + function throttle(func) { + var + context, args, result, + timeout = null, + previous = 0, + later = function() { + previous = getNow(); + timeout = null; + result = func.apply(context, args); + if (!timeout) { + context = args = null; + } + }; + + return function() { + var now = getNow(); + + if (!previous) { + previous = now; + } + + var remaining = throttledTimer - (now - previous); + + context = this; + args = arguments; + + if (remaining <= 0 || remaining > throttledTimer) { + if (timeout) { + clearTimeout(timeout); + timeout = null; + } + + previous = now; + result = func.apply(context, args); + + if (!timeout) { + context = args = null; + } + + } else if (!timeout) { + timeout = setTimeout(later, remaining); + } + + return result; + }; + } + + var getNow = Date.now || function() { + /* istanbul ignore next */ // Not testable in PhantonJS + return new Date().getTime(); + }; + + function formatLogMsg(msg){ + return msgID + '[' + myID + ']' + ' ' + msg; + } + + function log(msg){ + if (logging && ('object' === typeof window.console)){ + console.log(formatLogMsg(msg)); + } + } + + function warn(msg){ + if ('object' === typeof window.console){ + console.warn(formatLogMsg(msg)); + } + } + + + function init(){ + readDataFromParent(); + log('Initialising iFrame ('+location.href+')'); + readDataFromPage(); + setMargin(); + setBodyStyle('background',bodyBackground); + setBodyStyle('padding',bodyPadding); + injectClearFixIntoBodyElement(); + checkHeightMode(); + checkWidthMode(); + stopInfiniteResizingOfIFrame(); + setupPublicMethods(); + startEventListeners(); + inPageLinks = setupInPageLinks(); + sendSize('init','Init message from host page'); + readyCallback(); + } + + function readDataFromParent(){ + + function strBool(str){ + return 'true' === str ? true : false; + } + + var data = initMsg.substr(msgIdLen).split(':'); + + myID = data[0]; + bodyMargin = (undefined !== data[1]) ? Number(data[1]) : bodyMargin; //For V1 compatibility + calculateWidth = (undefined !== data[2]) ? strBool(data[2]) : calculateWidth; + logging = (undefined !== data[3]) ? strBool(data[3]) : logging; + interval = (undefined !== data[4]) ? Number(data[4]) : interval; + autoResize = (undefined !== data[6]) ? strBool(data[6]) : autoResize; + bodyMarginStr = data[7]; + heightCalcMode = (undefined !== data[8]) ? data[8] : heightCalcMode; + bodyBackground = data[9]; + bodyPadding = data[10]; + tolerance = (undefined !== data[11]) ? Number(data[11]) : tolerance; + inPageLinks.enable = (undefined !== data[12]) ? strBool(data[12]): false; + resizeFrom = (undefined !== data[13]) ? data[13] : resizeFrom; + widthCalcMode = (undefined !== data[14]) ? data[14] : widthCalcMode; + } + + function readDataFromPage(){ + function readData(){ + var data = window.iFrameResizer; + + log('Reading data from page: ' + JSON.stringify(data)); + + messageCallback = ('messageCallback' in data) ? data.messageCallback : messageCallback; + readyCallback = ('readyCallback' in data) ? data.readyCallback : readyCallback; + targetOriginDefault = ('targetOrigin' in data) ? data.targetOrigin : targetOriginDefault; + heightCalcMode = ('heightCalculationMethod' in data) ? data.heightCalculationMethod : heightCalcMode; + widthCalcMode = ('widthCalculationMethod' in data) ? data.widthCalculationMethod : widthCalcMode; + } + + function setupCustomCalcMethods(calcMode, calcFunc){ + if ('function' === typeof calcMode) { + log('Setup custom ' + calcFunc + 'CalcMethod'); + customCalcMethods[calcFunc] = calcMode; + calcMode = 'custom'; + } + + return calcMode; + } + + if(('iFrameResizer' in window) && (Object === window.iFrameResizer.constructor)) { + readData(); + heightCalcMode = setupCustomCalcMethods(heightCalcMode, 'height'); + widthCalcMode = setupCustomCalcMethods(widthCalcMode, 'width'); + } + + log('TargetOrigin for parent set to: ' + targetOriginDefault); + } + + + function chkCSS(attr,value){ + if (-1 !== value.indexOf('-')){ + warn('Negative CSS value ignored for '+attr); + value=''; + } + return value; + } + + function setBodyStyle(attr,value){ + if ((undefined !== value) && ('' !== value) && ('null' !== value)){ + document.body.style[attr] = value; + log('Body '+attr+' set to "'+value+'"'); + } + } + + function setMargin(){ + //If called via V1 script, convert bodyMargin from int to str + if (undefined === bodyMarginStr){ + bodyMarginStr = bodyMargin+'px'; + } + + setBodyStyle('margin',chkCSS('margin',bodyMarginStr)); + } + + function stopInfiniteResizingOfIFrame(){ + document.documentElement.style.height = ''; + document.body.style.height = ''; + log('HTML & body height set to "auto"'); + } + + + function manageTriggerEvent(options){ + function handleEvent(){ + sendSize(options.eventName,options.eventType); + } + + var listener = { + add: function(eventName){ + addEventListener(window,eventName,handleEvent); + }, + remove: function(eventName){ + removeEventListener(window,eventName,handleEvent); + } + }; + + if(options.eventNames && Array.prototype.map){ + options.eventName = options.eventNames[0]; + options.eventNames.map(listener[options.method]); + } else { + listener[options.method](options.eventName); + } + + log(capitalizeFirstLetter(options.method) + ' event listener: ' + options.eventType); + } + + function manageEventListeners(method){ + manageTriggerEvent({method:method, eventType: 'Animation Start', eventNames: ['animationstart','webkitAnimationStart'] }); + manageTriggerEvent({method:method, eventType: 'Animation Iteration', eventNames: ['animationiteration','webkitAnimationIteration'] }); + manageTriggerEvent({method:method, eventType: 'Animation End', eventNames: ['animationend','webkitAnimationEnd'] }); + manageTriggerEvent({method:method, eventType: 'Input', eventName: 'input' }); + manageTriggerEvent({method:method, eventType: 'Mouse Up', eventName: 'mouseup' }); + manageTriggerEvent({method:method, eventType: 'Mouse Down', eventName: 'mousedown' }); + manageTriggerEvent({method:method, eventType: 'Orientation Change', eventName: 'orientationchange' }); + manageTriggerEvent({method:method, eventType: 'Print', eventName: ['afterprint', 'beforeprint'] }); + manageTriggerEvent({method:method, eventType: 'Ready State Change', eventName: 'readystatechange' }); + manageTriggerEvent({method:method, eventType: 'Touch Start', eventName: 'touchstart' }); + manageTriggerEvent({method:method, eventType: 'Touch End', eventName: 'touchend' }); + manageTriggerEvent({method:method, eventType: 'Touch Cancel', eventName: 'touchcancel' }); + manageTriggerEvent({method:method, eventType: 'Transition Start', eventNames: ['transitionstart','webkitTransitionStart','MSTransitionStart','oTransitionStart','otransitionstart'] }); + manageTriggerEvent({method:method, eventType: 'Transition Iteration', eventNames: ['transitioniteration','webkitTransitionIteration','MSTransitionIteration','oTransitionIteration','otransitioniteration'] }); + manageTriggerEvent({method:method, eventType: 'Transition End', eventNames: ['transitionend','webkitTransitionEnd','MSTransitionEnd','oTransitionEnd','otransitionend'] }); + if('child' === resizeFrom){ + manageTriggerEvent({method:method, eventType: 'IFrame Resized', eventName: 'resize' }); + } + } + + function checkCalcMode(calcMode,calcModeDefault,modes,type){ + if (calcModeDefault !== calcMode){ + if (!(calcMode in modes)){ + warn(calcMode + ' is not a valid option for '+type+'CalculationMethod.'); + calcMode=calcModeDefault; + } + log(type+' calculation method set to "'+calcMode+'"'); + } + + return calcMode; + } + + function checkHeightMode(){ + heightCalcMode = checkCalcMode(heightCalcMode,heightCalcModeDefault,getHeight,'height'); + } + + function checkWidthMode(){ + widthCalcMode = checkCalcMode(widthCalcMode,widthCalcModeDefault,getWidth,'width'); + } + + function startEventListeners(){ + if ( true === autoResize ) { + manageEventListeners('add'); + setupMutationObserver(); + } + else { + log('Auto Resize disabled'); + } + } + + function stopMsgsToParent(){ + log('Disable outgoing messages'); + sendPermit = false; + } + + function removeMsgListener(){ + log('Remove event listener: Message'); + removeEventListener(window, 'message', receiver); + } + + function disconnectMutationObserver(){ + if (null !== bodyObserver){ + /* istanbul ignore next */ // Not testable in PhantonJS + bodyObserver.disconnect(); + } + } + + function stopEventListeners(){ + manageEventListeners('remove'); + disconnectMutationObserver(); + clearInterval(intervalTimer); + } + + function teardown(){ + stopMsgsToParent(); + removeMsgListener(); + if (true === autoResize) stopEventListeners(); + } + + function injectClearFixIntoBodyElement(){ + var clearFix = document.createElement('div'); + clearFix.style.clear = 'both'; + clearFix.style.display = 'block'; //Guard against this having been globally redefined in CSS. + document.body.appendChild(clearFix); + } + + function setupInPageLinks(){ + + function getPagePosition (){ + return { + x: (window.pageXOffset !== undefined) ? window.pageXOffset : document.documentElement.scrollLeft, + y: (window.pageYOffset !== undefined) ? window.pageYOffset : document.documentElement.scrollTop + }; + } + + function getElementPosition(el){ + var + elPosition = el.getBoundingClientRect(), + pagePosition = getPagePosition(); + + return { + x: parseInt(elPosition.left,10) + parseInt(pagePosition.x,10), + y: parseInt(elPosition.top,10) + parseInt(pagePosition.y,10) + }; + } + + function findTarget(location){ + function jumpToTarget(target){ + var jumpPosition = getElementPosition(target); + + log('Moving to in page link (#'+hash+') at x: '+jumpPosition.x+' y: '+jumpPosition.y); + sendMsg(jumpPosition.y, jumpPosition.x, 'scrollToOffset'); // X&Y reversed at sendMsg uses height/width + } + + var + hash = location.split('#')[1] || location, //Remove # if present + hashData = decodeURIComponent(hash), + target = document.getElementById(hashData) || document.getElementsByName(hashData)[0]; + + if (undefined !== target){ + jumpToTarget(target); + } else { + log('In page link (#' + hash + ') not found in iFrame, so sending to parent'); + sendMsg(0,0,'inPageLink','#'+hash); + } + } + + function checkLocationHash(){ + if ('' !== location.hash && '#' !== location.hash){ + findTarget(location.href); + } + } + + function bindAnchors(){ + function setupLink(el){ + function linkClicked(e){ + e.preventDefault(); + + /*jshint validthis:true */ + findTarget(this.getAttribute('href')); + } + + if ('#' !== el.getAttribute('href')){ + addEventListener(el,'click',linkClicked); + } + } + + Array.prototype.forEach.call( document.querySelectorAll( 'a[href^="#"]' ), setupLink ); + } + + function bindLocationHash(){ + addEventListener(window,'hashchange',checkLocationHash); + } + + function initCheck(){ //check if page loaded with location hash after init resize + setTimeout(checkLocationHash,eventCancelTimer); + } + + function enableInPageLinks(){ + /* istanbul ignore else */ // Not testable in phantonJS + if(Array.prototype.forEach && document.querySelectorAll){ + log('Setting up location.hash handlers'); + bindAnchors(); + bindLocationHash(); + initCheck(); + } else { + warn('In page linking not fully supported in this browser! (See README.md for IE8 workaround)'); + } + } + + if(inPageLinks.enable){ + enableInPageLinks(); + } else { + log('In page linking not enabled'); + } + + return { + findTarget:findTarget + }; + } + + function setupPublicMethods(){ + log('Enable public methods'); + + win.parentIFrame = { + + autoResize: function autoResizeF(resize){ + if (true === resize && false === autoResize) { + autoResize=true; + startEventListeners(); + //sendSize('autoResize','Auto Resize enabled'); + } else if (false === resize && true === autoResize) { + autoResize=false; + stopEventListeners(); + } + + return autoResize; + }, + + close: function closeF(){ + sendMsg(0,0,'close'); + teardown(); + }, + + getId: function getIdF(){ + return myID; + }, + + getPageInfo: function getPageInfoF(callback){ + if ('function' === typeof callback){ + pageInfoCallback = callback; + sendMsg(0,0,'pageInfo'); + } else { + pageInfoCallback = function(){}; + sendMsg(0,0,'pageInfoStop'); + } + }, + + moveToAnchor: function moveToAnchorF(hash){ + inPageLinks.findTarget(hash); + }, + + reset: function resetF(){ + resetIFrame('parentIFrame.reset'); + }, + + scrollTo: function scrollToF(x,y){ + sendMsg(y,x,'scrollTo'); // X&Y reversed at sendMsg uses height/width + }, + + scrollToOffset: function scrollToF(x,y){ + sendMsg(y,x,'scrollToOffset'); // X&Y reversed at sendMsg uses height/width + }, + + sendMessage: function sendMessageF(msg,targetOrigin){ + sendMsg(0,0,'message',JSON.stringify(msg),targetOrigin); + }, + + setHeightCalculationMethod: function setHeightCalculationMethodF(heightCalculationMethod){ + heightCalcMode = heightCalculationMethod; + checkHeightMode(); + }, + + setWidthCalculationMethod: function setWidthCalculationMethodF(widthCalculationMethod){ + widthCalcMode = widthCalculationMethod; + checkWidthMode(); + }, + + setTargetOrigin: function setTargetOriginF(targetOrigin){ + log('Set targetOrigin: '+targetOrigin); + targetOriginDefault = targetOrigin; + }, + + size: function sizeF(customHeight, customWidth){ + var valString = ''+(customHeight?customHeight:'')+(customWidth?','+customWidth:''); + //lockTrigger(); + sendSize('size','parentIFrame.size('+valString+')', customHeight, customWidth); + } + }; + } + + function initInterval(){ + if ( 0 !== interval ){ + log('setInterval: '+interval+'ms'); + intervalTimer = setInterval(function(){ + sendSize('interval','setInterval: '+interval); + },Math.abs(interval)); + } + } + + /* istanbul ignore next */ //Not testable in PhantomJS + function setupBodyMutationObserver(){ + function addImageLoadListners(mutation) { + function addImageLoadListener(element){ + if (false === element.complete) { + log('Attach listeners to ' + element.src); + element.addEventListener('load', imageLoaded, false); + element.addEventListener('error', imageError, false); + elements.push(element); + } + } + + if (mutation.type === 'attributes' && mutation.attributeName === 'src'){ + addImageLoadListener(mutation.target); + } else if (mutation.type === 'childList'){ + Array.prototype.forEach.call( + mutation.target.querySelectorAll('img'), + addImageLoadListener + ); + } + } + + function removeFromArray(element){ + elements.splice(elements.indexOf(element),1); + } + + function removeImageLoadListener(element){ + log('Remove listeners from ' + element.src); + element.removeEventListener('load', imageLoaded, false); + element.removeEventListener('error', imageError, false); + removeFromArray(element); + } + + function imageEventTriggered(event,type,typeDesc){ + removeImageLoadListener(event.target); + sendSize(type, typeDesc + ': ' + event.target.src, undefined, undefined); + } + + function imageLoaded(event) { + imageEventTriggered(event,'imageLoad','Image loaded'); + } + + function imageError(event) { + imageEventTriggered(event,'imageLoadFailed','Image load failed'); + } + + function mutationObserved(mutations) { + sendSize('mutationObserver','mutationObserver: ' + mutations[0].target + ' ' + mutations[0].type); + + //Deal with WebKit asyncing image loading when tags are injected into the page + mutations.forEach(addImageLoadListners); + } + + function createMutationObserver(){ + var + target = document.querySelector('body'), + + config = { + attributes : true, + attributeOldValue : false, + characterData : true, + characterDataOldValue : false, + childList : true, + subtree : true + }; + + observer = new MutationObserver(mutationObserved); + + log('Create body MutationObserver'); + observer.observe(target, config); + + return observer; + } + + var + elements = [], + MutationObserver = window.MutationObserver || window.WebKitMutationObserver, + observer = createMutationObserver(); + + return { + disconnect: function (){ + if ('disconnect' in observer){ + log('Disconnect body MutationObserver'); + observer.disconnect(); + elements.forEach(removeImageLoadListener); + } + } + }; + } + + function setupMutationObserver(){ + var forceIntervalTimer = 0 > interval; + + /* istanbul ignore if */ // Not testable in PhantomJS + if (window.MutationObserver || window.WebKitMutationObserver){ + if (forceIntervalTimer) { + initInterval(); + } else { + bodyObserver = setupBodyMutationObserver(); + } + } else { + log('MutationObserver not supported in this browser!'); + initInterval(); + } + } + + + // document.documentElement.offsetHeight is not reliable, so + // we have to jump through hoops to get a better value. + function getComputedStyle(prop,el) { + /* istanbul ignore next */ //Not testable in PhantomJS + function convertUnitsToPxForIE8(value) { + var PIXEL = /^\d+(px)?$/i; + + if (PIXEL.test(value)) { + return parseInt(value,base); + } + + var + style = el.style.left, + runtimeStyle = el.runtimeStyle.left; + + el.runtimeStyle.left = el.currentStyle.left; + el.style.left = value || 0; + value = el.style.pixelLeft; + el.style.left = style; + el.runtimeStyle.left = runtimeStyle; + + return value; + } + + var retVal = 0; + el = el || document.body; + + /* istanbul ignore else */ // Not testable in phantonJS + if (('defaultView' in document) && ('getComputedStyle' in document.defaultView)) { + retVal = document.defaultView.getComputedStyle(el, null); + retVal = (null !== retVal) ? retVal[prop] : 0; + } else {//IE8 + retVal = convertUnitsToPxForIE8(el.currentStyle[prop]); + } + + return parseInt(retVal,base); + } + + function chkEventThottle(timer){ + if(timer > throttledTimer/2){ + throttledTimer = 2*timer; + log('Event throttle increased to ' + throttledTimer + 'ms'); + } + } + + //Idea from https://github.com/guardian/iframe-messenger + function getMaxElement(side,elements) { + var + elementsLength = elements.length, + elVal = 0, + maxVal = 0, + Side = capitalizeFirstLetter(side), + timer = getNow(); + + for (var i = 0; i < elementsLength; i++) { + elVal = elements[i].getBoundingClientRect()[side] + getComputedStyle('margin'+Side,elements[i]); + if (elVal > maxVal) { + maxVal = elVal; + } + } + + timer = getNow() - timer; + + log('Parsed '+elementsLength+' HTML elements'); + log('Element position calculated in ' + timer + 'ms'); + + chkEventThottle(timer); + + return maxVal; + } + + function getAllMeasurements(dimention){ + return [ + dimention.bodyOffset(), + dimention.bodyScroll(), + dimention.documentElementOffset(), + dimention.documentElementScroll() + ]; + } + + function getTaggedElements(side,tag){ + function noTaggedElementsFound(){ + warn('No tagged elements ('+tag+') found on page'); + return height; //current height + } + + var elements = document.querySelectorAll('['+tag+']'); + + return 0 === elements.length ? noTaggedElementsFound() : getMaxElement(side,elements); + } + + function getAllElements(){ + return document.querySelectorAll('body *'); + } + + var + getHeight = { + bodyOffset: function getBodyOffsetHeight(){ + return document.body.offsetHeight + getComputedStyle('marginTop') + getComputedStyle('marginBottom'); + }, + + offset: function(){ + return getHeight.bodyOffset(); //Backwards compatability + }, + + bodyScroll: function getBodyScrollHeight(){ + return document.body.scrollHeight; + }, + + custom: function getCustomWidth(){ + return customCalcMethods.height(); + }, + + documentElementOffset: function getDEOffsetHeight(){ + return document.documentElement.offsetHeight; + }, + + documentElementScroll: function getDEScrollHeight(){ + return document.documentElement.scrollHeight; + }, + + max: function getMaxHeight(){ + return Math.max.apply(null,getAllMeasurements(getHeight)); + }, + + min: function getMinHeight(){ + return Math.min.apply(null,getAllMeasurements(getHeight)); + }, + + grow: function growHeight(){ + return getHeight.max(); //Run max without the forced downsizing + }, + + lowestElement: function getBestHeight(){ + return Math.max(getHeight.bodyOffset(), getMaxElement('bottom',getAllElements())); + }, + + taggedElement: function getTaggedElementsHeight(){ + return getTaggedElements('bottom','data-iframe-height'); + } + }, + + getWidth = { + bodyScroll: function getBodyScrollWidth(){ + return document.body.scrollWidth; + }, + + bodyOffset: function getBodyOffsetWidth(){ + return document.body.offsetWidth; + }, + + custom: function getCustomWidth(){ + return customCalcMethods.width(); + }, + + documentElementScroll: function getDEScrollWidth(){ + return document.documentElement.scrollWidth; + }, + + documentElementOffset: function getDEOffsetWidth(){ + return document.documentElement.offsetWidth; + }, + + scroll: function getMaxWidth(){ + return Math.max(getWidth.bodyScroll(), getWidth.documentElementScroll()); + }, + + max: function getMaxWidth(){ + return Math.max.apply(null,getAllMeasurements(getWidth)); + }, + + min: function getMinWidth(){ + return Math.min.apply(null,getAllMeasurements(getWidth)); + }, + + rightMostElement: function rightMostElement(){ + return getMaxElement('right', getAllElements()); + }, + + taggedElement: function getTaggedElementsWidth(){ + return getTaggedElements('right', 'data-iframe-width'); + } + }; + + + function sizeIFrame(triggerEvent, triggerEventDesc, customHeight, customWidth){ + + function resizeIFrame(){ + height = currentHeight; + width = currentWidth; + + sendMsg(height,width,triggerEvent); + } + + function isSizeChangeDetected(){ + function checkTolarance(a,b){ + var retVal = Math.abs(a-b) <= tolerance; + return !retVal; + } + + currentHeight = (undefined !== customHeight) ? customHeight : getHeight[heightCalcMode](); + currentWidth = (undefined !== customWidth ) ? customWidth : getWidth[widthCalcMode](); + + return checkTolarance(height,currentHeight) || (calculateWidth && checkTolarance(width,currentWidth)); + } + + function isForceResizableEvent(){ + return !(triggerEvent in {'init':1,'interval':1,'size':1}); + } + + function isForceResizableCalcMode(){ + return (heightCalcMode in resetRequiredMethods) || (calculateWidth && widthCalcMode in resetRequiredMethods); + } + + function logIgnored(){ + log('No change in size detected'); + } + + function checkDownSizing(){ + if (isForceResizableEvent() && isForceResizableCalcMode()){ + resetIFrame(triggerEventDesc); + } else if (!(triggerEvent in {'interval':1})){ + logIgnored(); + } + } + + var currentHeight,currentWidth; + + if (isSizeChangeDetected() || 'init' === triggerEvent){ + lockTrigger(); + resizeIFrame(); + } else { + checkDownSizing(); + } + } + + var sizeIFrameThrottled = throttle(sizeIFrame); + + function sendSize(triggerEvent, triggerEventDesc, customHeight, customWidth){ + function recordTrigger(){ + if (!(triggerEvent in {'reset':1,'resetPage':1,'init':1})){ + log( 'Trigger event: ' + triggerEventDesc ); + } + } + + function isDoubleFiredEvent(){ + return triggerLocked && (triggerEvent in doubleEventList); + } + + if (!isDoubleFiredEvent()){ + recordTrigger(); + sizeIFrameThrottled(triggerEvent, triggerEventDesc, customHeight, customWidth); + } else { + log('Trigger event cancelled: '+triggerEvent); + } + } + + function lockTrigger(){ + if (!triggerLocked){ + triggerLocked = true; + log('Trigger event lock on'); + } + clearTimeout(triggerLockedTimer); + triggerLockedTimer = setTimeout(function(){ + triggerLocked = false; + log('Trigger event lock off'); + log('--'); + },eventCancelTimer); + } + + function triggerReset(triggerEvent){ + height = getHeight[heightCalcMode](); + width = getWidth[widthCalcMode](); + + sendMsg(height,width,triggerEvent); + } + + function resetIFrame(triggerEventDesc){ + var hcm = heightCalcMode; + heightCalcMode = heightCalcModeDefault; + + log('Reset trigger event: ' + triggerEventDesc); + lockTrigger(); + triggerReset('reset'); + + heightCalcMode = hcm; + } + + function sendMsg(height,width,triggerEvent,msg,targetOrigin){ + function setTargetOrigin(){ + if (undefined === targetOrigin){ + targetOrigin = targetOriginDefault; + } else { + log('Message targetOrigin: '+targetOrigin); + } + } + + function sendToParent(){ + var + size = height + ':' + width, + message = myID + ':' + size + ':' + triggerEvent + (undefined !== msg ? ':' + msg : ''); + + log('Sending message to host page (' + message + ')'); + target.postMessage( msgID + message, targetOrigin); + } + + if(true === sendPermit){ + setTargetOrigin(); + sendToParent(); + } + } + + function receiver(event) { + function isMessageForUs(){ + return msgID === (''+event.data).substr(0,msgIdLen); //''+ Protects against non-string messages + } + + function initFromParent(){ + function fireInit(){ + initMsg = event.data; + target = event.source; + + init(); + firstRun = false; + setTimeout(function(){ initLock = false;},eventCancelTimer); + } + + if (document.body){ + fireInit(); + } else { + log('Waiting for page ready'); + addEventListener(window,'readystatechange',initFromParent); + } + } + + function resetFromParent(){ + if (!initLock){ + log('Page size reset by host page'); + triggerReset('resetPage'); + } else { + log('Page reset ignored by init'); + } + } + + function resizeFromParent(){ + sendSize('resizeParent','Parent window requested size check'); + } + + function moveToAnchor(){ + var anchor = getData(); + inPageLinks.findTarget(anchor); + } + + function getMessageType(){ + return event.data.split(']')[1].split(':')[0]; + } + + function getData(){ + return event.data.substr(event.data.indexOf(':')+1); + } + + function isMiddleTier(){ + return ('iFrameResize' in window); + } + + function messageFromParent(){ + var msgBody = getData(); + + log('MessageCallback called from parent: ' + msgBody ); + messageCallback(JSON.parse(msgBody)); + log(' --'); + } + + function pageInfoFromParent(){ + var msgBody = getData(); + log('PageInfoFromParent called from parent: ' + msgBody ); + pageInfoCallback(JSON.parse(msgBody)); + log(' --'); + } + + function isInitMsg(){ + //Test if this message is from a child below us. This is an ugly test, however, updating + //the message format would break backwards compatibity. + return event.data.split(':')[2] in {'true':1,'false':1}; + } + + function callFromParent(){ + switch (getMessageType()){ + case 'reset': + resetFromParent(); + break; + case 'resize': + resizeFromParent(); + break; + case 'inPageLink': + case 'moveToAnchor': + moveToAnchor(); + break; + case 'message': + messageFromParent(); + break; + case 'pageInfo': + pageInfoFromParent(); + break; + default: + if (!isMiddleTier() && !isInitMsg()){ + warn('Unexpected message ('+event.data+')'); + } + } + } + + function processMessage(){ + if (false === firstRun) { + callFromParent(); + } else if (isInitMsg()) { + initFromParent(); + } else { + log('Ignored message of type "' + getMessageType() + '". Received before initialization.'); + } + } + + if (isMessageForUs()){ + processMessage(); + } + } + + //Normally the parent kicks things off when it detects the iFrame has loaded. + //If this script is async-loaded, then tell parent page to retry init. + function chkLateLoaded(){ + if('loading' !== document.readyState){ + window.parent.postMessage('[iFrameResizerChild]Ready','*'); + } + } + + addEventListener(window, 'message', receiver); + chkLateLoaded(); + + + +})(window || {}); diff --git a/js/iframeResizer.contentWindow.map b/js/iframeResizer.contentWindow.map new file mode 100644 index 0000000..ab9fe2d --- /dev/null +++ b/js/iframeResizer.contentWindow.map @@ -0,0 +1 @@ +{"version":3,"file":"iframeResizer.contentWindow.min.js","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","handleEvent","eventName","eventType","listener","add","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","initFromParent","fireInit","source","firstRun","initLock","resetFromParent","resizeFromParent","anchor","getData","getMessageType","isMiddleTier","messageFromParent","msgBody","parse","pageInfoFromParent","isInitMsg","true","false","callFromParent","processMessage","chkLateLoaded","readyState","parent","click","max","min","offsetHeight","scrollWidth","Date","getTime","offset","scrollHeight","custom","grow","lowestElement","taggedElement","offsetWidth","scroll","rightMostElement"],"mappings":";;;;;;;;CAYC,SAAUA,EAAQC,GAClB,YAuDA,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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SAG1BV,sBAAuB,WACtB,MAAOvK,UAASG,gBAAgBkO,aAGjC/D,sBAAuB,WACtB,MAAOtK,UAASG,gBAAgB2O,aAGjCC,OAAQ,WACP,MAAOtI,MAAKyH,IAAIxM,GAAS2I,aAAc3I,GAAS6I,0BAGjD2D,IAAK,WACJ,MAAOzH,MAAKyH,IAAI1S,MAAM,KAAK0O,EAAmBxI,MAG/CyM,IAAK,WACJ,MAAO1H,MAAK0H,IAAI3S,MAAM,KAAK0O,EAAmBxI,MAG/CsN,iBAAkB,WACjB,MAAOtF,GAAc,QAASiB,MAG/BkE,cAAe,WACd,MAAOrE,GAAkB,QAAS,uBAwDjC0B,GAAsBlR,EAAS4P,EAsMnCxQ,GAAiBF,EAAQ,UAAW6H,GACpC+L,KAIE5T","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\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\t\tfunction handleEvent(){\n\t\t\tsendSize(options.eventName,options.eventType);\n\t\t}\n\n\t\tvar listener = {\n\t\t\tadd: function(eventName){\n\t\t\t\taddEventListener(window,eventName,handleEvent);\n\t\t\t},\n\t\t\tremove: function(eventName){\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 height; //current height\n\t\t}\n\n\t\tvar elements = document.querySelectorAll('['+tag+']');\n\n\t\treturn 0 === elements.length ? noTaggedElementsFound() : 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\tfunction isMessageForUs(){\n\t\t\treturn msgID === (''+event.data).substr(0,msgIdLen); //''+ Protects against non-string messages\n\t\t}\n\n\t\tfunction initFromParent(){\n\t\t\tfunction fireInit(){\n\t\t\t\tinitMsg = event.data;\n\t\t\t\ttarget = event.source;\n\n\t\t\t\tinit();\n\t\t\t\tfirstRun = false;\n\t\t\t\tsetTimeout(function(){ initLock = false;},eventCancelTimer);\n\t\t\t}\n\n\t\t\tif (document.body){\n\t\t\t\tfireInit();\n\t\t\t} else {\n\t\t\t\tlog('Waiting for page ready');\n\t\t\t\taddEventListener(window,'readystatechange',initFromParent);\n\t\t\t}\n\t\t}\n\n\t\tfunction resetFromParent(){\n\t\t\tif (!initLock){\n\t\t\t\tlog('Page size reset by host page');\n\t\t\t\ttriggerReset('resetPage');\n\t\t\t} else {\n\t\t\t\tlog('Page reset ignored by init');\n\t\t\t}\n\t\t}\n\n\t\tfunction resizeFromParent(){\n\t\t\tsendSize('resizeParent','Parent window requested size check');\n\t\t}\n\n\t\tfunction moveToAnchor(){\n\t\t\tvar anchor = getData();\n\t\t\tinPageLinks.findTarget(anchor);\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 messageFromParent(){\n\t\t\tvar msgBody = getData();\n\n\t\t\tlog('MessageCallback called from parent: ' + msgBody );\n\t\t\tmessageCallback(JSON.parse(msgBody));\n\t\t\tlog(' --');\n\t\t}\n\n\t\tfunction pageInfoFromParent(){\n\t\t\tvar msgBody = getData();\n\t\t\tlog('PageInfoFromParent called from parent: ' + msgBody );\n\t\t\tpageInfoCallback(JSON.parse(msgBody));\n\t\t\tlog(' --');\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\tswitch (getMessageType()){\n\t\t\tcase 'reset':\n\t\t\t\tresetFromParent();\n\t\t\t\tbreak;\n\t\t\tcase 'resize':\n\t\t\t\tresizeFromParent();\n\t\t\t\tbreak;\n\t\t\tcase 'inPageLink':\n\t\t\tcase 'moveToAnchor':\n\t\t\t\tmoveToAnchor();\n\t\t\t\tbreak;\n\t\t\tcase 'message':\n\t\t\t\tmessageFromParent();\n\t\t\t\tbreak;\n\t\t\tcase 'pageInfo':\n\t\t\t\tpageInfoFromParent();\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tif (!isMiddleTier() && !isInitMsg()){\n\t\t\t\t\twarn('Unexpected message ('+event.data+')');\n\t\t\t\t}\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\tinitFromParent();\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"]} \ No newline at end of file diff --git a/js/iframeResizer.contentWindow.min.js b/js/iframeResizer.contentWindow.min.js new file mode 100644 index 0000000..5cfd4e2 --- /dev/null +++ b/js/iframeResizer.contentWindow.min.js @@ -0,0 +1,10 @@ +/*! iFrame Resizer (iframeSizer.contentWindow.min.js) - v3.5.5 - 2016-06-16 + * Desc: Include this file in any page being loaded into an iframe + * to force the iframe to resize to the content size. + * Requires: iframeResizer.min.js on host page. + * Copyright: (c) 2016 David J. Bradshaw - dave@bradshaw.net + * License: MIT + */ + +!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=Ha(),e=null,d=a.apply(b,c),e||(b=c=null)};return function(){var h=Ha();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){function f(){O(b.eventName,b.eventType)}var g={add:function(b){c(a,b,f)},remove:function(b){d(a,b,f)}};b.eventNames&&Array.prototype.map?(b.eventName=b.eventNames[0],b.eventNames.map(g[b.method])):g[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,Ia,"height")}function u(){Ba=s(Ba,Aa,Ja,"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=Ha(),j=0;c>j;j++)d=b[j].getBoundingClientRect()[a]+H("margin"+g,b[j]),d>f&&(f=d);return i=Ha()-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"),ea}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:Ia[ga](),n=b!==e?e:Ja[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(),Ka(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=Ia[ga](),za=Ja[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(){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",e))}function f(){ha?h("Page reset ignored by init"):(h("Page size reset by host page"),Q("resetPage"))}function g(){O("resizeParent","Parent window requested size check")}function k(){var a=m();ja.findTarget(a)}function l(){return b.data.split("]")[1].split(":")[0]}function m(){return b.data.substr(b.data.indexOf(":")+1)}function n(){return"iFrameResize"in a}function o(){var a=m();h("MessageCallback called from parent: "+a),Da(JSON.parse(a)),h(" --")}function p(){var a=m();h("PageInfoFromParent called from parent: "+a),Fa(JSON.parse(a)),h(" --")}function q(){return b.data.split(":")[2]in{"true":1,"false":1}}function r(){switch(l()){case"reset":f();break;case"resize":g();break;case"inPageLink":case"moveToAnchor":k();break;case"message":o();break;case"pageInfo":p();break;default:n()||q()||i("Unexpected message ("+b.data+")")}}function s(){!1===da?r():q()?e():h('Ignored message of type "'+l()+'". Received before initialization.')}d()&&s()}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=Date.now||function(){return(new Date).getTime()},Ia={bodyOffset:function(){return document.body.offsetHeight+H("marginTop")+H("marginBottom")},offset:function(){return Ia.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(Ia))},min:function(){return Math.min.apply(null,K(Ia))},grow:function(){return Ia.max()},lowestElement:function(){return Math.max(Ia.bodyOffset(),J("bottom",M()))},taggedElement:function(){return L("bottom","data-iframe-height")}},Ja={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(Ja.bodyScroll(),Ja.documentElementScroll())},max:function(){return Math.max.apply(null,K(Ja))},min:function(){return Math.min.apply(null,K(Ja))},rightMostElement:function(){return J("right",M())},taggedElement:function(){return L("right","data-iframe-width")}},Ka=f(N);c(a,"message",T),U()}(window||{}); +//# sourceMappingURL=iframeResizer.contentWindow.map \ No newline at end of file diff --git a/js/iframeResizer.js b/js/iframeResizer.js new file mode 100644 index 0000000..897a632 --- /dev/null +++ b/js/iframeResizer.js @@ -0,0 +1,1002 @@ +/* + * File: iframeResizer.js + * Desc: Force iframes to size to content. + * Requires: iframeResizer.contentWindow.js to be loaded into the target frame. + * Doc: https://github.com/davidjbradshaw/iframe-resizer + * Author: David J. Bradshaw - dave@bradshaw.net + * Contributor: Jure Mav - jure.mav@gmail.com + * Contributor: Reed Dadoune - reed@dadoune.com + */ + + +;(function(window) { + 'use strict'; + + var + count = 0, + logEnabled = false, + hiddenCheckEnabled = false, + msgHeader = 'message', + msgHeaderLen = msgHeader.length, + msgId = '[iFrameSizer]', //Must match iframe msg ID + msgIdLen = msgId.length, + pagePosition = null, + requestAnimationFrame = window.requestAnimationFrame, + resetRequiredMethods = {max:1,scroll:1,bodyScroll:1,documentElementScroll:1}, + settings = {}, + timer = null, + logId = 'Host Page', + + defaults = { + autoResize : true, + bodyBackground : null, + bodyMargin : null, + bodyMarginV1 : 8, + bodyPadding : null, + checkOrigin : true, + inPageLinks : false, + enablePublicMethods : true, + heightCalculationMethod : 'bodyOffset', + id : 'iFrameResizer', + interval : 32, + log : false, + maxHeight : Infinity, + maxWidth : Infinity, + minHeight : 0, + minWidth : 0, + resizeFrom : 'parent', + scrolling : false, + sizeHeight : true, + sizeWidth : false, + tolerance : 0, + widthCalculationMethod : 'scroll', + closedCallback : function(){}, + initCallback : function(){}, + messageCallback : function(){warn('MessageCallback function not defined');}, + resizedCallback : function(){}, + scrollCallback : function(){return true;} + }; + + function addEventListener(obj,evt,func){ + /* istanbul ignore else */ // Not testable in PhantonJS + if ('addEventListener' in window){ + obj.addEventListener(evt,func, false); + } else if ('attachEvent' in window){//IE + obj.attachEvent('on'+evt,func); + } + } + + function removeEventListener(el,evt,func){ + /* istanbul ignore else */ // Not testable in phantonJS + if ('removeEventListener' in window){ + el.removeEventListener(evt,func, false); + } else if ('detachEvent' in window){ //IE + el.detachEvent('on'+evt,func); + } + } + + function setupRequestAnimationFrame(){ + var + vendors = ['moz', 'webkit', 'o', 'ms'], + x; + + // Remove vendor prefixing if prefixed and break early if not + for (x = 0; x < vendors.length && !requestAnimationFrame; x += 1) { + requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame']; + } + + if (!(requestAnimationFrame)){ + log('setup','RequestAnimationFrame not supported'); + } + } + + function getMyID(iframeId){ + var retStr = 'Host page: '+iframeId; + + if (window.top!==window.self){ + if (window.parentIFrame && window.parentIFrame.getId){ + retStr = window.parentIFrame.getId()+': '+iframeId; + } else { + retStr = 'Nested host page: '+iframeId; + } + } + + return retStr; + } + + function formatLogHeader(iframeId){ + return msgId + '[' + getMyID(iframeId) + ']'; + } + + function isLogEnabled(iframeId){ + return settings[iframeId] ? settings[iframeId].log : logEnabled; + } + + function log(iframeId,msg){ + output('log',iframeId,msg,isLogEnabled(iframeId)); + } + + function info(iframeId,msg){ + output('info',iframeId,msg,isLogEnabled(iframeId)); + } + + function warn(iframeId,msg){ + output('warn',iframeId,msg,true); + } + + function output(type,iframeId,msg,enabled){ + if (true === enabled && 'object' === typeof window.console){ + console[type](formatLogHeader(iframeId),msg); + } + } + + function iFrameListener(event){ + function resizeIFrame(){ + function resize(){ + setSize(messageData); + setPagePosition(iframeId); + } + + ensureInRange('Height'); + ensureInRange('Width'); + + syncResize(resize,messageData,'init'); + } + + function processMsg(){ + var data = msg.substr(msgIdLen).split(':'); + + return { + iframe: settings[data[0]].iframe, + id: data[0], + height: data[1], + width: data[2], + type: data[3] + }; + } + + function ensureInRange(Dimension){ + var + max = Number(settings[iframeId]['max' + Dimension]), + min = Number(settings[iframeId]['min' + Dimension]), + dimension = Dimension.toLowerCase(), + size = Number(messageData[dimension]); + + log(iframeId,'Checking ' + dimension + ' is in range ' + min + '-' + max); + + if (sizemax) { + size=max; + log(iframeId,'Set ' + dimension + ' to max value'); + } + + messageData[dimension] = '' + size; + } + + + function isMessageFromIFrame(){ + function checkAllowedOrigin(){ + function checkList(){ + var + i = 0, + retCode = false; + + log(iframeId,'Checking connection is from allowed list of origins: ' + checkOrigin); + + for (; i < checkOrigin.length; i++) { + if (checkOrigin[i] === origin) { + retCode = true; + break; + } + } + return retCode; + } + + function checkSingle(){ + var remoteHost = settings[iframeId].remoteHost; + log(iframeId,'Checking connection is from: '+remoteHost); + return origin === remoteHost; + } + + return checkOrigin.constructor === Array ? checkList() : checkSingle(); + } + + var + origin = event.origin, + checkOrigin = settings[iframeId].checkOrigin; + + if (checkOrigin && (''+origin !== 'null') && !checkAllowedOrigin()) { + throw new Error( + 'Unexpected message received from: ' + origin + + ' for ' + messageData.iframe.id + + '. Message was: ' + event.data + + '. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.' + ); + } + + return true; + } + + function isMessageForUs(){ + return msgId === (('' + msg).substr(0,msgIdLen)) && (msg.substr(msgIdLen).split(':')[0] in settings); //''+Protects against non-string msg + } + + function isMessageFromMetaParent(){ + //Test if this message is from a parent above us. This is an ugly test, however, updating + //the message format would break backwards compatibity. + var retCode = messageData.type in {'true':1,'false':1,'undefined':1}; + + if (retCode){ + log(iframeId,'Ignoring init message from meta parent page'); + } + + return retCode; + } + + function getMsgBody(offset){ + return msg.substr(msg.indexOf(':')+msgHeaderLen+offset); + } + + function forwardMsgFromIFrame(msgBody){ + log(iframeId,'MessageCallback passed: {iframe: '+ messageData.iframe.id + ', message: ' + msgBody + '}'); + callback('messageCallback',{ + iframe: messageData.iframe, + message: JSON.parse(msgBody) + }); + log(iframeId,'--'); + } + + function getPageInfo(){ + var + bodyPosition = document.body.getBoundingClientRect(), + iFramePosition = messageData.iframe.getBoundingClientRect(); + + return JSON.stringify({ + iframeHeight: iFramePosition.height, + iframeWidth: iFramePosition.width, + clientHeight: Math.max(document.documentElement.clientHeight, window.innerHeight || 0), + clientWidth: Math.max(document.documentElement.clientWidth, window.innerWidth || 0), + offsetTop: parseInt(iFramePosition.top - bodyPosition.top, 10), + offsetLeft: parseInt(iFramePosition.left - bodyPosition.left, 10), + scrollTop: window.pageYOffset, + scrollLeft: window.pageXOffset + }); + } + + function sendPageInfoToIframe(iframe,iframeId){ + function debouncedTrigger(){ + trigger( + 'Send Page Info', + 'pageInfo:' + getPageInfo(), + iframe, + iframeId + ); + } + + debouce(debouncedTrigger,32); + } + + + function startPageInfoMonitor(){ + function setListener(type,func){ + function sendPageInfo(){ + if (settings[id]){ + sendPageInfoToIframe(settings[id].iframe,id); + } else { + stop(); + } + } + + ['scroll','resize'].forEach(function(evt){ + log(id, type + evt + ' listener for sendPageInfo'); + func(window,evt,sendPageInfo); + }); + } + + function stop(){ + setListener('Remove ', removeEventListener); + } + + function start(){ + setListener('Add ', addEventListener); + } + + var id = iframeId; //Create locally scoped copy of iFrame ID + + start(); + + settings[id].stopPageInfo = stop; + } + + function stopPageInfoMonitor(){ + if (settings[iframeId] && settings[iframeId].stopPageInfo){ + settings[iframeId].stopPageInfo(); + delete settings[iframeId].stopPageInfo; + } + } + + function checkIFrameExists(){ + var retBool = true; + + if (null === messageData.iframe) { + warn(iframeId,'IFrame ('+messageData.id+') not found'); + retBool = false; + } + return retBool; + } + + function getElementPosition(target){ + var iFramePosition = target.getBoundingClientRect(); + + getPagePosition(iframeId); + + return { + x: Math.floor( Number(iFramePosition.left) + Number(pagePosition.x) ), + y: Math.floor( Number(iFramePosition.top) + Number(pagePosition.y) ) + }; + } + + function scrollRequestFromChild(addOffset){ + /* istanbul ignore next */ //Not testable in Karma + function reposition(){ + pagePosition = newPosition; + scrollTo(); + log(iframeId,'--'); + } + + function calcOffset(){ + return { + x: Number(messageData.width) + offset.x, + y: Number(messageData.height) + offset.y + }; + } + + function scrollParent(){ + if (window.parentIFrame){ + window.parentIFrame['scrollTo'+(addOffset?'Offset':'')](newPosition.x,newPosition.y); + } else { + warn(iframeId,'Unable to scroll to requested position, window.parentIFrame not found'); + } + } + + var + offset = addOffset ? getElementPosition(messageData.iframe) : {x:0,y:0}, + newPosition = calcOffset(); + + log(iframeId,'Reposition requested from iFrame (offset x:'+offset.x+' y:'+offset.y+')'); + + if(window.top!==window.self){ + scrollParent(); + } else { + reposition(); + } + } + + function scrollTo(){ + if (false !== callback('scrollCallback',pagePosition)){ + setPagePosition(iframeId); + } else { + unsetPagePosition(); + } + } + + function findTarget(location){ + function jumpToTarget(){ + var jumpPosition = getElementPosition(target); + + log(iframeId,'Moving to in page link (#'+hash+') at x: '+jumpPosition.x+' y: '+jumpPosition.y); + pagePosition = { + x: jumpPosition.x, + y: jumpPosition.y + }; + + scrollTo(); + log(iframeId,'--'); + } + + function jumpToParent(){ + if (window.parentIFrame){ + window.parentIFrame.moveToAnchor(hash); + } else { + log(iframeId,'In page link #'+hash+' not found and window.parentIFrame not found'); + } + } + + var + hash = location.split('#')[1] || '', + hashData = decodeURIComponent(hash), + target = document.getElementById(hashData) || document.getElementsByName(hashData)[0]; + + if (target){ + jumpToTarget(); + } else if(window.top!==window.self){ + jumpToParent(); + } else { + log(iframeId,'In page link #'+hash+' not found'); + } + } + + function callback(funcName,val){ + return chkCallback(iframeId,funcName,val); + } + + function actionMsg(){ + + if(settings[iframeId].firstRun) firstRun(); + + switch(messageData.type){ + case 'close': + closeIFrame(messageData.iframe); + break; + case 'message': + forwardMsgFromIFrame(getMsgBody(6)); + break; + case 'scrollTo': + scrollRequestFromChild(false); + break; + case 'scrollToOffset': + scrollRequestFromChild(true); + break; + case 'pageInfo': + sendPageInfoToIframe(settings[iframeId].iframe,iframeId); + startPageInfoMonitor(); + break; + case 'pageInfoStop': + stopPageInfoMonitor(); + break; + case 'inPageLink': + findTarget(getMsgBody(9)); + break; + case 'reset': + resetIFrame(messageData); + break; + case 'init': + resizeIFrame(); + callback('initCallback',messageData.iframe); + callback('resizedCallback',messageData); + break; + default: + resizeIFrame(); + callback('resizedCallback',messageData); + } + } + + function hasSettings(iframeId){ + var retBool = true; + + if (!settings[iframeId]){ + retBool = false; + warn(messageData.type + ' No settings for ' + iframeId + '. Message was: ' + msg); + } + + return retBool; + } + + function iFrameReadyMsgReceived(){ + for (var iframeId in settings){ + trigger('iFrame requested init',createOutgoingMsg(iframeId),document.getElementById(iframeId),iframeId); + } + } + + function firstRun() { + settings[iframeId].firstRun = false; + } + + var + msg = event.data, + messageData = {}, + iframeId = null; + + if('[iFrameResizerChild]Ready' === msg){ + iFrameReadyMsgReceived(); + } else if (isMessageForUs()){ + messageData = processMsg(); + iframeId = logId = messageData.id; + + if (!isMessageFromMetaParent() && hasSettings(iframeId)){ + log(iframeId,'Received: '+msg); + + if ( checkIFrameExists() && isMessageFromIFrame() ){ + actionMsg(); + } + } + } else { + info(iframeId,'Ignored: '+msg); + } + + } + + + function chkCallback(iframeId,funcName,val){ + var + func = null, + retVal = null; + + if(settings[iframeId]){ + func = settings[iframeId][funcName]; + + if( 'function' === typeof func){ + retVal = func(val); + } else { + throw new TypeError(funcName+' on iFrame['+iframeId+'] is not a function'); + } + } + + return retVal; + } + + function closeIFrame(iframe){ + var iframeId = iframe.id; + + log(iframeId,'Removing iFrame: '+iframeId); + iframe.parentNode.removeChild(iframe); + chkCallback(iframeId,'closedCallback',iframeId); + log(iframeId,'--'); + delete settings[iframeId]; + } + + function getPagePosition(iframeId){ + if(null === pagePosition){ + pagePosition = { + x: (window.pageXOffset !== undefined) ? window.pageXOffset : document.documentElement.scrollLeft, + y: (window.pageYOffset !== undefined) ? window.pageYOffset : document.documentElement.scrollTop + }; + log(iframeId,'Get page position: '+pagePosition.x+','+pagePosition.y); + } + } + + function setPagePosition(iframeId){ + if(null !== pagePosition){ + window.scrollTo(pagePosition.x,pagePosition.y); + log(iframeId,'Set page position: '+pagePosition.x+','+pagePosition.y); + unsetPagePosition(); + } + } + + function unsetPagePosition(){ + pagePosition = null; + } + + function resetIFrame(messageData){ + function reset(){ + setSize(messageData); + trigger('reset','reset',messageData.iframe,messageData.id); + } + + log(messageData.id,'Size reset requested by '+('init'===messageData.type?'host page':'iFrame')); + getPagePosition(messageData.id); + syncResize(reset,messageData,'reset'); + } + + function setSize(messageData){ + function setDimension(dimension){ + messageData.iframe.style[dimension] = messageData[dimension] + 'px'; + log( + messageData.id, + 'IFrame (' + iframeId + + ') ' + dimension + + ' set to ' + messageData[dimension] + 'px' + ); + } + + function chkZero(dimension){ + //FireFox sets dimension of hidden iFrames to zero. + //So if we detect that set up an event to check for + //when iFrame becomes visible. + + /* istanbul ignore next */ //Not testable in PhantomJS + if (!hiddenCheckEnabled && '0' === messageData[dimension]){ + hiddenCheckEnabled = true; + log(iframeId,'Hidden iFrame detected, creating visibility listener'); + fixHiddenIFrames(); + } + } + + function processDimension(dimension){ + setDimension(dimension); + chkZero(dimension); + } + + var iframeId = messageData.iframe.id; + + if(settings[iframeId]){ + if( settings[iframeId].sizeHeight) { processDimension('height'); } + if( settings[iframeId].sizeWidth ) { processDimension('width'); } + } + } + + function syncResize(func,messageData,doNotSync){ + /* istanbul ignore if */ //Not testable in PhantomJS + if(doNotSync!==messageData.type && requestAnimationFrame){ + log(messageData.id,'Requesting animation frame'); + requestAnimationFrame(func); + } else { + func(); + } + } + + function trigger(calleeMsg,msg,iframe,id){ + function postMessageToIFrame(){ + var target = settings[id].targetOrigin; + log(id,'[' + calleeMsg + '] Sending msg to iframe['+id+'] ('+msg+') targetOrigin: '+target); + iframe.contentWindow.postMessage( msgId + msg, target ); + } + + function iFrameNotFound(){ + info(id,'[' + calleeMsg + '] IFrame('+id+') not found'); + if(settings[id]) { + delete settings[id]; + } + } + + function chkAndSend(){ + if(iframe && 'contentWindow' in iframe && (null !== iframe.contentWindow)){ //Null test for PhantomJS + postMessageToIFrame(); + } else { + iFrameNotFound(); + } + } + + id = id || iframe.id; + + if(settings[id]) { + chkAndSend(); + } + + } + + function createOutgoingMsg(iframeId){ + return iframeId + + ':' + settings[iframeId].bodyMarginV1 + + ':' + settings[iframeId].sizeWidth + + ':' + settings[iframeId].log + + ':' + settings[iframeId].interval + + ':' + settings[iframeId].enablePublicMethods + + ':' + settings[iframeId].autoResize + + ':' + settings[iframeId].bodyMargin + + ':' + settings[iframeId].heightCalculationMethod + + ':' + settings[iframeId].bodyBackground + + ':' + settings[iframeId].bodyPadding + + ':' + settings[iframeId].tolerance + + ':' + settings[iframeId].inPageLinks + + ':' + settings[iframeId].resizeFrom + + ':' + settings[iframeId].widthCalculationMethod; + } + + function setupIFrame(iframe,options){ + function setLimits(){ + function addStyle(style){ + if ((Infinity !== settings[iframeId][style]) && (0 !== settings[iframeId][style])){ + iframe.style[style] = settings[iframeId][style] + 'px'; + log(iframeId,'Set '+style+' = '+settings[iframeId][style]+'px'); + } + } + + function chkMinMax(dimension){ + if (settings[iframeId]['min'+dimension]>settings[iframeId]['max'+dimension]){ + throw new Error('Value for min'+dimension+' can not be greater than max'+dimension); + } + } + + chkMinMax('Height'); + chkMinMax('Width'); + + addStyle('maxHeight'); + addStyle('minHeight'); + addStyle('maxWidth'); + addStyle('minWidth'); + } + + function newId(){ + var id = ((options && options.id) || defaults.id + count++); + if (null!==document.getElementById(id)){ + id = id + count++; + } + return id; + } + + function ensureHasId(iframeId){ + logId=iframeId; + if (''===iframeId){ + iframe.id = iframeId = newId(); + logEnabled = (options || {}).log; + logId=iframeId; + log(iframeId,'Added missing iframe ID: '+ iframeId +' (' + iframe.src + ')'); + } + + + return iframeId; + } + + function setScrolling(){ + log(iframeId,'IFrame scrolling ' + (settings[iframeId].scrolling ? 'enabled' : 'disabled') + ' for ' + iframeId); + iframe.style.overflow = false === settings[iframeId].scrolling ? 'hidden' : 'auto'; + iframe.scrolling = false === settings[iframeId].scrolling ? 'no' : 'yes'; + } + + //The V1 iFrame script expects an int, where as in V2 expects a CSS + //string value such as '1px 3em', so if we have an int for V2, set V1=V2 + //and then convert V2 to a string PX value. + function setupBodyMarginValues(){ + if (('number'===typeof(settings[iframeId].bodyMargin)) || ('0'===settings[iframeId].bodyMargin)){ + settings[iframeId].bodyMarginV1 = settings[iframeId].bodyMargin; + settings[iframeId].bodyMargin = '' + settings[iframeId].bodyMargin + 'px'; + } + } + + function checkReset(){ + // Reduce scope of firstRun to function, because IE8's JS execution + // context stack is borked and this value gets externally + // changed midway through running this function!!! + var + firstRun = settings[iframeId].firstRun, + resetRequertMethod = settings[iframeId].heightCalculationMethod in resetRequiredMethods; + + if (!firstRun && resetRequertMethod){ + resetIFrame({iframe:iframe, height:0, width:0, type:'init'}); + } + } + + function setupIFrameObject(){ + if(Function.prototype.bind){ //Ignore unpolyfilled IE8. + settings[iframeId].iframe.iFrameResizer = { + + close : closeIFrame.bind(null,settings[iframeId].iframe), + + resize : trigger.bind(null,'Window resize', 'resize', settings[iframeId].iframe), + + moveToAnchor : function(anchor){ + trigger('Move to anchor','moveToAnchor:'+anchor, settings[iframeId].iframe,iframeId); + }, + + sendMessage : function(message){ + message = JSON.stringify(message); + trigger('Send Message','message:'+message, settings[iframeId].iframe,iframeId); + } + }; + } + } + + //We have to call trigger twice, as we can not be sure if all + //iframes have completed loading when this code runs. The + //event listener also catches the page changing in the iFrame. + function init(msg){ + function iFrameLoaded(){ + trigger('iFrame.onload',msg,iframe); + checkReset(); + } + + addEventListener(iframe,'load',iFrameLoaded); + trigger('init',msg,iframe); + } + + function checkOptions(options){ + if ('object' !== typeof options){ + throw new TypeError('Options is not an object'); + } + } + + function copyOptions(options){ + for (var option in defaults) { + if (defaults.hasOwnProperty(option)){ + settings[iframeId][option] = options.hasOwnProperty(option) ? options[option] : defaults[option]; + } + } + } + + function getTargetOrigin (remoteHost){ + return ('' === remoteHost || 'file://' === remoteHost) ? '*' : remoteHost; + } + + function processOptions(options){ + options = options || {}; + settings[iframeId] = { + firstRun : true, + iframe : iframe, + remoteHost : iframe.src.split('/').slice(0,3).join('/') + }; + + checkOptions(options); + copyOptions(options); + + settings[iframeId].targetOrigin = true === settings[iframeId].checkOrigin ? getTargetOrigin(settings[iframeId].remoteHost) : '*'; + } + + function beenHere(){ + return (iframeId in settings && 'iFrameResizer' in iframe); + } + + var iframeId = ensureHasId(iframe.id); + + if (!beenHere()){ + processOptions(options); + setScrolling(); + setLimits(); + setupBodyMarginValues(); + init(createOutgoingMsg(iframeId)); + setupIFrameObject(); + } else { + warn(iframeId,'Ignored iFrame, already setup.'); + } + } + + function debouce(fn,time){ + if (null === timer){ + timer = setTimeout(function(){ + timer = null; + fn(); + }, time); + } + } + + /* istanbul ignore next */ //Not testable in PhantomJS + function fixHiddenIFrames(){ + function checkIFrames(){ + function checkIFrame(settingId){ + function chkDimension(dimension){ + return '0px' === settings[settingId].iframe.style[dimension]; + } + + function isVisible(el) { + return (null !== el.offsetParent); + } + + if (isVisible(settings[settingId].iframe) && (chkDimension('height') || chkDimension('width'))){ + trigger('Visibility change', 'resize', settings[settingId].iframe,settingId); + } + } + + for (var settingId in settings){ + checkIFrame(settingId); + } + } + + function mutationObserved(mutations){ + log('window','Mutation observed: ' + mutations[0].target + ' ' + mutations[0].type); + debouce(checkIFrames,16); + } + + function createMutationObserver(){ + var + target = document.querySelector('body'), + + config = { + attributes : true, + attributeOldValue : false, + characterData : true, + characterDataOldValue : false, + childList : true, + subtree : true + }, + + observer = new MutationObserver(mutationObserved); + + observer.observe(target, config); + } + + var MutationObserver = window.MutationObserver || window.WebKitMutationObserver; + + if (MutationObserver) createMutationObserver(); + } + + + function resizeIFrames(event){ + function resize(){ + sendTriggerMsg('Window '+event,'resize'); + } + + log('window','Trigger event: '+event); + debouce(resize,16); + } + + /* istanbul ignore next */ //Not testable in PhantomJS + function tabVisible() { + function resize(){ + sendTriggerMsg('Tab Visable','resize'); + } + + if('hidden' !== document.visibilityState) { + log('document','Trigger event: Visiblity change'); + debouce(resize,16); + } + } + + function sendTriggerMsg(eventName,event){ + function isIFrameResizeEnabled(iframeId) { + return 'parent' === settings[iframeId].resizeFrom && + settings[iframeId].autoResize && + !settings[iframeId].firstRun; + } + + for (var iframeId in settings){ + if(isIFrameResizeEnabled(iframeId)){ + trigger(eventName,event,document.getElementById(iframeId),iframeId); + } + } + } + + function setupEventListeners(){ + addEventListener(window,'message',iFrameListener); + + addEventListener(window,'resize', function(){resizeIFrames('resize');}); + + addEventListener(document,'visibilitychange',tabVisible); + addEventListener(document,'-webkit-visibilitychange',tabVisible); //Andriod 4.4 + addEventListener(window,'focusin',function(){resizeIFrames('focus');}); //IE8-9 + addEventListener(window,'focus',function(){resizeIFrames('focus');}); + } + + + function factory(){ + function init(options,element){ + function chkType(){ + if(!element.tagName) { + throw new TypeError('Object is not a valid DOM element'); + } else if ('IFRAME' !== element.tagName.toUpperCase()) { + throw new TypeError('Expected + + +

+

+
+ For details on how this works, see + http://davidjbradshaw.github.io/iframe-resizer/. +
+ + + + + + + + + \ No newline at end of file