diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2016-11-15 04:03:59 +0300 |
---|---|---|
committer | Matthieu Aubry <mattab@users.noreply.github.com> | 2016-11-15 04:03:59 +0300 |
commit | 587cc39e0362719332d410b7a4d5ddcc68788eeb (patch) | |
tree | c982c369cdda542c3a4de08be11c893e5364838c /libs | |
parent | 64314b26dbc6619d535002bdb79b9e55d1fc87db (diff) |
Update Marketplace to work with new API (#10799)
* starting to port marketplace to piwik 3
* updating tests
* fix translation key
* fix various issues
* use material select
* fix plugin upload
* deprecate license_homepage plugin metadata and link to a LICENSE[.md|.txt] file if found (#10756)
* deprecate license_homepage plugin metadata, and link to a LICENSE[.md|.txt] file if found
* Make license view HTML only without menu
* fix tests and update
* fix some links did not work
* we need to show warnings even when plugin is installed, not only when activated. otherwise it is not clear why something is not downloadable
* fix install was not working
* improved responsiveness of marketplace
* fix more tests
* fix search was shown when only a few plugins are there
* fix ui tests
* fix some translations
* fix tests and remove duplicated test
Diffstat (limited to 'libs')
20 files changed, 4592 insertions, 0 deletions
diff --git a/libs/bower_components/iframe-resizer/.bower.json b/libs/bower_components/iframe-resizer/.bower.json new file mode 100644 index 0000000000..5fe4004c75 --- /dev/null +++ b/libs/bower_components/iframe-resizer/.bower.json @@ -0,0 +1,55 @@ +{ + "name": "iframe-resizer", + "version": "3.5.5", + "homepage": "https://github.com/davidjbradshaw/iframe-resizer", + "authors": [ + "David J. Bradshaw <dave@bradshaw.net>" + ], + "description": "Responsively keep same and cross domain iFrames sized to their content with support for window/content resizing, multiple and nested iFrames. (Dependacy free and works with IE8+)", + "main": [ + "js/iframeResizer.js", + "js/iframeResizer.contentWindow.js" + ], + "keywords": [ + "CrossDomain", + "Cross-Domain", + "iFrame", + "Resizing", + "Resizer", + "postMessage", + "content", + "resize", + "height", + "autoheight", + "auto-height", + "iframe-auto-height", + "height-iframe", + "heightiframe", + "width", + "mutationObserver", + "RWD", + "responsive", + "responsiveiframes", + "responsive-iframes" + ], + "license": "MIT", + "ignore": [ + "example", + "test", + "gruntfile.js", + "*.md", + "*.json" + ], + "dependencies": {}, + "devDependencies": {}, + "_release": "3.5.5", + "_resolution": { + "type": "version", + "tag": "v3.5.5", + "commit": "ddfe8e77c1fd7cc36e2b88b057ef2ab04a45c666" + }, + "_source": "https://github.com/davidjbradshaw/iframe-resizer.git", + "_target": "~3.5.5", + "_originalSource": "iframe-resizer", + "_direct": true +}
\ No newline at end of file diff --git a/libs/bower_components/iframe-resizer/.gitignore b/libs/bower_components/iframe-resizer/.gitignore new file mode 100644 index 0000000000..352f695b0f --- /dev/null +++ b/libs/bower_components/iframe-resizer/.gitignore @@ -0,0 +1,9 @@ +.DS_Store +.coveralls.yml +node_modules +bin +example/test.html +test/*.off +npm-debug.log +bower_components +coverage*
\ No newline at end of file diff --git a/libs/bower_components/iframe-resizer/.travis.yml b/libs/bower_components/iframe-resizer/.travis.yml new file mode 100644 index 0000000000..6f671aef5e --- /dev/null +++ b/libs/bower_components/iframe-resizer/.travis.yml @@ -0,0 +1,6 @@ +language: node_js +node_js: + - "4.1" +before_script: + - npm install -g grunt-cli +sudo: false diff --git a/libs/bower_components/iframe-resizer/LICENSE b/libs/bower_components/iframe-resizer/LICENSE new file mode 100644 index 0000000000..1c74bdc837 --- /dev/null +++ b/libs/bower_components/iframe-resizer/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2013-2015 David J. Bradshaw + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE.
\ No newline at end of file diff --git a/libs/bower_components/iframe-resizer/bower.json b/libs/bower_components/iframe-resizer/bower.json new file mode 100644 index 0000000000..3749495987 --- /dev/null +++ b/libs/bower_components/iframe-resizer/bower.json @@ -0,0 +1,45 @@ +{ + "name": "iframe-resizer", + "version": "3.5.5", + "homepage": "https://github.com/davidjbradshaw/iframe-resizer", + "authors": [ + "David J. Bradshaw <dave@bradshaw.net>" + ], + "description": "Responsively keep same and cross domain iFrames sized to their content with support for window/content resizing, multiple and nested iFrames. (Dependacy free and works with IE8+)", + "main": [ + "js/iframeResizer.js", + "js/iframeResizer.contentWindow.js" + ], + "keywords": [ + "CrossDomain", + "Cross-Domain", + "iFrame", + "Resizing", + "Resizer", + "postMessage", + "content", + "resize", + "height", + "autoheight", + "auto-height", + "iframe-auto-height", + "height-iframe", + "heightiframe", + "width", + "mutationObserver", + "RWD", + "responsive", + "responsiveiframes", + "responsive-iframes" + ], + "license": "MIT", + "ignore": [ + "example", + "test", + "gruntfile.js", + "*.md", + "*.json" + ], + "dependencies": {}, + "devDependencies": {} +} diff --git a/libs/bower_components/iframe-resizer/index.js b/libs/bower_components/iframe-resizer/index.js new file mode 100644 index 0000000000..c08035a32b --- /dev/null +++ b/libs/bower_components/iframe-resizer/index.js @@ -0,0 +1,4 @@ + +'use strict'; + +module.exports = require('./js'); diff --git a/libs/bower_components/iframe-resizer/js/ie8.polyfils.map b/libs/bower_components/iframe-resizer/js/ie8.polyfils.map new file mode 100644 index 0000000000..eb0ef37713 --- /dev/null +++ b/libs/bower_components/iframe-resizer/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/libs/bower_components/iframe-resizer/js/ie8.polyfils.min.js b/libs/bower_components/iframe-resizer/js/ie8.polyfils.min.js new file mode 100644 index 0000000000..5836bacdb4 --- /dev/null +++ b/libs/bower_components/iframe-resizer/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/libs/bower_components/iframe-resizer/js/iframeResizer.contentWindow.js b/libs/bower_components/iframe-resizer/js/iframeResizer.contentWindow.js new file mode 100644 index 0000000000..bfb4a416e3 --- /dev/null +++ b/libs/bower_components/iframe-resizer/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/libs/bower_components/iframe-resizer/js/iframeResizer.contentWindow.map b/libs/bower_components/iframe-resizer/js/iframeResizer.contentWindow.map new file mode 100644 index 0000000000..ab9fe2d7eb --- /dev/null +++ b/libs/bower_components/iframe-resizer/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,KAA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AkBW,UAG1BkK,sBAAuB,WACtB,MAAOtK,UAASG,gBAAgBiO,cAGjC7D,sBAAuB,WACtB,MAAOvK,UAASG,gBAAgBsO,cAGjCP,IAAK,WACJ,MAAOzH,MAAKyH,IAAI1S,MAAM,KAAK0O,EAAmB1I,MAG/C2M,IAAK,WACJ,MAAO1H,MAAK0H,IAAI3S,MAAM,KAAK0O,EAAmB1I,MAG/CmN,KAAM,WACL,MAAOnN,IAAU0M,OAGlBU,cAAe,WACd,MAAOnI,MAAKyH,IAAI1M,GAAU4I,aAAcV,EAAc,SAASiB,OAGhEkE,cAAe,WACd,MAAOrE,GAAkB,SAAS,wBAIpC9I,IACC2I,WAAY,WACX,MAAOrK,UAASC,KAAKoO,aAGtBjE,WAAY,WACX,MAAOpK,UAASC,KAAK6O,aAGtBJ,OAAQ,WACP,MAAOjP,IAAkBwL,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/libs/bower_components/iframe-resizer/js/iframeResizer.contentWindow.min.js b/libs/bower_components/iframe-resizer/js/iframeResizer.contentWindow.min.js new file mode 100644 index 0000000000..5cfd4e276b --- /dev/null +++ b/libs/bower_components/iframe-resizer/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/libs/bower_components/iframe-resizer/js/iframeResizer.js b/libs/bower_components/iframe-resizer/js/iframeResizer.js new file mode 100644 index 0000000000..897a632ce4 --- /dev/null +++ b/libs/bower_components/iframe-resizer/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 (size<min) { + size=min; + log(iframeId,'Set ' + dimension + ' to min value'); + } + + if (size>max) { + 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 <IFRAME> tag, found <'+element.tagName+'>'); + } + } + + if(element) { + chkType(); + setupIFrame(element, options); + iFrames.push(element); + } + } + + var iFrames; + + setupRequestAnimationFrame(); + setupEventListeners(); + + return function iFrameResizeF(options,target){ + iFrames = []; //Only return iFrames past in on this call + + switch (typeof(target)){ + case 'undefined': + case 'string': + Array.prototype.forEach.call( + document.querySelectorAll( target || 'iframe' ), + init.bind(undefined, options) + ); + break; + case 'object': + init(options,target); + break; + default: + throw new TypeError('Unexpected data type ('+typeof(target)+')'); + } + + return iFrames; + }; + } + + function createJQueryPublicMethod($){ + if (!$.fn) { + info('','Unable to bind to jQuery, it is not fully loaded.'); + } else { + $.fn.iFrameResize = function $iFrameResizeF(options) { + function init(index, element) { + setupIFrame(element, options); + } + + return this.filter('iframe').each(init).end(); + }; + } + } + + if (window.jQuery) { createJQueryPublicMethod(jQuery); } + + if (typeof define === 'function' && define.amd) { + define([],factory); + } else if (typeof module === 'object' && typeof module.exports === 'object') { //Node for browserfy + module.exports = factory(); + } else { + window.iFrameResize = window.iFrameResize || factory(); + } + +})(window || {}); diff --git a/libs/bower_components/iframe-resizer/js/iframeResizer.map b/libs/bower_components/iframe-resizer/js/iframeResizer.map new file mode 100644 index 0000000000..c26b45efb4 --- /dev/null +++ b/libs/bower_components/iframe-resizer/js/iframeResizer.map @@ -0,0 +1 @@ +{"version":3,"file":"iframeResizer.min.js","sources":["iframeResizer.js"],"names":["window","addEventListener","obj","evt","func","attachEvent","removeEventListener","el","detachEvent","setupRequestAnimationFrame","x","vendors","length","requestAnimationFrame","log","getMyID","iframeId","retStr","top","self","parentIFrame","getId","formatLogHeader","msgId","isLogEnabled","settings","logEnabled","msg","output","info","warn","type","enabled","console","iFrameListener","event","resizeIFrame","resize","setSize","messageData","setPagePosition","ensureInRange","syncResize","processMsg","data","substr","msgIdLen","split","iframe","id","height","width","Dimension","max","Number","min","dimension","toLowerCase","size","isMessageFromIFrame","checkAllowedOrigin","checkList","i","retCode","checkOrigin","origin","checkSingle","remoteHost","constructor","Array","Error","isMessageForUs","isMessageFromMetaParent","true","false","undefined","getMsgBody","offset","indexOf","msgHeaderLen","forwardMsgFromIFrame","msgBody","callback","message","JSON","parse","getPageInfo","bodyPosition","document","body","getBoundingClientRect","iFramePosition","stringify","iframeHeight","iframeWidth","clientHeight","Math","documentElement","innerHeight","clientWidth","innerWidth","offsetTop","parseInt","offsetLeft","left","scrollTop","pageYOffset","scrollLeft","pageXOffset","sendPageInfoToIframe","debouncedTrigger","trigger","debouce","startPageInfoMonitor","setListener","sendPageInfo","stop","forEach","start","stopPageInfo","stopPageInfoMonitor","checkIFrameExists","retBool","getElementPosition","target","getPagePosition","floor","pagePosition","y","scrollRequestFromChild","addOffset","reposition","newPosition","scrollTo","calcOffset","scrollParent","unsetPagePosition","findTarget","location","jumpToTarget","jumpPosition","hash","jumpToParent","moveToAnchor","hashData","decodeURIComponent","getElementById","getElementsByName","funcName","val","chkCallback","actionMsg","firstRun","closeIFrame","resetIFrame","hasSettings","iFrameReadyMsgReceived","createOutgoingMsg","logId","retVal","TypeError","parentNode","removeChild","reset","setDimension","style","chkZero","hiddenCheckEnabled","fixHiddenIFrames","processDimension","sizeHeight","sizeWidth","doNotSync","calleeMsg","postMessageToIFrame","targetOrigin","contentWindow","postMessage","iFrameNotFound","chkAndSend","bodyMarginV1","interval","enablePublicMethods","autoResize","bodyMargin","heightCalculationMethod","bodyBackground","bodyPadding","tolerance","inPageLinks","resizeFrom","widthCalculationMethod","setupIFrame","options","setLimits","addStyle","Infinity","chkMinMax","newId","defaults","count","ensureHasId","src","setScrolling","scrolling","overflow","setupBodyMarginValues","checkReset","resetRequertMethod","resetRequiredMethods","setupIFrameObject","Function","prototype","bind","iFrameResizer","close","anchor","sendMessage","init","iFrameLoaded","checkOptions","copyOptions","option","hasOwnProperty","getTargetOrigin","processOptions","slice","join","beenHere","fn","time","timer","setTimeout","checkIFrames","checkIFrame","settingId","chkDimension","isVisible","offsetParent","mutationObserved","mutations","createMutationObserver","querySelector","config","attributes","attributeOldValue","characterData","characterDataOldValue","childList","subtree","observer","MutationObserver","observe","WebKitMutationObserver","resizeIFrames","sendTriggerMsg","tabVisible","visibilityState","eventName","isIFrameResizeEnabled","setupEventListeners","factory","element","chkType","tagName","toUpperCase","iFrames","push","call","querySelectorAll","createJQueryPublicMethod","$","iFrameResize","index","this","filter","each","end","msgHeader","scroll","bodyScroll","documentElementScroll","maxHeight","maxWidth","minHeight","minWidth","closedCallback","initCallback","messageCallback","resizedCallback","scrollCallback","jQuery","define","amd","module","exports"],"mappings":";;;;;;;CAWC,SAAUA,GACV,YA+CA,SAASC,GAAiBC,EAAIC,EAAIC,GAE7B,oBAAsBJ,GACzBE,EAAID,iBAAiBE,EAAIC,GAAM,GACrB,eAAiBJ,IAC3BE,EAAIG,YAAY,KAAKF,EAAIC,GAI3B,QAASE,GAAoBC,EAAGJ,EAAIC,GAE/B,uBAAyBJ,GAC5BO,EAAGD,oBAAoBH,EAAIC,GAAM,GACvB,eAAiBJ,IAC3BO,EAAGC,YAAY,KAAKL,EAAIC,GAI1B,QAASK,KACR,GAECC,GADAC,GAAW,MAAO,SAAU,IAAK,KAIlC,KAAKD,EAAI,EAAGA,EAAIC,EAAQC,SAAWC,EAAuBH,GAAK,EAC9DG,EAAwBb,EAAOW,EAAQD,GAAK,wBAGxC,IACJI,EAAI,QAAQ,uCAId,QAASC,GAAQC,GAChB,GAAIC,GAAS,cAAcD,CAU3B,OARIhB,GAAOkB,MAAMlB,EAAOmB,OAEtBF,EADGjB,EAAOoB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B,KACxBlH,EAAwBb,EAAOa,sBAC/BoM,GAAyB5J,IAAI,EAAEkO,OAAO,EAAEC,WAAW,EAAEC,sBAAsB,GAC3EhQ,KACA8M,EAAwB,KACxBzE,EAAwB,YAExByC,GACChB,YAA4B,EAC5BG,eAA4B,KAC5BF,WAA4B,KAC5BJ,aAA4B,EAC5BO,YAA4B,KAC5B3H,aAA4B,EAC5B6H,aAA4B,EAC5BP,qBAA4B,EAC5BG,wBAA4B,aAC5BxI,GAA4B,gBAC5BoI,SAA4B,GAC5BvK,KAA4B,EAC5B4Q,UAA4BtF,EAAAA,EAC5BuF,SAA4BvF,EAAAA,EAC5BwF,UAA4B,EAC5BC,SAA4B,EAC5B/F,WAA4B,SAC5Bc,WAA4B,EAC5BlC,YAA4B,EAC5BC,WAA4B,EAC5BiB,UAA4B,EAC5BG,uBAA4B,SAC5B+F,eAA4B,aAC5BC,aAA4B,aAC5BC,gBAA4B,WAAWlQ,EAAK,yCAC5CmQ,gBAA4B,aAC5BC,eAA4B,WAAW,OAAO,GAu6B5ClS,GAAOmS,QAAUrB,EAAyBqB,QAExB,kBAAXC,SAAyBA,OAAOC,IAC1CD,UAAU/B,GACkB,gBAAXiC,SAAiD,gBAAnBA,QAAOC,QACtDD,OAAOC,QAAUlC,IAEjBrQ,EAAOgR,aAAehR,EAAOgR,cAAgBX,KAG5CrQ","sourcesContent":["/*\n * File: iframeResizer.js\n * Desc: Force iframes to size to content.\n * Requires: iframeResizer.contentWindow.js to be loaded into the target frame.\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: Reed Dadoune - reed@dadoune.com\n */\n\n\n;(function(window) {\n\t'use strict';\n\n\tvar\n\t\tcount = 0,\n\t\tlogEnabled = false,\n\t\thiddenCheckEnabled = false,\n\t\tmsgHeader = 'message',\n\t\tmsgHeaderLen = msgHeader.length,\n\t\tmsgId = '[iFrameSizer]', //Must match iframe msg ID\n\t\tmsgIdLen = msgId.length,\n\t\tpagePosition = null,\n\t\trequestAnimationFrame = window.requestAnimationFrame,\n\t\tresetRequiredMethods = {max:1,scroll:1,bodyScroll:1,documentElementScroll:1},\n\t\tsettings = {},\n\t\ttimer = null,\n\t\tlogId = 'Host Page',\n\n\t\tdefaults = {\n\t\t\tautoResize : true,\n\t\t\tbodyBackground : null,\n\t\t\tbodyMargin : null,\n\t\t\tbodyMarginV1 : 8,\n\t\t\tbodyPadding : null,\n\t\t\tcheckOrigin : true,\n\t\t\tinPageLinks : false,\n\t\t\tenablePublicMethods : true,\n\t\t\theightCalculationMethod : 'bodyOffset',\n\t\t\tid : 'iFrameResizer',\n\t\t\tinterval : 32,\n\t\t\tlog : false,\n\t\t\tmaxHeight : Infinity,\n\t\t\tmaxWidth : Infinity,\n\t\t\tminHeight : 0,\n\t\t\tminWidth : 0,\n\t\t\tresizeFrom : 'parent',\n\t\t\tscrolling : false,\n\t\t\tsizeHeight : true,\n\t\t\tsizeWidth : false,\n\t\t\ttolerance : 0,\n\t\t\twidthCalculationMethod : 'scroll',\n\t\t\tclosedCallback : function(){},\n\t\t\tinitCallback : function(){},\n\t\t\tmessageCallback : function(){warn('MessageCallback function not defined');},\n\t\t\tresizedCallback : function(){},\n\t\t\tscrollCallback : function(){return true;}\n\t\t};\n\n\tfunction addEventListener(obj,evt,func){\n\t\t/* istanbul ignore else */ // Not testable in PhantonJS\n\t\tif ('addEventListener' in window){\n\t\t\tobj.addEventListener(evt,func, false);\n\t\t} else if ('attachEvent' in window){//IE\n\t\t\tobj.attachEvent('on'+evt,func);\n\t\t}\n\t}\n\n\tfunction 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 setupRequestAnimationFrame(){\n\t\tvar\n\t\t\tvendors = ['moz', 'webkit', 'o', 'ms'],\n\t\t\tx;\n\n\t\t// Remove vendor prefixing if prefixed and break early if not\n\t\tfor (x = 0; x < vendors.length && !requestAnimationFrame; x += 1) {\n\t\t\trequestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];\n\t\t}\n\n\t\tif (!(requestAnimationFrame)){\n\t\t\tlog('setup','RequestAnimationFrame not supported');\n\t\t}\n\t}\n\n\tfunction getMyID(iframeId){\n\t\tvar retStr = 'Host page: '+iframeId;\n\n\t\tif (window.top!==window.self){\n\t\t\tif (window.parentIFrame && window.parentIFrame.getId){\n\t\t\t\tretStr = window.parentIFrame.getId()+': '+iframeId;\n\t\t\t} else {\n\t\t\t\tretStr = 'Nested host page: '+iframeId;\n\t\t\t}\n\t\t}\n\n\t\treturn retStr;\n\t}\n\n\tfunction formatLogHeader(iframeId){\n\t\treturn msgId + '[' + getMyID(iframeId) + ']';\n\t}\n\n\tfunction isLogEnabled(iframeId){\n\t\treturn settings[iframeId] ? settings[iframeId].log : logEnabled;\n\t}\n\n\tfunction log(iframeId,msg){\n\t\toutput('log',iframeId,msg,isLogEnabled(iframeId));\n\t}\n\n\tfunction info(iframeId,msg){\n\t\toutput('info',iframeId,msg,isLogEnabled(iframeId));\n\t}\n\n\tfunction warn(iframeId,msg){\n\t\toutput('warn',iframeId,msg,true);\n\t}\n\n\tfunction output(type,iframeId,msg,enabled){\n\t\tif (true === enabled && 'object' === typeof window.console){\n\t\t\tconsole[type](formatLogHeader(iframeId),msg);\n\t\t}\n\t}\n\n\tfunction iFrameListener(event){\n\t\tfunction resizeIFrame(){\n\t\t\tfunction resize(){\n\t\t\t\tsetSize(messageData);\n\t\t\t\tsetPagePosition(iframeId);\n\t\t\t}\n\n\t\t\tensureInRange('Height');\n\t\t\tensureInRange('Width');\n\n\t\t\tsyncResize(resize,messageData,'init');\n\t\t}\n\n\t\tfunction processMsg(){\n\t\t\tvar data = msg.substr(msgIdLen).split(':');\n\n\t\t\treturn {\n\t\t\t\tiframe: settings[data[0]].iframe,\n\t\t\t\tid: data[0],\n\t\t\t\theight: data[1],\n\t\t\t\twidth: data[2],\n\t\t\t\ttype: data[3]\n\t\t\t};\n\t\t}\n\n\t\tfunction ensureInRange(Dimension){\n\t\t\tvar\n\t\t\t\tmax = Number(settings[iframeId]['max' + Dimension]),\n\t\t\t\tmin = Number(settings[iframeId]['min' + Dimension]),\n\t\t\t\tdimension = Dimension.toLowerCase(),\n\t\t\t\tsize = Number(messageData[dimension]);\n\n\t\t\tlog(iframeId,'Checking ' + dimension + ' is in range ' + min + '-' + max);\n\n\t\t\tif (size<min) {\n\t\t\t\tsize=min;\n\t\t\t\tlog(iframeId,'Set ' + dimension + ' to min value');\n\t\t\t}\n\n\t\t\tif (size>max) {\n\t\t\t\tsize=max;\n\t\t\t\tlog(iframeId,'Set ' + dimension + ' to max value');\n\t\t\t}\n\n\t\t\tmessageData[dimension] = '' + size;\n\t\t}\n\n\n\t\tfunction isMessageFromIFrame(){\n\t\t\tfunction checkAllowedOrigin(){\n\t\t\t\tfunction checkList(){\n\t\t\t\t\tvar\n\t\t\t\t\t\ti = 0,\n\t\t\t\t\t\tretCode = false;\n\n\t\t\t\t\tlog(iframeId,'Checking connection is from allowed list of origins: ' + checkOrigin);\n\n\t\t\t\t\tfor (; i < checkOrigin.length; i++) {\n\t\t\t\t\t\tif (checkOrigin[i] === origin) {\n\t\t\t\t\t\t\tretCode = true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn retCode;\n\t\t\t\t}\n\n\t\t\t\tfunction checkSingle(){\n\t\t\t\t\tvar remoteHost = settings[iframeId].remoteHost;\n\t\t\t\t\tlog(iframeId,'Checking connection is from: '+remoteHost);\n\t\t\t\t\treturn origin === remoteHost;\n\t\t\t\t}\n\n\t\t\t\treturn checkOrigin.constructor === Array ? checkList() : checkSingle();\n\t\t\t}\n\n\t\t\tvar\n\t\t\t\torigin = event.origin,\n\t\t\t\tcheckOrigin = settings[iframeId].checkOrigin;\n\n\t\t\tif (checkOrigin && (''+origin !== 'null') && !checkAllowedOrigin()) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Unexpected message received from: ' + origin +\n\t\t\t\t\t' for ' + messageData.iframe.id +\n\t\t\t\t\t'. Message was: ' + event.data +\n\t\t\t\t\t'. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.'\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn true;\n\t\t}\n\n\t\tfunction isMessageForUs(){\n\t\t\treturn msgId === (('' + msg).substr(0,msgIdLen)) && (msg.substr(msgIdLen).split(':')[0] in settings); //''+Protects against non-string msg\n\t\t}\n\n\t\tfunction isMessageFromMetaParent(){\n\t\t\t//Test if this message is from a parent above us. This is an ugly test, however, updating\n\t\t\t//the message format would break backwards compatibity.\n\t\t\tvar retCode = messageData.type in {'true':1,'false':1,'undefined':1};\n\n\t\t\tif (retCode){\n\t\t\t\tlog(iframeId,'Ignoring init message from meta parent page');\n\t\t\t}\n\n\t\t\treturn retCode;\n\t\t}\n\n\t\tfunction getMsgBody(offset){\n\t\t\treturn msg.substr(msg.indexOf(':')+msgHeaderLen+offset);\n\t\t}\n\n\t\tfunction forwardMsgFromIFrame(msgBody){\n\t\t\tlog(iframeId,'MessageCallback passed: {iframe: '+ messageData.iframe.id + ', message: ' + msgBody + '}');\n\t\t\tcallback('messageCallback',{\n\t\t\t\tiframe: messageData.iframe,\n\t\t\t\tmessage: JSON.parse(msgBody)\n\t\t\t});\n\t\t\tlog(iframeId,'--');\n\t\t}\n\n\t\tfunction getPageInfo(){\n\t\t\tvar\n\t\t\t\tbodyPosition = document.body.getBoundingClientRect(),\n\t\t\t\tiFramePosition = messageData.iframe.getBoundingClientRect();\n\n\t\t\treturn JSON.stringify({\n\t\t\t\tiframeHeight: iFramePosition.height,\n\t\t\t\tiframeWidth: iFramePosition.width,\n\t\t\t\tclientHeight: Math.max(document.documentElement.clientHeight, window.innerHeight || 0),\n\t\t\t\tclientWidth: Math.max(document.documentElement.clientWidth, window.innerWidth || 0),\n\t\t\t\toffsetTop: parseInt(iFramePosition.top - bodyPosition.top, 10),\n\t\t\t\toffsetLeft: parseInt(iFramePosition.left - bodyPosition.left, 10),\n\t\t\t\tscrollTop: window.pageYOffset,\n\t\t\t\tscrollLeft: window.pageXOffset\n\t\t\t});\n\t\t}\n\n\t\tfunction sendPageInfoToIframe(iframe,iframeId){\n\t\t\tfunction debouncedTrigger(){\n\t\t\t\ttrigger(\n\t\t\t\t\t'Send Page Info',\n\t\t\t\t\t'pageInfo:' + getPageInfo(), \n\t\t\t\t\tiframe, \n\t\t\t\t\tiframeId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tdebouce(debouncedTrigger,32);\n\t\t}\n\n\n\t\tfunction startPageInfoMonitor(){\n\t\t\tfunction setListener(type,func){\n\t\t\t\tfunction sendPageInfo(){\n\t\t\t\t\tif (settings[id]){\n\t\t\t\t\t\tsendPageInfoToIframe(settings[id].iframe,id);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstop();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t['scroll','resize'].forEach(function(evt){\n\t\t\t\t\tlog(id, type + evt + ' listener for sendPageInfo');\n\t\t\t\t\tfunc(window,evt,sendPageInfo);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tfunction stop(){\n\t\t\t\tsetListener('Remove ', removeEventListener);\n\t\t\t}\n\n\t\t\tfunction start(){\n\t\t\t\tsetListener('Add ', addEventListener);\n\t\t\t}\n\t\t\t\n\t\t\tvar id = iframeId; //Create locally scoped copy of iFrame ID\n\n\t\t\tstart();\n\n\t\t\tsettings[id].stopPageInfo = stop;\n\t\t}\n\n\t\tfunction stopPageInfoMonitor(){\n\t\t\tif (settings[iframeId] && settings[iframeId].stopPageInfo){\n\t\t\t\tsettings[iframeId].stopPageInfo();\n\t\t\t\tdelete settings[iframeId].stopPageInfo;\n\t\t\t}\n\t\t}\n\n\t\tfunction checkIFrameExists(){\n\t\t\tvar retBool = true;\n\n\t\t\tif (null === messageData.iframe) {\n\t\t\t\twarn(iframeId,'IFrame ('+messageData.id+') not found');\n\t\t\t\tretBool = false;\n\t\t\t}\n\t\t\treturn retBool;\n\t\t}\n\n\t\tfunction getElementPosition(target){\n\t\t\tvar iFramePosition = target.getBoundingClientRect();\n\n\t\t\tgetPagePosition(iframeId);\n\n\t\t\treturn {\n\t\t\t\tx: Math.floor( Number(iFramePosition.left) + Number(pagePosition.x) ),\n\t\t\t\ty: Math.floor( Number(iFramePosition.top) + Number(pagePosition.y) )\n\t\t\t};\n\t\t}\n\n\t\tfunction scrollRequestFromChild(addOffset){\n\t\t\t/* istanbul ignore next */ //Not testable in Karma\n\t\t\tfunction reposition(){\n\t\t\t\tpagePosition = newPosition;\n\t\t\t\tscrollTo();\n\t\t\t\tlog(iframeId,'--');\n\t\t\t}\n\n\t\t\tfunction calcOffset(){\n\t\t\t\treturn {\n\t\t\t\t\tx: Number(messageData.width) + offset.x,\n\t\t\t\t\ty: Number(messageData.height) + offset.y\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tfunction scrollParent(){\n\t\t\t\tif (window.parentIFrame){\n\t\t\t\t\twindow.parentIFrame['scrollTo'+(addOffset?'Offset':'')](newPosition.x,newPosition.y);\n\t\t\t\t} else {\n\t\t\t\t\twarn(iframeId,'Unable to scroll to requested position, window.parentIFrame not found');\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar\n\t\t\t\toffset = addOffset ? getElementPosition(messageData.iframe) : {x:0,y:0},\n\t\t\t\tnewPosition = calcOffset();\n\n\t\t\tlog(iframeId,'Reposition requested from iFrame (offset x:'+offset.x+' y:'+offset.y+')');\n\n\t\t\tif(window.top!==window.self){\n\t\t\t\tscrollParent();\n\t\t\t} else {\n\t\t\t\treposition();\n\t\t\t}\n\t\t}\n\n\t\tfunction scrollTo(){\n\t\t\tif (false !== callback('scrollCallback',pagePosition)){\n\t\t\t\tsetPagePosition(iframeId);\n\t\t\t} else {\n\t\t\t\tunsetPagePosition();\n\t\t\t}\n\t\t}\n\n\t\tfunction findTarget(location){\n\t\t\tfunction jumpToTarget(){\n\t\t\t\tvar jumpPosition = getElementPosition(target);\n\n\t\t\t\tlog(iframeId,'Moving to in page link (#'+hash+') at x: '+jumpPosition.x+' y: '+jumpPosition.y);\n\t\t\t\tpagePosition = {\n\t\t\t\t\tx: jumpPosition.x,\n\t\t\t\t\ty: jumpPosition.y\n\t\t\t\t};\n\n\t\t\t\tscrollTo();\n\t\t\t\tlog(iframeId,'--');\n\t\t\t}\n\n\t\t\tfunction jumpToParent(){\n\t\t\t\tif (window.parentIFrame){\n\t\t\t\t\twindow.parentIFrame.moveToAnchor(hash);\n\t\t\t\t} else {\n\t\t\t\t\tlog(iframeId,'In page link #'+hash+' not found and window.parentIFrame not found');\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar\n\t\t\t\thash = location.split('#')[1] || '',\n\t\t\t\thashData = decodeURIComponent(hash),\n\t\t\t\ttarget = document.getElementById(hashData) || document.getElementsByName(hashData)[0];\n\n\t\t\tif (target){\n\t\t\t\tjumpToTarget();\n\t\t\t} else if(window.top!==window.self){\n\t\t\t\tjumpToParent();\n\t\t\t} else {\n\t\t\t\tlog(iframeId,'In page link #'+hash+' not found');\n\t\t\t}\n\t\t}\n\n\t\tfunction callback(funcName,val){\n\t\t\treturn chkCallback(iframeId,funcName,val);\n\t\t}\n\n\t\tfunction actionMsg(){\n\n\t\t\tif(settings[iframeId].firstRun) firstRun();\n\n\t\t\tswitch(messageData.type){\n\t\t\tcase 'close':\n\t\t\t\tcloseIFrame(messageData.iframe);\n\t\t\t\tbreak;\n\t\t\tcase 'message':\n\t\t\t\tforwardMsgFromIFrame(getMsgBody(6));\n\t\t\t\tbreak;\n\t\t\tcase 'scrollTo':\n\t\t\t\tscrollRequestFromChild(false);\n\t\t\t\tbreak;\n\t\t\tcase 'scrollToOffset':\n\t\t\t\tscrollRequestFromChild(true);\n\t\t\t\tbreak;\n\t\t\tcase 'pageInfo':\n\t\t\t\tsendPageInfoToIframe(settings[iframeId].iframe,iframeId);\n\t\t\t\tstartPageInfoMonitor();\n\t\t\t\tbreak;\n\t\t\tcase 'pageInfoStop':\n\t\t\t\tstopPageInfoMonitor();\n\t\t\t\tbreak;\n\t\t\tcase 'inPageLink':\n\t\t\t\tfindTarget(getMsgBody(9));\n\t\t\t\tbreak;\n\t\t\tcase 'reset':\n\t\t\t\tresetIFrame(messageData);\n\t\t\t\tbreak;\n\t\t\tcase 'init':\n\t\t\t\tresizeIFrame();\n\t\t\t\tcallback('initCallback',messageData.iframe);\n\t\t\t\tcallback('resizedCallback',messageData);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tresizeIFrame();\n\t\t\t\tcallback('resizedCallback',messageData);\n\t\t\t}\n\t\t}\n\n\t\tfunction hasSettings(iframeId){\n\t\t\tvar retBool = true;\n\n\t\t\tif (!settings[iframeId]){\n\t\t\t\tretBool = false;\n\t\t\t\twarn(messageData.type + ' No settings for ' + iframeId + '. Message was: ' + msg);\n\t\t\t}\n\n\t\t\treturn retBool;\n\t\t}\n\n\t\tfunction iFrameReadyMsgReceived(){\n\t\t\tfor (var iframeId in settings){\n\t\t\t\ttrigger('iFrame requested init',createOutgoingMsg(iframeId),document.getElementById(iframeId),iframeId);\n\t\t\t}\n\t\t}\n\n\t\tfunction firstRun() {\n\t\t\tsettings[iframeId].firstRun = false;\n\t\t}\n\n\t\tvar\n\t\t\tmsg = event.data,\n\t\t\tmessageData = {},\n\t\t\tiframeId = null;\n\n\t\tif('[iFrameResizerChild]Ready' === msg){\n\t\t\tiFrameReadyMsgReceived();\n\t\t} else if (isMessageForUs()){\n\t\t\tmessageData = processMsg();\n\t\t\tiframeId = logId = messageData.id;\n\n\t\t\tif (!isMessageFromMetaParent() && hasSettings(iframeId)){\n\t\t\t\tlog(iframeId,'Received: '+msg);\n\n\t\t\t\tif ( checkIFrameExists() && isMessageFromIFrame() ){\n\t\t\t\t\tactionMsg();\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tinfo(iframeId,'Ignored: '+msg);\n\t\t}\n\n\t}\n\n\n\tfunction chkCallback(iframeId,funcName,val){\n\t\tvar\n\t\t\tfunc = null,\n\t\t\tretVal = null;\n\n\t\tif(settings[iframeId]){\n\t\t\tfunc = settings[iframeId][funcName];\n\n\t\t\tif( 'function' === typeof func){\n\t\t\t\tretVal = func(val);\n\t\t\t} else {\n\t\t\t\tthrow new TypeError(funcName+' on iFrame['+iframeId+'] is not a function');\n\t\t\t}\n\t\t}\n\n\t\treturn retVal;\n\t}\n\n\tfunction closeIFrame(iframe){\n\t\tvar iframeId = iframe.id;\n\n\t\tlog(iframeId,'Removing iFrame: '+iframeId);\n\t\tiframe.parentNode.removeChild(iframe);\n\t\tchkCallback(iframeId,'closedCallback',iframeId);\n\t\tlog(iframeId,'--');\n\t\tdelete settings[iframeId];\n\t}\n\n\tfunction getPagePosition(iframeId){\n\t\tif(null === pagePosition){\n\t\t\tpagePosition = {\n\t\t\t\tx: (window.pageXOffset !== undefined) ? window.pageXOffset : document.documentElement.scrollLeft,\n\t\t\t\ty: (window.pageYOffset !== undefined) ? window.pageYOffset : document.documentElement.scrollTop\n\t\t\t};\n\t\t\tlog(iframeId,'Get page position: '+pagePosition.x+','+pagePosition.y);\n\t\t}\n\t}\n\n\tfunction setPagePosition(iframeId){\n\t\tif(null !== pagePosition){\n\t\t\twindow.scrollTo(pagePosition.x,pagePosition.y);\n\t\t\tlog(iframeId,'Set page position: '+pagePosition.x+','+pagePosition.y);\n\t\t\tunsetPagePosition();\n\t\t}\n\t}\n\n\tfunction unsetPagePosition(){\n\t\tpagePosition = null;\n\t}\n\n\tfunction resetIFrame(messageData){\n\t\tfunction reset(){\n\t\t\tsetSize(messageData);\n\t\t\ttrigger('reset','reset',messageData.iframe,messageData.id);\n\t\t}\n\n\t\tlog(messageData.id,'Size reset requested by '+('init'===messageData.type?'host page':'iFrame'));\n\t\tgetPagePosition(messageData.id);\n\t\tsyncResize(reset,messageData,'reset');\n\t}\n\n\tfunction setSize(messageData){\n\t\tfunction setDimension(dimension){\n\t\t\tmessageData.iframe.style[dimension] = messageData[dimension] + 'px';\n\t\t\tlog(\n\t\t\t\tmessageData.id,\n\t\t\t\t'IFrame (' + iframeId +\n\t\t\t\t') ' + dimension +\n\t\t\t\t' set to ' + messageData[dimension] + 'px'\n\t\t\t);\n\t\t}\n\n\t\tfunction chkZero(dimension){\n\t\t\t//FireFox sets dimension of hidden iFrames to zero.\n\t\t\t//So if we detect that set up an event to check for\n\t\t\t//when iFrame becomes visible.\n\n\t\t\t/* istanbul ignore next */ //Not testable in PhantomJS\n\t\t\tif (!hiddenCheckEnabled && '0' === messageData[dimension]){\n\t\t\t\thiddenCheckEnabled = true;\n\t\t\t\tlog(iframeId,'Hidden iFrame detected, creating visibility listener');\n\t\t\t\tfixHiddenIFrames();\n\t\t\t}\n\t\t}\n\n\t\tfunction processDimension(dimension){\n\t\t\tsetDimension(dimension);\n\t\t\tchkZero(dimension);\n\t\t}\n\n\t\tvar iframeId = messageData.iframe.id;\n\n\t\tif(settings[iframeId]){\n\t\t\tif( settings[iframeId].sizeHeight) { processDimension('height'); }\n\t\t\tif( settings[iframeId].sizeWidth ) { processDimension('width'); }\n\t\t}\n\t}\n\n\tfunction syncResize(func,messageData,doNotSync){\n\t\t/* istanbul ignore if */ //Not testable in PhantomJS\n\t\tif(doNotSync!==messageData.type && requestAnimationFrame){\n\t\t\tlog(messageData.id,'Requesting animation frame');\n\t\t\trequestAnimationFrame(func);\n\t\t} else {\n\t\t\tfunc();\n\t\t}\n\t}\n\n\tfunction trigger(calleeMsg,msg,iframe,id){\n\t\tfunction postMessageToIFrame(){\n\t\t\tvar target = settings[id].targetOrigin;\n\t\t\tlog(id,'[' + calleeMsg + '] Sending msg to iframe['+id+'] ('+msg+') targetOrigin: '+target);\n\t\t\tiframe.contentWindow.postMessage( msgId + msg, target );\n\t\t}\n\n\t\tfunction iFrameNotFound(){\n\t\t\tinfo(id,'[' + calleeMsg + '] IFrame('+id+') not found');\n\t\t\tif(settings[id]) {\n\t\t\t\tdelete settings[id];\n\t\t\t}\n\t\t}\n\n\t\tfunction chkAndSend(){\n\t\t\tif(iframe && 'contentWindow' in iframe && (null !== iframe.contentWindow)){ //Null test for PhantomJS\n\t\t\t\tpostMessageToIFrame();\n\t\t\t} else {\n\t\t\t\tiFrameNotFound();\n\t\t\t}\n\t\t}\n\n\t\tid = id || iframe.id;\n\n\t\tif(settings[id]) {\n\t\t\tchkAndSend();\n\t\t}\n\n\t}\n\n\tfunction createOutgoingMsg(iframeId){\n\t\treturn iframeId +\n\t\t\t':' + settings[iframeId].bodyMarginV1 +\n\t\t\t':' + settings[iframeId].sizeWidth +\n\t\t\t':' + settings[iframeId].log +\n\t\t\t':' + settings[iframeId].interval +\n\t\t\t':' + settings[iframeId].enablePublicMethods +\n\t\t\t':' + settings[iframeId].autoResize +\n\t\t\t':' + settings[iframeId].bodyMargin +\n\t\t\t':' + settings[iframeId].heightCalculationMethod +\n\t\t\t':' + settings[iframeId].bodyBackground +\n\t\t\t':' + settings[iframeId].bodyPadding +\n\t\t\t':' + settings[iframeId].tolerance +\n\t\t\t':' + settings[iframeId].inPageLinks +\n\t\t\t':' + settings[iframeId].resizeFrom +\n\t\t\t':' + settings[iframeId].widthCalculationMethod;\n\t}\n\n\tfunction setupIFrame(iframe,options){\n\t\tfunction setLimits(){\n\t\t\tfunction addStyle(style){\n\t\t\t\tif ((Infinity !== settings[iframeId][style]) && (0 !== settings[iframeId][style])){\n\t\t\t\t\tiframe.style[style] = settings[iframeId][style] + 'px';\n\t\t\t\t\tlog(iframeId,'Set '+style+' = '+settings[iframeId][style]+'px');\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction chkMinMax(dimension){\n\t\t\t\tif (settings[iframeId]['min'+dimension]>settings[iframeId]['max'+dimension]){\n\t\t\t\t\tthrow new Error('Value for min'+dimension+' can not be greater than max'+dimension);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tchkMinMax('Height');\n\t\t\tchkMinMax('Width');\n\n\t\t\taddStyle('maxHeight');\n\t\t\taddStyle('minHeight');\n\t\t\taddStyle('maxWidth');\n\t\t\taddStyle('minWidth');\n\t\t}\n\n\t\tfunction newId(){\n\t\t\tvar id = ((options && options.id) || defaults.id + count++);\n\t\t\tif (null!==document.getElementById(id)){\n\t\t\t\tid = id + count++;\n\t\t\t}\n\t\t\treturn id;\n\t\t}\n\n\t\tfunction ensureHasId(iframeId){\n\t\t\tlogId=iframeId;\n\t\t\tif (''===iframeId){\n\t\t\t\tiframe.id = iframeId = newId();\n\t\t\t\tlogEnabled = (options || {}).log;\n\t\t\t\tlogId=iframeId;\n\t\t\t\tlog(iframeId,'Added missing iframe ID: '+ iframeId +' (' + iframe.src + ')');\n\t\t\t}\n\n\n\t\t\treturn iframeId;\n\t\t}\n\n\t\tfunction setScrolling(){\n\t\t\tlog(iframeId,'IFrame scrolling ' + (settings[iframeId].scrolling ? 'enabled' : 'disabled') + ' for ' + iframeId);\n\t\t\tiframe.style.overflow = false === settings[iframeId].scrolling ? 'hidden' : 'auto';\n\t\t\tiframe.scrolling = false === settings[iframeId].scrolling ? 'no' : 'yes';\n\t\t}\n\n\t\t//The V1 iFrame script expects an int, where as in V2 expects a CSS\n\t\t//string value such as '1px 3em', so if we have an int for V2, set V1=V2\n\t\t//and then convert V2 to a string PX value.\n\t\tfunction setupBodyMarginValues(){\n\t\t\tif (('number'===typeof(settings[iframeId].bodyMargin)) || ('0'===settings[iframeId].bodyMargin)){\n\t\t\t\tsettings[iframeId].bodyMarginV1 = settings[iframeId].bodyMargin;\n\t\t\t\tsettings[iframeId].bodyMargin = '' + settings[iframeId].bodyMargin + 'px';\n\t\t\t}\n\t\t}\n\n\t\tfunction checkReset(){\n\t\t\t// Reduce scope of firstRun to function, because IE8's JS execution\n\t\t\t// context stack is borked and this value gets externally\n\t\t\t// changed midway through running this function!!!\n\t\t\tvar\n\t\t\t\tfirstRun = settings[iframeId].firstRun,\n\t\t\t\tresetRequertMethod = settings[iframeId].heightCalculationMethod in resetRequiredMethods;\n\n\t\t\tif (!firstRun && resetRequertMethod){\n\t\t\t\tresetIFrame({iframe:iframe, height:0, width:0, type:'init'});\n\t\t\t}\n\t\t}\n\n\t\tfunction setupIFrameObject(){\n\t\t\tif(Function.prototype.bind){ //Ignore unpolyfilled IE8.\n\t\t\t\tsettings[iframeId].iframe.iFrameResizer = {\n\n\t\t\t\t\tclose : closeIFrame.bind(null,settings[iframeId].iframe),\n\n\t\t\t\t\tresize : trigger.bind(null,'Window resize', 'resize', settings[iframeId].iframe),\n\n\t\t\t\t\tmoveToAnchor : function(anchor){\n\t\t\t\t\t\ttrigger('Move to anchor','moveToAnchor:'+anchor, settings[iframeId].iframe,iframeId);\n\t\t\t\t\t},\n\n\t\t\t\t\tsendMessage : function(message){\n\t\t\t\t\t\tmessage = JSON.stringify(message);\n\t\t\t\t\t\ttrigger('Send Message','message:'+message, settings[iframeId].iframe,iframeId);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\t//We have to call trigger twice, as we can not be sure if all\n\t\t//iframes have completed loading when this code runs. The\n\t\t//event listener also catches the page changing in the iFrame.\n\t\tfunction init(msg){\n\t\t\tfunction iFrameLoaded(){\n\t\t\t\ttrigger('iFrame.onload',msg,iframe);\n\t\t\t\tcheckReset();\n\t\t\t}\n\n\t\t\taddEventListener(iframe,'load',iFrameLoaded);\n\t\t\ttrigger('init',msg,iframe);\n\t\t}\n\n\t\tfunction checkOptions(options){\n\t\t\tif ('object' !== typeof options){\n\t\t\t\tthrow new TypeError('Options is not an object');\n\t\t\t}\n\t\t}\n\n\t\tfunction copyOptions(options){\n\t\t\tfor (var option in defaults) {\n\t\t\t\tif (defaults.hasOwnProperty(option)){\n\t\t\t\t\tsettings[iframeId][option] = options.hasOwnProperty(option) ? options[option] : defaults[option];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction getTargetOrigin (remoteHost){\n\t\t\treturn ('' === remoteHost || 'file://' === remoteHost) ? '*' : remoteHost;\n\t\t}\n\n\t\tfunction processOptions(options){\n\t\t\toptions = options || {};\n\t\t\tsettings[iframeId] = {\n\t\t\t\tfirstRun\t: true,\n\t\t\t\tiframe\t\t: iframe,\n\t\t\t\tremoteHost\t: iframe.src.split('/').slice(0,3).join('/')\n\t\t\t};\n\n\t\t\tcheckOptions(options);\n\t\t\tcopyOptions(options);\n\n\t\t\tsettings[iframeId].targetOrigin = true === settings[iframeId].checkOrigin ? getTargetOrigin(settings[iframeId].remoteHost) : '*';\n\t\t}\n\n\t\tfunction beenHere(){\n\t\t\treturn (iframeId in settings && 'iFrameResizer' in iframe);\n\t\t}\n\n\t\tvar iframeId = ensureHasId(iframe.id);\n\n\t\tif (!beenHere()){\n\t\t\tprocessOptions(options);\n\t\t\tsetScrolling();\n\t\t\tsetLimits();\n\t\t\tsetupBodyMarginValues();\n\t\t\tinit(createOutgoingMsg(iframeId));\n\t\t\tsetupIFrameObject();\n\t\t} else {\n\t\t\twarn(iframeId,'Ignored iFrame, already setup.');\n\t\t}\n\t}\n\n\tfunction debouce(fn,time){\n\t\tif (null === timer){\n\t\t\ttimer = setTimeout(function(){\n\t\t\t\ttimer = null;\n\t\t\t\tfn();\n\t\t\t}, time);\n\t\t}\n\t}\n\n\t/* istanbul ignore next */ //Not testable in PhantomJS\n\tfunction fixHiddenIFrames(){\n\t\tfunction checkIFrames(){\n\t\t\tfunction checkIFrame(settingId){\n\t\t\t\tfunction chkDimension(dimension){\n\t\t\t\t\treturn '0px' === settings[settingId].iframe.style[dimension];\n\t\t\t\t}\n\n\t\t\t\tfunction isVisible(el) {\n\t\t\t\t\treturn (null !== el.offsetParent);\n\t\t\t\t}\n\n\t\t\t\tif (isVisible(settings[settingId].iframe) && (chkDimension('height') || chkDimension('width'))){\n\t\t\t\t\ttrigger('Visibility change', 'resize', settings[settingId].iframe,settingId);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (var settingId in settings){\n\t\t\t\tcheckIFrame(settingId);\n\t\t\t}\n\t\t}\n\n\t\tfunction mutationObserved(mutations){\n\t\t\tlog('window','Mutation observed: ' + mutations[0].target + ' ' + mutations[0].type);\n\t\t\tdebouce(checkIFrames,16);\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\t\tobserver = new MutationObserver(mutationObserved);\n\n\t\t\tobserver.observe(target, config);\n\t\t}\n\n\t\tvar MutationObserver = window.MutationObserver || window.WebKitMutationObserver;\n\n\t\tif (MutationObserver) createMutationObserver();\n\t}\n\n\n\tfunction resizeIFrames(event){\n\t\tfunction resize(){\n\t\t\tsendTriggerMsg('Window '+event,'resize');\n\t\t}\n\n\t\tlog('window','Trigger event: '+event);\n\t\tdebouce(resize,16);\n\t}\n\n\t/* istanbul ignore next */ //Not testable in PhantomJS\n\tfunction tabVisible() {\n\t\tfunction resize(){\n\t\t\tsendTriggerMsg('Tab Visable','resize');\n\t\t}\n\n\t\tif('hidden' !== document.visibilityState) {\n\t\t\tlog('document','Trigger event: Visiblity change');\n\t\t\tdebouce(resize,16);\n\t\t}\n\t}\n\n\tfunction sendTriggerMsg(eventName,event){\n\t\tfunction isIFrameResizeEnabled(iframeId) {\n\t\t\treturn\t'parent' === settings[iframeId].resizeFrom &&\n\t\t\t\t\tsettings[iframeId].autoResize &&\n\t\t\t\t\t!settings[iframeId].firstRun;\n\t\t}\n\n\t\tfor (var iframeId in settings){\n\t\t\tif(isIFrameResizeEnabled(iframeId)){\n\t\t\t\ttrigger(eventName,event,document.getElementById(iframeId),iframeId);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction setupEventListeners(){\n\t\taddEventListener(window,'message',iFrameListener);\n\n\t\taddEventListener(window,'resize', function(){resizeIFrames('resize');});\n\n\t\taddEventListener(document,'visibilitychange',tabVisible);\n\t\taddEventListener(document,'-webkit-visibilitychange',tabVisible); //Andriod 4.4\n\t\taddEventListener(window,'focusin',function(){resizeIFrames('focus');}); //IE8-9\n\t\taddEventListener(window,'focus',function(){resizeIFrames('focus');});\n\t}\n\n\n\tfunction factory(){\n\t\tfunction init(options,element){\n\t\t\tfunction chkType(){\n\t\t\t\tif(!element.tagName) {\n\t\t\t\t\tthrow new TypeError('Object is not a valid DOM element');\n\t\t\t\t} else if ('IFRAME' !== element.tagName.toUpperCase()) {\n\t\t\t\t\tthrow new TypeError('Expected <IFRAME> tag, found <'+element.tagName+'>');\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif(element) {\n\t\t\t\tchkType();\n\t\t\t\tsetupIFrame(element, options);\n\t\t\t\tiFrames.push(element);\n\t\t\t}\n\t\t}\n\n\t\tvar iFrames;\n\n\t\tsetupRequestAnimationFrame();\n\t\tsetupEventListeners();\n\n\t\treturn function iFrameResizeF(options,target){\n\t\t\tiFrames = []; //Only return iFrames past in on this call\n\n\t\t\tswitch (typeof(target)){\n\t\t\tcase 'undefined':\n\t\t\tcase 'string':\n\t\t\t\tArray.prototype.forEach.call(\n\t\t\t\t\tdocument.querySelectorAll( target || 'iframe' ),\n\t\t\t\t\tinit.bind(undefined, options)\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase 'object':\n\t\t\t\tinit(options,target);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new TypeError('Unexpected data type ('+typeof(target)+')');\n\t\t\t}\n\n\t\t\treturn iFrames;\n\t\t};\n\t}\n\n\tfunction createJQueryPublicMethod($){\n\t\tif (!$.fn) {\n\t\t\tinfo('','Unable to bind to jQuery, it is not fully loaded.');\n\t\t} else {\n\t\t\t$.fn.iFrameResize = function $iFrameResizeF(options) {\n\t\t\t\tfunction init(index, element) {\n\t\t\t\t\tsetupIFrame(element, options);\n\t\t\t\t}\n\n\t\t\t\treturn this.filter('iframe').each(init).end();\n\t\t\t};\n\t\t}\n\t}\n\n\tif (window.jQuery) { createJQueryPublicMethod(jQuery); }\n\n\tif (typeof define === 'function' && define.amd) {\n\t\tdefine([],factory);\n\t} else if (typeof module === 'object' && typeof module.exports === 'object') { //Node for browserfy\n\t\tmodule.exports = factory();\n\t} else {\n\t\twindow.iFrameResize = window.iFrameResize || factory();\n\t}\n\n})(window || {});\n"]}
\ No newline at end of file diff --git a/libs/bower_components/iframe-resizer/js/iframeResizer.min.js b/libs/bower_components/iframe-resizer/js/iframeResizer.min.js new file mode 100644 index 0000000000..40e2ec4798 --- /dev/null +++ b/libs/bower_components/iframe-resizer/js/iframeResizer.min.js @@ -0,0 +1,9 @@ +/*! iFrame Resizer (iframeSizer.min.js ) - v3.5.5 - 2016-06-16 + * Desc: Force cross domain iframes to size to content. + * Requires: iframeResizer.contentWindow.min.js to be loaded into the target frame. + * Copyright: (c) 2016 David J. Bradshaw - dave@bradshaw.net + * License: MIT + */ + +!function(a){"use strict";function b(b,c,d){"addEventListener"in a?b.addEventListener(c,d,!1):"attachEvent"in a&&b.attachEvent("on"+c,d)}function c(b,c,d){"removeEventListener"in a?b.removeEventListener(c,d,!1):"detachEvent"in a&&b.detachEvent("on"+c,d)}function d(){var b,c=["moz","webkit","o","ms"];for(b=0;b<c.length&&!N;b+=1)N=a[c[b]+"RequestAnimationFrame"];N||h("setup","RequestAnimationFrame not supported")}function e(b){var c="Host page: "+b;return a.top!==a.self&&(c=a.parentIFrame&&a.parentIFrame.getId?a.parentIFrame.getId()+": "+b:"Nested host page: "+b),c}function f(a){return K+"["+e(a)+"]"}function g(a){return P[a]?P[a].log:G}function h(a,b){k("log",a,b,g(a))}function i(a,b){k("info",a,b,g(a))}function j(a,b){k("warn",a,b,!0)}function k(b,c,d,e){!0===e&&"object"==typeof a.console&&console[b](f(c),d)}function l(d){function e(){function a(){s(V),p(W)}g("Height"),g("Width"),t(a,V,"init")}function f(){var a=U.substr(L).split(":");return{iframe:P[a[0]].iframe,id:a[0],height:a[1],width:a[2],type:a[3]}}function g(a){var b=Number(P[W]["max"+a]),c=Number(P[W]["min"+a]),d=a.toLowerCase(),e=Number(V[d]);h(W,"Checking "+d+" is in range "+c+"-"+b),c>e&&(e=c,h(W,"Set "+d+" to min value")),e>b&&(e=b,h(W,"Set "+d+" to max value")),V[d]=""+e}function k(){function a(){function a(){var a=0,d=!1;for(h(W,"Checking connection is from allowed list of origins: "+c);a<c.length;a++)if(c[a]===b){d=!0;break}return d}function d(){var a=P[W].remoteHost;return h(W,"Checking connection is from: "+a),b===a}return c.constructor===Array?a():d()}var b=d.origin,c=P[W].checkOrigin;if(c&&""+b!="null"&&!a())throw new Error("Unexpected message received from: "+b+" for "+V.iframe.id+". Message was: "+d.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return!0}function l(){return K===(""+U).substr(0,L)&&U.substr(L).split(":")[0]in P}function w(){var a=V.type in{"true":1,"false":1,undefined:1};return a&&h(W,"Ignoring init message from meta parent page"),a}function y(a){return U.substr(U.indexOf(":")+J+a)}function z(a){h(W,"MessageCallback passed: {iframe: "+V.iframe.id+", message: "+a+"}"),N("messageCallback",{iframe:V.iframe,message:JSON.parse(a)}),h(W,"--")}function A(){var b=document.body.getBoundingClientRect(),c=V.iframe.getBoundingClientRect();return JSON.stringify({iframeHeight:c.height,iframeWidth:c.width,clientHeight:Math.max(document.documentElement.clientHeight,a.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,a.innerWidth||0),offsetTop:parseInt(c.top-b.top,10),offsetLeft:parseInt(c.left-b.left,10),scrollTop:a.pageYOffset,scrollLeft:a.pageXOffset})}function B(a,b){function c(){u("Send Page Info","pageInfo:"+A(),a,b)}x(c,32)}function C(){function d(b,c){function d(){P[g]?B(P[g].iframe,g):e()}["scroll","resize"].forEach(function(e){h(g,b+e+" listener for sendPageInfo"),c(a,e,d)})}function e(){d("Remove ",c)}function f(){d("Add ",b)}var g=W;f(),P[g].stopPageInfo=e}function D(){P[W]&&P[W].stopPageInfo&&(P[W].stopPageInfo(),delete P[W].stopPageInfo)}function E(){var a=!0;return null===V.iframe&&(j(W,"IFrame ("+V.id+") not found"),a=!1),a}function F(a){var b=a.getBoundingClientRect();return o(W),{x:Math.floor(Number(b.left)+Number(M.x)),y:Math.floor(Number(b.top)+Number(M.y))}}function G(b){function c(){M=g,H(),h(W,"--")}function d(){return{x:Number(V.width)+f.x,y:Number(V.height)+f.y}}function e(){a.parentIFrame?a.parentIFrame["scrollTo"+(b?"Offset":"")](g.x,g.y):j(W,"Unable to scroll to requested position, window.parentIFrame not found")}var f=b?F(V.iframe):{x:0,y:0},g=d();h(W,"Reposition requested from iFrame (offset x:"+f.x+" y:"+f.y+")"),a.top!==a.self?e():c()}function H(){!1!==N("scrollCallback",M)?p(W):q()}function I(b){function c(){var a=F(g);h(W,"Moving to in page link (#"+e+") at x: "+a.x+" y: "+a.y),M={x:a.x,y:a.y},H(),h(W,"--")}function d(){a.parentIFrame?a.parentIFrame.moveToAnchor(e):h(W,"In page link #"+e+" not found and window.parentIFrame not found")}var e=b.split("#")[1]||"",f=decodeURIComponent(e),g=document.getElementById(f)||document.getElementsByName(f)[0];g?c():a.top!==a.self?d():h(W,"In page link #"+e+" not found")}function N(a,b){return m(W,a,b)}function O(){switch(P[W].firstRun&&T(),V.type){case"close":n(V.iframe);break;case"message":z(y(6));break;case"scrollTo":G(!1);break;case"scrollToOffset":G(!0);break;case"pageInfo":B(P[W].iframe,W),C();break;case"pageInfoStop":D();break;case"inPageLink":I(y(9));break;case"reset":r(V);break;case"init":e(),N("initCallback",V.iframe),N("resizedCallback",V);break;default:e(),N("resizedCallback",V)}}function Q(a){var b=!0;return P[a]||(b=!1,j(V.type+" No settings for "+a+". Message was: "+U)),b}function S(){for(var a in P)u("iFrame requested init",v(a),document.getElementById(a),a)}function T(){P[W].firstRun=!1}var U=d.data,V={},W=null;"[iFrameResizerChild]Ready"===U?S():l()?(V=f(),W=R=V.id,!w()&&Q(W)&&(h(W,"Received: "+U),E()&&k()&&O())):i(W,"Ignored: "+U)}function m(a,b,c){var d=null,e=null;if(P[a]){if(d=P[a][b],"function"!=typeof d)throw new TypeError(b+" on iFrame["+a+"] is not a function");e=d(c)}return e}function n(a){var b=a.id;h(b,"Removing iFrame: "+b),a.parentNode.removeChild(a),m(b,"closedCallback",b),h(b,"--"),delete P[b]}function o(b){null===M&&(M={x:void 0!==a.pageXOffset?a.pageXOffset:document.documentElement.scrollLeft,y:void 0!==a.pageYOffset?a.pageYOffset:document.documentElement.scrollTop},h(b,"Get page position: "+M.x+","+M.y))}function p(b){null!==M&&(a.scrollTo(M.x,M.y),h(b,"Set page position: "+M.x+","+M.y),q())}function q(){M=null}function r(a){function b(){s(a),u("reset","reset",a.iframe,a.id)}h(a.id,"Size reset requested by "+("init"===a.type?"host page":"iFrame")),o(a.id),t(b,a,"reset")}function s(a){function b(b){a.iframe.style[b]=a[b]+"px",h(a.id,"IFrame ("+e+") "+b+" set to "+a[b]+"px")}function c(b){H||"0"!==a[b]||(H=!0,h(e,"Hidden iFrame detected, creating visibility listener"),y())}function d(a){b(a),c(a)}var e=a.iframe.id;P[e]&&(P[e].sizeHeight&&d("height"),P[e].sizeWidth&&d("width"))}function t(a,b,c){c!==b.type&&N?(h(b.id,"Requesting animation frame"),N(a)):a()}function u(a,b,c,d){function e(){var e=P[d].targetOrigin;h(d,"["+a+"] Sending msg to iframe["+d+"] ("+b+") targetOrigin: "+e),c.contentWindow.postMessage(K+b,e)}function f(){i(d,"["+a+"] IFrame("+d+") not found"),P[d]&&delete P[d]}function g(){c&&"contentWindow"in c&&null!==c.contentWindow?e():f()}d=d||c.id,P[d]&&g()}function v(a){return a+":"+P[a].bodyMarginV1+":"+P[a].sizeWidth+":"+P[a].log+":"+P[a].interval+":"+P[a].enablePublicMethods+":"+P[a].autoResize+":"+P[a].bodyMargin+":"+P[a].heightCalculationMethod+":"+P[a].bodyBackground+":"+P[a].bodyPadding+":"+P[a].tolerance+":"+P[a].inPageLinks+":"+P[a].resizeFrom+":"+P[a].widthCalculationMethod}function w(a,c){function d(){function b(b){1/0!==P[w][b]&&0!==P[w][b]&&(a.style[b]=P[w][b]+"px",h(w,"Set "+b+" = "+P[w][b]+"px"))}function c(a){if(P[w]["min"+a]>P[w]["max"+a])throw new Error("Value for min"+a+" can not be greater than max"+a)}c("Height"),c("Width"),b("maxHeight"),b("minHeight"),b("maxWidth"),b("minWidth")}function e(){var a=c&&c.id||S.id+F++;return null!==document.getElementById(a)&&(a+=F++),a}function f(b){return R=b,""===b&&(a.id=b=e(),G=(c||{}).log,R=b,h(b,"Added missing iframe ID: "+b+" ("+a.src+")")),b}function g(){h(w,"IFrame scrolling "+(P[w].scrolling?"enabled":"disabled")+" for "+w),a.style.overflow=!1===P[w].scrolling?"hidden":"auto",a.scrolling=!1===P[w].scrolling?"no":"yes"}function i(){("number"==typeof P[w].bodyMargin||"0"===P[w].bodyMargin)&&(P[w].bodyMarginV1=P[w].bodyMargin,P[w].bodyMargin=""+P[w].bodyMargin+"px")}function k(){var b=P[w].firstRun,c=P[w].heightCalculationMethod in O;!b&&c&&r({iframe:a,height:0,width:0,type:"init"})}function l(){Function.prototype.bind&&(P[w].iframe.iFrameResizer={close:n.bind(null,P[w].iframe),resize:u.bind(null,"Window resize","resize",P[w].iframe),moveToAnchor:function(a){u("Move to anchor","moveToAnchor:"+a,P[w].iframe,w)},sendMessage:function(a){a=JSON.stringify(a),u("Send Message","message:"+a,P[w].iframe,w)}})}function m(c){function d(){u("iFrame.onload",c,a),k()}b(a,"load",d),u("init",c,a)}function o(a){if("object"!=typeof a)throw new TypeError("Options is not an object")}function p(a){for(var b in S)S.hasOwnProperty(b)&&(P[w][b]=a.hasOwnProperty(b)?a[b]:S[b])}function q(a){return""===a||"file://"===a?"*":a}function s(b){b=b||{},P[w]={firstRun:!0,iframe:a,remoteHost:a.src.split("/").slice(0,3).join("/")},o(b),p(b),P[w].targetOrigin=!0===P[w].checkOrigin?q(P[w].remoteHost):"*"}function t(){return w in P&&"iFrameResizer"in a}var w=f(a.id);t()?j(w,"Ignored iFrame, already setup."):(s(c),g(),d(),i(),m(v(w)),l())}function x(a,b){null===Q&&(Q=setTimeout(function(){Q=null,a()},b))}function y(){function b(){function a(a){function b(b){return"0px"===P[a].iframe.style[b]}function c(a){return null!==a.offsetParent}c(P[a].iframe)&&(b("height")||b("width"))&&u("Visibility change","resize",P[a].iframe,a)}for(var b in P)a(b)}function c(a){h("window","Mutation observed: "+a[0].target+" "+a[0].type),x(b,16)}function d(){var a=document.querySelector("body"),b={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0},d=new e(c);d.observe(a,b)}var e=a.MutationObserver||a.WebKitMutationObserver;e&&d()}function z(a){function b(){B("Window "+a,"resize")}h("window","Trigger event: "+a),x(b,16)}function A(){function a(){B("Tab Visable","resize")}"hidden"!==document.visibilityState&&(h("document","Trigger event: Visiblity change"),x(a,16))}function B(a,b){function c(a){return"parent"===P[a].resizeFrom&&P[a].autoResize&&!P[a].firstRun}for(var d in P)c(d)&&u(a,b,document.getElementById(d),d)}function C(){b(a,"message",l),b(a,"resize",function(){z("resize")}),b(document,"visibilitychange",A),b(document,"-webkit-visibilitychange",A),b(a,"focusin",function(){z("focus")}),b(a,"focus",function(){z("focus")})}function D(){function a(a,c){function d(){if(!c.tagName)throw new TypeError("Object is not a valid DOM element");if("IFRAME"!==c.tagName.toUpperCase())throw new TypeError("Expected <IFRAME> tag, found <"+c.tagName+">")}c&&(d(),w(c,a),b.push(c))}var b;return d(),C(),function(c,d){switch(b=[],typeof d){case"undefined":case"string":Array.prototype.forEach.call(document.querySelectorAll(d||"iframe"),a.bind(void 0,c));break;case"object":a(c,d);break;default:throw new TypeError("Unexpected data type ("+typeof d+")")}return b}}function E(a){a.fn?a.fn.iFrameResize=function(a){function b(b,c){w(c,a)}return this.filter("iframe").each(b).end()}:i("","Unable to bind to jQuery, it is not fully loaded.")}var F=0,G=!1,H=!1,I="message",J=I.length,K="[iFrameSizer]",L=K.length,M=null,N=a.requestAnimationFrame,O={max:1,scroll:1,bodyScroll:1,documentElementScroll:1},P={},Q=null,R="Host Page",S={autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"bodyOffset",id:"iFrameResizer",interval:32,log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,resizeFrom:"parent",scrolling:!1,sizeHeight:!0,sizeWidth:!1,tolerance:0,widthCalculationMethod:"scroll",closedCallback:function(){},initCallback:function(){},messageCallback:function(){j("MessageCallback function not defined")},resizedCallback:function(){},scrollCallback:function(){return!0}};a.jQuery&&E(jQuery),"function"==typeof define&&define.amd?define([],D):"object"==typeof module&&"object"==typeof module.exports?module.exports=D():a.iFrameResize=a.iFrameResize||D()}(window||{}); +//# sourceMappingURL=iframeResizer.map
\ No newline at end of file diff --git a/libs/bower_components/iframe-resizer/js/index.js b/libs/bower_components/iframe-resizer/js/index.js new file mode 100644 index 0000000000..a9cb2845e2 --- /dev/null +++ b/libs/bower_components/iframe-resizer/js/index.js @@ -0,0 +1,2 @@ +exports.iframeResizer = require('./iframeResizer'); +exports.iframeResizerContentWindow = require('./iframeResizer.contentWindow'); diff --git a/libs/bower_components/iframe-resizer/karma.conf.js b/libs/bower_components/iframe-resizer/karma.conf.js new file mode 100644 index 0000000000..3e558511e6 --- /dev/null +++ b/libs/bower_components/iframe-resizer/karma.conf.js @@ -0,0 +1,92 @@ +// Karma configuration +// Generated on Tue Aug 25 2015 12:11:48 GMT+0100 (BST) + +module.exports = function(config) { + config.set({ + + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '', + + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['jasmine-jquery', 'jasmine', 'requirejs'], + + // Karma will require() these plugins + /* + plugins: [ + 'logcapture', + 'karma-verbose-summary-reporter', + 'karma-jasmine', + 'karma-chrome-launcher' + ], + */ + + // list of files / patterns to load in the browser + files: [ + 'test-main.js', + 'spec/lib/*.js', + 'js/ie8.polyfils.min.js', + {pattern: 'js/*.js', included: false}, + {pattern: 'src/*.js', included: false}, + {pattern: 'example/*.html', included: false}, + {pattern: 'spec/*Spec.js', included: false}, + {pattern: 'spec/resources/*', included: false}, + {pattern: 'spec/javascripts/fixtures/*.html', included: false} + ], + + + // list of files to exclude + exclude: [ + ], + + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + 'src/*.js': ['coverage'] + }, + + coverageReporter: { + type : 'html', + dir : 'coverage/' + }, + + client: { + captureConsole: true + }, + + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['logcapture', 'progress', 'verbose-summary', 'coverage'], + + + // web server port + port: 9876, + + + // enable / disable colors in the output (reporters and logs) + colors: true, + + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: true, + + + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: [ ], //'Chrome', 'Firefox', 'Safari', 'PhantomJS' + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: true + + }) +} diff --git a/libs/bower_components/iframe-resizer/src/ie8.polyfils.js b/libs/bower_components/iframe-resizer/src/ie8.polyfils.js new file mode 100644 index 0000000000..43dbb13d21 --- /dev/null +++ b/libs/bower_components/iframe-resizer/src/ie8.polyfils.js @@ -0,0 +1,64 @@ +/* + * IE8 Polyfils for iframeResizer.js + * + * Public domain code - Mozilla Contributors + * https://developer.mozilla.org/ + */ + + if (!Array.prototype.forEach){ + Array.prototype.forEach = function(fun /*, thisArg */){ + "use strict"; + if (this === void 0 || this === null || typeof fun !== "function") throw new TypeError(); + + var + t = Object(this), + len = t.length >>> 0, + thisArg = arguments.length >= 2 ? arguments[1] : void 0; + + for (var i = 0; i < len; i++) + if (i in t) + fun.call(thisArg, t[i], i, t); + }; +} + + +if (!Function.prototype.bind) { + Function.prototype.bind = function(oThis) { + if (typeof this !== 'function') { + // closest thing possible to the ECMAScript 5 + // internal IsCallable function + throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable'); + } + + var aArgs = Array.prototype.slice.call(arguments, 1), + fToBind = this, + fNOP = function() {}, + fBound = function() { + return fToBind.apply(this instanceof fNOP ? this : oThis, + aArgs.concat(Array.prototype.slice.call(arguments))); + }; + + fNOP.prototype = this.prototype; + fBound.prototype = new fNOP(); + + return fBound; + }; +} + +if (!Array.prototype.forEach) { + Array.prototype.forEach = function(callback, thisArg) { + if (this === null) throw new TypeError(' this is null or not defined'); + if (typeof callback !== 'function') throw new TypeError(callback + ' is not a function'); + + var + O = Object(this), + len = O.length >>> 0; + + for (var k=0 ; k < len ; k++) { + if (k in O) + callback.call(thisArg, O[k], k, O); + } + }; +} + + diff --git a/libs/bower_components/iframe-resizer/src/iframeResizer.contentWindow.js b/libs/bower_components/iframe-resizer/src/iframeResizer.contentWindow.js new file mode 100644 index 0000000000..02d2602d8d --- /dev/null +++ b/libs/bower_components/iframe-resizer/src/iframeResizer.contentWindow.js @@ -0,0 +1,1123 @@ +/* + * 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(); + + // TEST CODE START // + + //Create test hooks + + function mockMsgListener(msgObject){ + receiver(msgObject); + return win; + } + + win={}; + + removeEventListener(window, 'message', receiver); + + define([], function() {return mockMsgListener;}); + + // TEST CODE END // + +})(window || {}); diff --git a/libs/bower_components/iframe-resizer/src/iframeResizer.js b/libs/bower_components/iframe-resizer/src/iframeResizer.js new file mode 100644 index 0000000000..897a632ce4 --- /dev/null +++ b/libs/bower_components/iframe-resizer/src/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 (size<min) { + size=min; + log(iframeId,'Set ' + dimension + ' to min value'); + } + + if (size>max) { + 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 <IFRAME> tag, found <'+element.tagName+'>'); + } + } + + if(element) { + chkType(); + setupIFrame(element, options); + iFrames.push(element); + } + } + + var iFrames; + + setupRequestAnimationFrame(); + setupEventListeners(); + + return function iFrameResizeF(options,target){ + iFrames = []; //Only return iFrames past in on this call + + switch (typeof(target)){ + case 'undefined': + case 'string': + Array.prototype.forEach.call( + document.querySelectorAll( target || 'iframe' ), + init.bind(undefined, options) + ); + break; + case 'object': + init(options,target); + break; + default: + throw new TypeError('Unexpected data type ('+typeof(target)+')'); + } + + return iFrames; + }; + } + + function createJQueryPublicMethod($){ + if (!$.fn) { + info('','Unable to bind to jQuery, it is not fully loaded.'); + } else { + $.fn.iFrameResize = function $iFrameResizeF(options) { + function init(index, element) { + setupIFrame(element, options); + } + + return this.filter('iframe').each(init).end(); + }; + } + } + + if (window.jQuery) { createJQueryPublicMethod(jQuery); } + + if (typeof define === 'function' && define.amd) { + define([],factory); + } else if (typeof module === 'object' && typeof module.exports === 'object') { //Node for browserfy + module.exports = factory(); + } else { + window.iFrameResize = window.iFrameResize || factory(); + } + +})(window || {}); diff --git a/libs/bower_components/iframe-resizer/test-main.js b/libs/bower_components/iframe-resizer/test-main.js new file mode 100644 index 0000000000..1abfe13131 --- /dev/null +++ b/libs/bower_components/iframe-resizer/test-main.js @@ -0,0 +1,33 @@ +var allTestFiles = []; + +var TEST_REGEXP = /(spec|test)\.js$/i; + +// Get a list of all the test files to include +Object.keys(window.__karma__.files).forEach(function(file) { + if (TEST_REGEXP.test(file)) { + // Normalize paths to RequireJS module names. + // If you require sub-dependencies of test files to be loaded as-is (requiring file extension) + // then do not normalize the paths + var normalizedTestModule = file.replace(/^\/base\/|\.js$/g, ''); + allTestFiles.push(normalizedTestModule); + } +}); + +require.config({ + // Karma serves files under /base, which is the basePath from your config file + baseUrl: '/base', + + paths: { + jquery : 'node_modules/jquery/dist/jquery', + iframeResizerMin : 'js/iframeResizer.min', + iframeResizer : 'src/iframeResizer', + iframeResizerContentMin : 'js/iframeResizer.contentWindow.min', + iframeResizerContent : 'src/iframeResizer.contentWindow' + }, + + // dynamically load all test files + deps: allTestFiles, + + // we have to kickoff jasmine, as it is asynchronous + callback: window.__karma__.start +}); |