diff --git a/formio/CHANGELOG.md b/formio/CHANGELOG.md index ff21dade..06e1fdb1 100644 --- a/formio/CHANGELOG.md +++ b/formio/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## 11.1 + +Solve Form height resizing issues, by applying the iFrame Resizer `bodyMargin` option.\ +Eg. ensure the rendering of select component at the bottom of a Form won't break anymore.\ +Issue: [\#20](https://github.com/novacode-nl/odoo-formio/issues/20) + +- Update iFrame Resizer (JS) library to version 4.3.2 (Dec 2021). +- Add configurable `iframe_resizer_body_margin` field in Form Builder, with a (sensible) default value. +- Change Form templates (backend, portal) to apply the configurable iFrame Resizer `bodyMargin`. +- Add callable template `formio.form_iframe` (with options: `src`, `bodyMargin`, `form`), which applies the iFrame Resizer (with fallback on `form` its Form Builder). + ### 11.0 - Add Form (JS) `apiUrl` property (backend, portal, public). diff --git a/formio/__manifest__.py b/formio/__manifest__.py index 9099ce38..3ceafe59 100644 --- a/formio/__manifest__.py +++ b/formio/__manifest__.py @@ -4,7 +4,7 @@ { 'name': 'Forms', 'summary': 'Form Builder & integration of professional and versatile Forms to collect any information you need for your business.', - 'version': '11.0', + 'version': '11.1', 'license': 'LGPL-3', 'author': 'Nova Code', 'website': 'https://www.novacode.nl', diff --git a/formio/models/formio_builder.py b/formio/models/formio_builder.py index 9890110a..1f754d4c 100644 --- a/formio/models/formio_builder.py +++ b/formio/models/formio_builder.py @@ -118,6 +118,10 @@ class Builder(models.Model): show_form_state = fields.Boolean("Show Form State", tracking=True, help="Show the state in the Form header.", default=True) show_form_user_metadata = fields.Boolean( "Show User Metadata", tracking=True, help="Show submission and assigned user metadata in the Form header.", default=True) + iframe_resizer_body_margin = fields.Char( + "iFrame Resizer bodyMargin", default="0px 0px 260px 0px", tracking=True, + help="Override the default body margin style in the iFrame. A string can be any valid value for the CSS margin attribute. A number is converted into px." + ) wizard = fields.Boolean("Wizard", tracking=True) wizard_on_next_page_save_draft = fields.Boolean("Wizard on Next Page Save Draft", tracking=True) submission_url_add_query_params_from = fields.Selection( diff --git a/formio/models/formio_form.py b/formio/models/formio_form.py index 6e09e8ff..80e8da0a 100644 --- a/formio/models/formio_form.py +++ b/formio/models/formio_form.py @@ -106,6 +106,10 @@ class Form(models.Model): show_id = fields.Boolean("Show ID") show_uuid = fields.Boolean("Show UUID") show_user_metadata = fields.Boolean("Show User Metadata") + iframe_resizer_body_margin = fields.Char( + "iFrame Resizer bodyMargin", related="builder_id.iframe_resizer_body_margin", + help="Override the default body margin style in the iFrame. A string can be any valid value for the CSS margin attribute. A number is converted into px." + ) languages = fields.One2many('res.lang', related='builder_id.languages', string='Languages') allow_unlink = fields.Boolean("Allow delete", compute='_compute_access') allow_force_update_state = fields.Boolean("Allow force update State", compute='_compute_access') diff --git a/formio/static/lib/iframe-resizer/LICENSE b/formio/static/lib/iframe-resizer/LICENSE index 0c5dcf98..bfeb6a4b 100644 --- a/formio/static/lib/iframe-resizer/LICENSE +++ b/formio/static/lib/iframe-resizer/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2013-2019 David J. Bradshaw +Copyright (c) 2013-2021 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 diff --git a/formio/static/lib/iframe-resizer/iframeResizer.contentWindow.js b/formio/static/lib/iframe-resizer/iframeResizer.contentWindow.js new file mode 100644 index 00000000..fa7464b6 --- /dev/null +++ b/formio/static/lib/iframe-resizer/iframeResizer.contentWindow.js @@ -0,0 +1,1303 @@ +/* + * 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 + * + */ + +// eslint-disable-next-line sonarjs/cognitive-complexity, no-shadow-restricted-names +;(function (undefined) { + if (typeof window === 'undefined') return // don't run for server side render + + 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, + mouseEvents = false, + msgID = '[iFrameSizer]', // Must match host page msg ID + msgIdLen = msgID.length, + myID = '', + 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, + onMessage = function () { + warn('onMessage function not defined') + }, + onReady = function () {}, + onPageInfo = 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 + } + }, + eventHandlersByName = {}, + passiveSupported = false + + function noop() {} + + try { + var options = Object.create( + {}, + { + passive: { + get: function () { + passiveSupported = true + } + } + } + ) + window.addEventListener('test', noop, options) + window.removeEventListener('test', noop, options) + } catch (error) { + /* */ + } + + function addEventListener(el, evt, func, options) { + el.addEventListener(evt, func, passiveSupported ? options || {} : false) + } + + function removeEventListener(el, evt, func) { + el.removeEventListener(evt, func, false) + } + + 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 = Date.now() + timeout = null + result = func.apply(context, args) + if (!timeout) { + // eslint-disable-next-line no-multi-assign + context = args = null + } + } + + return function () { + var now = Date.now() + + 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) { + // eslint-disable-next-line no-multi-assign + context = args = null + } + } else if (!timeout) { + timeout = setTimeout(later, remaining) + } + + return result + } + } + + function formatLogMsg(msg) { + return msgID + '[' + myID + '] ' + msg + } + + function log(msg) { + if (logging && 'object' === typeof window.console) { + // eslint-disable-next-line no-console + console.log(formatLogMsg(msg)) + } + } + + function warn(msg) { + if ('object' === typeof window.console) { + // eslint-disable-next-line no-console + console.warn(formatLogMsg(msg)) + } + } + + function init() { + readDataFromParent() + log('Initialising iFrame (' + window.location.href + ')') + readDataFromPage() + setMargin() + setBodyStyle('background', bodyBackground) + setBodyStyle('padding', bodyPadding) + injectClearFixIntoBodyElement() + checkHeightMode() + checkWidthMode() + stopInfiniteResizingOfIFrame() + setupPublicMethods() + setupMouseEvents() + startEventListeners() + inPageLinks = setupInPageLinks() + sendSize('init', 'Init message from host page') + onReady() + } + + function readDataFromParent() { + function strBool(str) { + return 'true' === str + } + + 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 + mouseEvents = undefined !== data[15] ? Boolean(data[15]) : mouseEvents + } + + function depricate(key) { + var splitName = key.split('Callback') + + if (splitName.length === 2) { + var name = + 'on' + splitName[0].charAt(0).toUpperCase() + splitName[0].slice(1) + this[name] = this[key] + delete this[key] + warn( + "Deprecated: '" + + key + + "' has been renamed '" + + name + + "'. The old method will be removed in the next major version." + ) + } + } + + function readDataFromPage() { + function readData() { + var data = window.iFrameResizer + + log('Reading data from page: ' + JSON.stringify(data)) + Object.keys(data).forEach(depricate, data) + + onMessage = 'onMessage' in data ? data.onMessage : onMessage + onReady = 'onReady' in data ? data.onReady : onReady + 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) { + var listener = { + add: function (eventName) { + function handleEvent() { + sendSize(options.eventName, options.eventType) + } + + eventHandlersByName[eventName] = handleEvent + + addEventListener(window, eventName, handleEvent, { passive: true }) + }, + remove: function (eventName) { + var handleEvent = eventHandlersByName[eventName] + delete eventHandlersByName[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' + // Guard against the following having been globally redefined in CSS. + clearFix.style.display = 'block' + clearFix.style.height = '0' + 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() { + var hash = window.location.hash + var href = window.location.href + + if ('' !== hash && '#' !== hash) { + findTarget(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 setupMouseEvents() { + if (mouseEvents !== true) return + + function sendMouse(e) { + sendMsg(0, 0, e.type, e.screenY + ':' + e.screenX) + } + + function addMouseListener(evt, name) { + log('Add event listener: ' + name) + addEventListener(window.document, evt, sendMouse) + } + + addMouseListener('mouseenter', 'Mouse Enter') + addMouseListener('mouseleave', 'Mouse Leave') + } + + function setupPublicMethods() { + log('Enable public methods') + + win.parentIFrame = { + autoResize: function autoResizeF(resize) { + if (true === resize && false === autoResize) { + autoResize = true + startEventListeners() + } else if (false === resize && true === autoResize) { + autoResize = false + stopEventListeners() + } + sendMsg(0, 0, 'autoResize', JSON.stringify(autoResize)) + return autoResize + }, + + close: function closeF() { + sendMsg(0, 0, 'close') + // teardown() + }, + + getId: function getIdF() { + return myID + }, + + getPageInfo: function getPageInfoF(callback) { + if ('function' === typeof callback) { + onPageInfo = callback + sendMsg(0, 0, 'pageInfo') + } else { + onPageInfo = 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 || '') + (customWidth ? ',' + customWidth : '') + 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)) + } + } + + // Not testable in PhantomJS + /* istanbul ignore next */ + 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) + } + + 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 / Blink 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 + + // Not testable in PhantomJS + /* istanbul ignore if */ 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) { + var retVal = 0 + el = el || document.body // Not testable in phantonJS + + retVal = document.defaultView.getComputedStyle(el, null) + retVal = null !== retVal ? retVal[prop] : 0 + + 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 = Date.now() + + for (var i = 0; i < elementsLength; i++) { + elVal = + elements[i].getBoundingClientRect()[side] + + getComputedStyle('margin' + Side, elements[i]) + if (elVal > maxVal) { + maxVal = elVal + } + } + + timer = Date.now() - timer + + log('Parsed ' + elementsLength + ' HTML elements') + log('Element position calculated in ' + timer + 'ms') + + chkEventThottle(timer) + + return maxVal + } + + function getAllMeasurements(dimensions) { + return [ + dimensions.bodyOffset(), + dimensions.bodyScroll(), + dimensions.documentElementOffset(), + dimensions.documentElementScroll() + ] + } + + function getTaggedElements(side, tag) { + function noTaggedElementsFound() { + warn('No tagged elements (' + tag + ') found on page') + return document.querySelectorAll('body *') + } + + var elements = document.querySelectorAll('[' + tag + ']') + + if (elements.length === 0) noTaggedElementsFound() + + return 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() || getHeight.documentElementOffset(), + 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() + if (triggerEvent === 'init') { + sizeIFrame(triggerEvent, triggerEventDesc, customHeight, customWidth) + } else { + 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) { + var processRequestFromParent = { + init: function initFromParent() { + initMsg = event.data + target = event.source + + init() + firstRun = false + setTimeout(function () { + initLock = false + }, eventCancelTimer) + }, + + reset: function resetFromParent() { + if (!initLock) { + log('Page size reset by host page') + triggerReset('resetPage') + } else { + log('Page reset ignored by init') + } + }, + + resize: function resizeFromParent() { + sendSize('resizeParent', 'Parent window requested size check') + }, + + moveToAnchor: function moveToAnchorF() { + inPageLinks.findTarget(getData()) + }, + inPageLink: function inPageLinkF() { + this.moveToAnchor() + }, // Backward compatability + + pageInfo: function pageInfoFromParent() { + var msgBody = getData() + log('PageInfoFromParent called from parent: ' + msgBody) + onPageInfo(JSON.parse(msgBody)) + log(' --') + }, + + message: function messageFromParent() { + var msgBody = getData() + + log('onMessage called from parent: ' + msgBody) + // eslint-disable-next-line sonarjs/no-extra-arguments + onMessage(JSON.parse(msgBody)) + log(' --') + } + } + + function isMessageForUs() { + return msgID === ('' + event.data).substr(0, msgIdLen) // ''+ Protects against non-string messages + } + + function getMessageType() { + return event.data.split(']')[1].split(':')[0] + } + + function getData() { + return event.data.substr(event.data.indexOf(':') + 1) + } + + function isMiddleTier() { + return ( + (!(typeof module !== 'undefined' && module.exports) && + 'iFrameResize' in window) || + ('jQuery' in window && 'iFrameResize' in window.jQuery.prototype) + ) + } + + 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() { + var messageType = getMessageType() + + if (messageType in processRequestFromParent) { + processRequestFromParent[messageType]() + } else if (!isMiddleTier() && !isInitMsg()) { + warn('Unexpected message (' + event.data + ')') + } + } + + function processMessage() { + if (false === firstRun) { + callFromParent() + } else if (isInitMsg()) { + processRequestFromParent.init() + } 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) + addEventListener(window, 'readystatechange', chkLateLoaded) + chkLateLoaded() + + +})() diff --git a/formio/static/lib/iframe-resizer/iframeResizer.contentWindow.map b/formio/static/lib/iframe-resizer/iframeResizer.contentWindow.map index 70c46ee0..5a78c6a1 100644 --- a/formio/static/lib/iframe-resizer/iframeResizer.contentWindow.map +++ b/formio/static/lib/iframe-resizer/iframeResizer.contentWindow.map @@ -1 +1 @@ -{"version":3,"sources":["iframeResizer.contentWindow.js"],"names":["undefined","window","autoResize","base","bodyBackground","bodyMargin","bodyMarginStr","bodyObserver","bodyPadding","calculateWidth","doubleEventList","resize","click","eventCancelTimer","firstRun","height","heightCalcModeDefault","heightCalcMode","initLock","initMsg","inPageLinks","interval","intervalTimer","logging","msgID","msgIdLen","length","myID","resetRequiredMethods","max","min","bodyScroll","documentElementScroll","resizeFrom","sendPermit","target","parent","targetOriginDefault","tolerance","triggerLocked","triggerLockedTimer","throttledTimer","width","widthCalcModeDefault","widthCalcMode","win","onMessage","warn","onReady","onPageInfo","customCalcMethods","document","documentElement","offsetHeight","body","scrollWidth","eventHandlersByName","passiveSupported","options","Object","create","passive","get","addEventListener","noop","removeEventListener","error","func","context","args","result","timeout","previous","getNow","Date","now","getTime","getHeight","bodyOffset","getComputedStyle","offset","scrollHeight","custom","documentElementOffset","Math","apply","getAllMeasurements","grow","lowestElement","getMaxElement","getAllElements","taggedElement","getTaggedElements","getWidth","offsetWidth","scroll","rightMostElement","sizeIFrameThrottled","sizeIFrame","remaining","this","arguments","clearTimeout","setTimeout","later","event","processRequestFromParent","init","data","source","reset","log","triggerReset","sendSize","moveToAnchor","findTarget","getData","inPageLink","pageInfo","msgBody","JSON","parse","message","getMessageType","split","substr","indexOf","isInitMsg","true","false","callFromParent","messageType","module","exports","jQuery","prototype","chkLateLoaded","el","evt","capitalizeFirstLetter","string","charAt","toUpperCase","slice","formatLogMsg","msg","console","strBool","str","Number","enable","readDataFromParent","location","href","setupCustomCalcMethods","calcMode","calcFunc","iFrameResizer","constructor","stringify","keys","forEach","depricate","targetOrigin","heightCalculationMethod","widthCalculationMethod","readData","readDataFromPage","setBodyStyle","attr","value","chkCSS","setMargin","clearFix","createElement","style","clear","display","appendChild","injectClearFixIntoBodyElement","checkHeightMode","checkWidthMode","parentIFrame","startEventListeners","manageEventListeners","disconnect","clearInterval","sendMsg","close","getId","getPageInfo","callback","hash","resetIFrame","scrollTo","x","y","scrollToOffset","sendMessage","setHeightCalculationMethod","setWidthCalculationMethod","setTargetOrigin","size","customHeight","customWidth","getElementPosition","elPosition","getBoundingClientRect","pagePosition","pageXOffset","scrollLeft","pageYOffset","scrollTop","parseInt","left","top","jumpPosition","hashData","decodeURIComponent","getElementById","getElementsByName","checkLocationHash","bindAnchors","Array","call","querySelectorAll","getAttribute","e","preventDefault","setupInPageLinks","key","splitName","name","manageTriggerEvent","listener","add","eventName","handleEvent","eventType","remove","eventNames","map","method","checkCalcMode","calcModeDefault","modes","type","forceIntervalTimer","MutationObserver","WebKitMutationObserver","initInterval","addImageLoadListners","mutation","addImageLoadListener","element","complete","src","imageLoaded","imageError","elements","push","attributeName","removeImageLoadListener","splice","removeFromArray","imageEventTriggered","typeDesc","mutationObserved","mutations","observer","querySelector","observe","attributes","attributeOldValue","characterData","characterDataOldValue","childList","subtree","createMutationObserver","setupBodyMutationObserver","setupMutationObserver","setInterval","abs","prop","retVal","defaultView","side","elementsLength","elVal","maxVal","Side","timer","i","chkEventThottle","dimention","tag","triggerEvent","triggerEventDesc","currentHeight","currentWidth","checkTolarance","a","b","lockTrigger","resetPage","hcm","postMessage","readyState"],"mappings":";;;;;;;;CAWC,SAAUA,GACT,GAAsB,oBAAXC,OAAX,CAEA,IAAIC,GAAa,EACfC,EAAO,GACPC,EAAiB,GACjBC,EAAa,EACbC,EAAgB,GAChBC,EAAe,KACfC,EAAc,GACdC,GAAiB,EACjBC,EAAkB,CAAEC,OAAQ,EAAGC,MAAO,GACtCC,EAAmB,IACnBC,GAAW,EACXC,EAAS,EACTC,EAAwB,aACxBC,EAAiBD,EACjBE,GAAW,EACXC,EAAU,GACVC,EAAc,GACdC,EAAW,GACXC,EAAgB,KAChBC,GAAU,EACVC,EAAQ,gBACRC,EAAWD,EAAME,OACjBC,EAAO,GACPC,EAAuB,CACrBC,IAAK,EACLC,IAAK,EACLC,WAAY,EACZC,sBAAuB,GAEzBC,EAAa,QACbC,GAAa,EACbC,EAASlC,OAAOmC,OAChBC,EAAsB,IACtBC,EAAY,EACZC,GAAgB,EAChBC,EAAqB,KACrBC,EAAiB,GACjBC,EAAQ,EACRC,EAAuB,SACvBC,EAAgBD,EAChBE,EAAM5C,OACN6C,EAAY,WACVC,GAAK,mCAEPC,EAAU,aACVC,EAAa,aACbC,EAAoB,CAClBnC,OAAQ,WAEN,OADAgC,GAAK,kDACEI,SAASC,gBAAgBC,cAElCX,MAAO,WAEL,OADAK,GAAK,iDACEI,SAASG,KAAKC,cAGzBC,EAAsB,GACtBC,GAAmB,EAIrB,IACE,IAAIC,EAAUC,OAAOC,OACnB,GACA,CACEC,QAAS,CACPC,IAAK,WACHL,GAAmB,MAK3BxD,OAAO8D,iBAAiB,OAAQC,GAAMN,GACtCzD,OAAOgE,oBAAoB,OAAQD,GAAMN,GACzC,MAAOQ,IAkET,IAjDkBC,EACZC,EACFC,EACAC,EACAC,EACAC,EA4CAC,EACFC,KAAKC,KACL,WAEE,OAAO,IAAID,MAAOE,WA4vBlBC,EAAY,CACZC,WAAY,WACV,OACE3B,SAASG,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hE,GAAgB,EAChBwE,GAAI,0BACJA,GAAI,OACHlG,GAGL,SAASmG,GAAawL,GACpBzR,EAAS8D,EAAU5D,KACnByB,EAAQmD,EAASjD,KAEjB+I,GAAQ5K,EAAQ2B,EAAO8P,GAGzB,SAASvG,GAAYwG,GACnB,IAAIQ,EAAMhS,EACVA,EAAiBD,EAEjB+F,GAAI,wBAA0B0L,GAC9BM,KACA/L,GAAa,SAEb/F,EAAiBgS,EAGnB,SAAStH,GAAQ5K,EAAQ2B,EAAO8P,EAAcvJ,EAAKkB,GASjD,IAEIzC,GAYA,IAASxF,IArBPlC,IAAcmK,EAChBA,EAAe9H,EAEf0E,GAAI,yBAA2BoD,GAcjCpD,GAAI,kCARFW,EACE/F,EACA,KAHOZ,EAAS,IAAM2B,GAKtB,IACA8P,GACCxS,IAAciJ,EAAM,IAAMA,EAAM,KAEY,KACjD9G,EAAO+Q,YAAY1R,EAAQkG,EAASyC,IAoHxC,SAAS3B,KACH,YAAcrF,SAASgQ,YACzBlT,OAAOmC,OAAO8Q,YAAY,4BAA6B,MAnvC5D","file":"iframeResizer.contentWindow.min.js"} \ No newline at end of file +{"version":3,"file":"iframeResizer.contentWindow.min.js","sources":["iframeResizer.contentWindow.js"],"names":["undefined","window","autoResize","base","bodyBackground","bodyMargin","bodyMarginStr","bodyObserver","bodyPadding","calculateWidth","doubleEventList","resize","click","eventCancelTimer","firstRun","height","heightCalcModeDefault","heightCalcMode","initLock","initMsg","inPageLinks","interval","intervalTimer","logging","mouseEvents","msgID","msgIdLen","length","myID","resetRequiredMethods","max","min","bodyScroll","documentElementScroll","resizeFrom","sendPermit","target","parent","targetOriginDefault","tolerance","triggerLocked","triggerLockedTimer","throttledTimer","width","widthCalcModeDefault","widthCalcMode","win","onMessage","warn","onReady","onPageInfo","customCalcMethods","document","documentElement","offsetHeight","body","scrollWidth","eventHandlersByName","passiveSupported","options","Object","create","passive","get","addEventListener","noop","removeEventListener","error","func","context","args","result","timeout","previous","getHeight","bodyOffset","getComputedStyle","offset","scrollHeight","custom","documentElementOffset","Math","apply","getAllMeasurements","grow","lowestElement","getMaxElement","getAllElements","taggedElement","getTaggedElements","getWidth","offsetWidth","scroll","rightMostElement","sizeIFrameThrottled","sizeIFrame","now","Date","remaining","this","arguments","clearTimeout","setTimeout","later","event","processRequestFromParent","init","data","source","reset","log","triggerReset","sendSize","moveToAnchor","findTarget","getData","inPageLink","pageInfo","msgBody","JSON","parse","message","getMessageType","split","substr","indexOf","isInitMsg","true","false","callFromParent","messageType","module","exports","jQuery","prototype","chkLateLoaded","el","evt","capitalizeFirstLetter","string","charAt","toUpperCase","slice","formatLogMsg","msg","console","strBool","str","clearFix","sendMouse","e","sendMsg","type","screenY","screenX","addMouseListener","name","Number","enable","Boolean","location","href","setupCustomCalcMethods","calcMode","calcFunc","iFrameResizer","constructor","stringify","keys","forEach","depricate","targetOrigin","heightCalculationMethod","widthCalculationMethod","readData","readDataFromPage","setBodyStyle","attr","value","chkCSS","setMargin","createElement","style","clear","display","appendChild","checkHeightMode","checkWidthMode","parentIFrame","startEventListeners","manageEventListeners","disconnect","clearInterval","close","getId","getPageInfo","callback","hash","resetIFrame","scrollTo","x","y","scrollToOffset","sendMessage","setHeightCalculationMethod","setWidthCalculationMethod","setTargetOrigin","size","customHeight","customWidth","getElementPosition","elPosition","getBoundingClientRect","pagePosition","pageXOffset","scrollLeft","pageYOffset","scrollTop","parseInt","left","top","hashData","decodeURIComponent","getElementById","getElementsByName","jumpPosition","checkLocationHash","bindAnchors","Array","call","querySelectorAll","getAttribute","preventDefault","enableInPageLinks","setupInPageLinks","key","splitName","manageTriggerEvent","listener","add","eventName","handleEvent","eventType","remove","eventNames","map","method","checkCalcMode","calcModeDefault","modes","forceIntervalTimer","MutationObserver","WebKitMutationObserver","initInterval","addImageLoadListners","mutation","addImageLoadListener","element","complete","src","imageLoaded","imageError","elements","push","attributeName","removeImageLoadListener","splice","imageEventTriggered","typeDesc","mutationObserved","mutations","observer","querySelector","observe","attributes","attributeOldValue","characterData","characterDataOldValue","childList","subtree","createMutationObserver","setupBodyMutationObserver","setInterval","abs","prop","retVal","defaultView","side","elVal","elementsLength","maxVal","Side","timer","i","dimensions","tag","triggerEvent","triggerEventDesc","checkDownSizing","currentHeight","currentWidth","checkTolarance","a","b","lockTrigger","resetPage","hcm","postMessage","readyState"],"mappings":";;;;;;;;CAWC,SAAWA,GACV,GAAsB,oBAAXC,OAAX,CAEA,IAAIC,GAAa,EACfC,EAAO,GACPC,EAAiB,GACjBC,EAAa,EACbC,EAAgB,GAChBC,EAAe,KACfC,EAAc,GACdC,GAAiB,EACjBC,EAAkB,CAAEC,OAAQ,EAAGC,MAAO,GACtCC,EAAmB,IACnBC,GAAW,EACXC,EAAS,EACTC,EAAwB,aACxBC,EAAiBD,EACjBE,GAAW,EACXC,EAAU,GACVC,EAAc,GACdC,EAAW,GACXC,EAAgB,KAChBC,GAAU,EACVC,GAAc,EACdC,EAAQ,gBACRC,EAAWD,EAAME,OACjBC,EAAO,GACPC,EAAuB,CACrBC,IAAK,EACLC,IAAK,EACLC,WAAY,EACZC,sBAAuB,GAEzBC,EAAa,QACbC,GAAa,EACbC,EAASnC,OAAOoC,OAChBC,EAAsB,IACtBC,EAAY,EACZC,GAAgB,EAChBC,EAAqB,KACrBC,EAAiB,GACjBC,EAAQ,EACRC,EAAuB,SACvBC,EAAgBD,EAChBE,EAAM7C,OACN8C,EAAY,WACVC,GAAK,mCAEPC,EAAU,aACVC,EAAa,aACbC,EAAoB,CAClBpC,OAAQ,WAEN,OADAiC,GAAK,kDACEI,SAASC,gBAAgBC,cAElCX,MAAO,WAEL,OADAK,GAAK,iDACEI,SAASG,KAAKC,cAGzBC,EAAsB,GACtBC,GAAmB,EAIrB,IACE,IAAIC,EAAUC,OAAOC,OACnB,GACA,CACEC,QAAS,CACPC,IAAK,WACHL,GAAmB,MAK3BzD,OAAO+D,iBAAiB,OAAQC,GAAMN,GACtC1D,OAAOiE,oBAAoB,OAAQD,GAAMN,GACzC,M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B,KAAKD,MAChBxB,EAAU,KACVD,EAASH,EAAKc,MAAMb,EAASC,GACxBE,IAEHH,EAAUC,EAAO,MAk9BzB,SAAS0C,GAASwL,EAAcC,EAAkBzF,EAAcC,GAQrDzK,GAAiBgQ,KAAgB9R,EAgBxCoG,GAAI,4BAA8B0L,IAtB5BA,IAAgB,CAAE3L,MAAO,EAAGoM,UAAW,EAAGvM,KAAM,IACpDI,GAAI,kBAAoB2L,IAUL,SAAjBD,EACFzM,GAEAD,GAFW0M,EAAcC,EAAkBzF,EAAcC,IAc/D,SAAS+F,KACFxQ,IACHA,GAAgB,EAChBsE,GAAI,0BAENT,aAAa5D,GACbA,EAAqB6D,WAAW,WAC9B9D,GAAgB,EAChBsE,GAAI,0BACJA,GAAI,OACHjG,GAGL,SAASkG,GAAayL,GACpBzR,EAAS2D,EAAUzD,KACnB0B,EAAQ+C,EAAS7C,KAEjB0G,GAAQxI,EAAQ4B,EAAO6P,GAGzB,SAASlG,GAAYmG,GACnB,IAAIS,EAAMjS,EACVA,EAAiBD,EAEjB8F,GAAI,wBAA0B2L,GAC9BO,KACAjM,GAAa,SAEb9F,EAAiBiS,EAGnB,SAAS3J,GAAQxI,EAAQ4B,EAAO6P,EAAcxJ,EAAK2B,GASjD,IAEIlD,GAYA,IAAStF,IArBPnC,IAAc2K,EAChBA,EAAerI,EAEfwE,GAAI,yBAA2B6D,GAcjC7D,GAAI,kCARFW,EACE7F,EACA,KAHOb,EAAS,IAAM4B,GAKtB,IACA6P,GACCxS,IAAcgJ,EAAM,IAAMA,EAAM,KAEY,KACjD5G,EAAO+Q,YAAY1R,EAAQgG,EAASkD,IAoHxC,SAASpC,KACH,YAAcnF,SAASgQ,YACzBnT,OAAOoC,OAAO8Q,YAAY,4BAA6B,MAlwC5D"} \ No newline at end of file diff --git a/formio/static/lib/iframe-resizer/iframeResizer.contentWindow.min.js b/formio/static/lib/iframe-resizer/iframeResizer.contentWindow.min.js index 2972853c..a25e5818 100644 --- a/formio/static/lib/iframe-resizer/iframeResizer.contentWindow.min.js +++ b/formio/static/lib/iframe-resizer/iframeResizer.contentWindow.min.js @@ -1,10 +1,10 @@ -/*! iFrame Resizer (iframeSizer.contentWindow.min.js) - v4.2.9 - 2019-12-30 +/*! iFrame Resizer (iframeSizer.contentWindow.min.js) - v4.3.2 - 2021-04-26 * 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) 2019 David J. Bradshaw - dave@bradshaw.net + * Copyright: (c) 2021 David J. Bradshaw - dave@bradshaw.net * License: MIT */ -!function(d){if("undefined"!=typeof window){var n=!0,o=10,i="",r=0,a="",t=null,u="",c=!1,s={resize:1,click:1},l=128,f=!0,m=1,h="bodyOffset",g=h,p=!0,v="",y={},b=32,w=null,T=!1,E="[iFrameSizer]",O=E.length,S="",M={max:1,min:1,bodyScroll:1,documentElementScroll:1},I="child",N=!0,A=window.parent,C="*",z=0,k=!1,e=null,R=16,x=1,L="scroll",F=L,P=window,D=function(){re("onMessage function not defined")},j=function(){},q=function(){},H={height:function(){return re("Custom height calculation function not defined"),document.documentElement.offsetHeight},width:function(){return re("Custom width calculation function not defined"),document.body.scrollWidth}},W={},B=!1;try{var J=Object.create({},{passive:{get:function(){B=!0}}});window.addEventListener("test",ee,J),window.removeEventListener("test",ee,J)}catch(e){}var U,V,K,Q,X,Y,G=Date.now||function(){return(new Date).getTime()},Z={bodyOffset:function(){return document.body.offsetHeight+pe("marginTop")+pe("marginBottom")},offset:function(){return Z.bodyOffset()},bodyScroll:function(){return document.body.scrollHeight},custom:function(){return H.height()},documentElementOffset:function(){return document.documentElement.offsetHeight},documentElementScroll:function(){return document.documentElement.scrollHeight},max:function(){return Math.max.apply(null,ye(Z))},min:function(){return Math.min.apply(null,ye(Z))},grow:function(){return Z.max()},lowestElement:function(){return Math.max(Z.bodyOffset()||Z.documentElementOffset(),ve("bottom",we()))},taggedElement:function(){return be("bottom","data-iframe-height")}},$={bodyScroll:function(){return document.body.scrollWidth},bodyOffset:function(){return document.body.offsetWidth},custom:function(){return H.width()},documentElementScroll:function(){return document.documentElement.scrollWidth},documentElementOffset:function(){return document.documentElement.offsetWidth},scroll:function(){return Math.max($.bodyScroll(),$.documentElementScroll())},max:function(){return Math.max.apply(null,ye($))},min:function(){return Math.min.apply(null,ye($))},rightMostElement:function(){return ve("right",we())},taggedElement:function(){return be("right","data-iframe-width")}},_=(U=Te,X=null,Y=0,function(){var e=G(),t=R-(e-(Y=Y||e));return V=this,K=arguments,t<=0||R 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] && 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] && 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, + 'onMessage passed: {iframe: ' + + messageData.iframe.id + + ', message: ' + + msgBody + + '}' + ) + + on('onMessage', { + 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, + documentHeight: document.documentElement.clientHeight, + documentWidth: document.documentElement.clientWidth, + windowHeight: window.innerHeight, + windowWidth: window.innerWidth + }) + } + + function sendPageInfoToIframe(iframe, iframeId) { + function debouncedTrigger() { + trigger('Send Page Info', 'pageInfo:' + getPageInfo(), iframe, iframeId) + } + debounceFrameEvents(debouncedTrigger, 32, iframeId) + } + + 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() + + if (settings[id]) { + 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 !== on('onScroll', 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 onMouse(event) { + var mousePos = {} + + if (Number(messageData.width) === 0 && Number(messageData.height) === 0) { + var data = getMsgBody(9).split(':') + mousePos = { + x: data[1], + y: data[0] + } + } else { + mousePos = { + x: messageData.width, + y: messageData.height + } + } + + on(event, { + iframe: messageData.iframe, + screenX: Number(mousePos.x), + screenY: Number(mousePos.y), + type: messageData.type + }) + } + + function on(funcName, val) { + return chkEvent(iframeId, funcName, val) + } + + function actionMsg() { + if (settings[iframeId] && settings[iframeId].firstRun) firstRun() + + switch (messageData.type) { + case 'close': + closeIFrame(messageData.iframe) + break + + case 'message': + forwardMsgFromIFrame(getMsgBody(6)) + break + + case 'mouseenter': + onMouse('onMouseEnter') + break + + case 'mouseleave': + onMouse('onMouseLeave') + break + + case 'autoResize': + settings[iframeId].autoResize = JSON.parse(getMsgBody(9)) + break + + case 'scrollTo': + scrollRequestFromChild(false) + break + + case 'scrollToOffset': + scrollRequestFromChild(true) + break + + case 'pageInfo': + sendPageInfoToIframe( + settings[iframeId] && settings[iframeId].iframe, + iframeId + ) + startPageInfoMonitor() + break + + case 'pageInfoStop': + stopPageInfoMonitor() + break + + case 'inPageLink': + findTarget(getMsgBody(9)) + break + + case 'reset': + resetIFrame(messageData) + break + + case 'init': + resizeIFrame() + on('onInit', messageData.iframe) + break + + default: + if ( + Number(messageData.width) === 0 && + Number(messageData.height) === 0 + ) { + warn( + 'Unsupported message received (' + + messageData.type + + '), this is likely due to the iframe containing a later ' + + 'version of iframe-resizer than the parent page' + ) + } else { + resizeIFrame() + } + } + } + + 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() { + // eslint-disable-next-line no-restricted-syntax, guard-for-in + for (var iframeId in settings) { + trigger( + 'iFrame requested init', + createOutgoingMsg(iframeId), + settings[iframeId].iframe, + iframeId + ) + } + } + + function firstRun() { + if (settings[iframeId]) { + settings[iframeId].firstRun = false + } + } + + var msg = event.data, + messageData = {}, + iframeId = null + + if ('[iFrameResizerChild]Ready' === msg) { + iFrameReadyMsgReceived() + } else if (isMessageForUs()) { + messageData = processMsg() + iframeId = messageData.id + if (settings[iframeId]) { + settings[iframeId].loaded = true + } + + if (!isMessageFromMetaParent() && hasSettings(iframeId)) { + log(iframeId, 'Received: ' + msg) + + if (checkIFrameExists() && isMessageFromIFrame()) { + actionMsg() + } + } + } else { + info(iframeId, 'Ignored: ' + msg) + } + } + + function chkEvent(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 removeIframeListeners(iframe) { + var iframeId = iframe.id + delete settings[iframeId] + } + + function closeIFrame(iframe) { + var iframeId = iframe.id + if (chkEvent(iframeId, 'onClose', iframeId) === false) { + log(iframeId, 'Close iframe cancelled by onClose event') + return + } + log(iframeId, 'Removing iFrame: ' + iframeId) + + try { + // Catch race condition error with React + if (iframe.parentNode) { + iframe.parentNode.removeChild(iframe) + } + } catch (error) { + warn(error) + } + + chkEvent(iframeId, 'onClosed', iframeId) + log(iframeId, '--') + removeIframeListeners(iframe) + } + + 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) { + if (!messageData.id) { + log('undefined', 'messageData id not set') + return + } + 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 && + // including check for jasmine because had trouble getting spy to work in unit test using requestAnimationFrame + !window.jasmine + ) { + log(messageData.id, 'Requesting animation frame') + requestAnimationFrame(func) + } else { + func() + } + } + + function trigger(calleeMsg, msg, iframe, id, noResponseWarning) { + function postMessageToIFrame() { + var target = settings[id] && settings[id].targetOrigin + log( + id, + '[' + + calleeMsg + + '] Sending msg to iframe[' + + id + + '] (' + + msg + + ') targetOrigin: ' + + target + ) + iframe.contentWindow.postMessage(msgId + msg, target) + } + + function iFrameNotFound() { + warn(id, '[' + calleeMsg + '] IFrame(' + id + ') not found') + } + + function chkAndSend() { + if ( + iframe && + 'contentWindow' in iframe && + null !== iframe.contentWindow + ) { + // Null test for PhantomJS + postMessageToIFrame() + } else { + iFrameNotFound() + } + } + + function warnOnNoResponse() { + function warning() { + if (settings[id] && !settings[id].loaded && !errorShown) { + errorShown = true + warn( + id, + 'IFrame has not responded within ' + + settings[id].warningTimeout / 1000 + + ' seconds. Check iFrameResizer.contentWindow.js has been loaded in iFrame. This message can be ignored if everything is working, or you can set the warningTimeout option to a higher value or zero to suppress this warning.' + ) + } + } + + if ( + !!noResponseWarning && + settings[id] && + !!settings[id].warningTimeout + ) { + settings[id].msgTimeout = setTimeout( + warning, + settings[id].warningTimeout + ) + } + } + + var errorShown = false + + id = id || iframe.id + + if (settings[id]) { + chkAndSend() + warnOnNoResponse() + } + } + + 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 + + ':' + + settings[iframeId].mouseEvents + ) + } + + function isNumber(value) { + return typeof value === 'number' + } + + function setupIFrame(iframe, options) { + function setLimits() { + function addStyle(style) { + var styleValue = settings[iframeId][style] + if (Infinity !== styleValue && 0 !== styleValue) { + iframe.style[style] = isNumber(styleValue) + ? styleValue + 'px' + : styleValue + log(iframeId, 'Set ' + style + ' = ' + iframe.style[style]) + } + } + + 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 += count++ + } + return id + } + + function ensureHasId(iframeId) { + if ('' === iframeId) { + // eslint-disable-next-line no-multi-assign + iframe.id = iframeId = newId() + logEnabled = (options || {}).log + log( + iframeId, + 'Added missing iframe ID: ' + iframeId + ' (' + iframe.src + ')' + ) + } + + return iframeId + } + + function setScrolling() { + log( + iframeId, + 'IFrame scrolling ' + + (settings[iframeId] && settings[iframeId].scrolling + ? 'enabled' + : 'disabled') + + ' for ' + + iframeId + ) + iframe.style.overflow = + false === (settings[iframeId] && settings[iframeId].scrolling) + ? 'hidden' + : 'auto' + switch (settings[iframeId] && settings[iframeId].scrolling) { + case 'omit': + break + + case true: + iframe.scrolling = 'yes' + break + + case false: + iframe.scrolling = 'no' + break + + default: + iframe.scrolling = settings[iframeId] + ? settings[iframeId].scrolling + : 'no' + } + } + + // 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] && settings[iframeId].bodyMargin) || + '0' === (settings[iframeId] && 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] && settings[iframeId].firstRun, + resetRequertMethod = + settings[iframeId] && + settings[iframeId].heightCalculationMethod in resetRequiredMethods + + if (!firstRun && resetRequertMethod) { + resetIFrame({ iframe: iframe, height: 0, width: 0, type: 'init' }) + } + } + + function setupIFrameObject() { + if (settings[iframeId]) { + settings[iframeId].iframe.iFrameResizer = { + close: closeIFrame.bind(null, settings[iframeId].iframe), + + removeListeners: removeIframeListeners.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, undefined, true) + checkReset() + } + + function createDestroyObserver(MutationObserver) { + if (!iframe.parentNode) { + return + } + + var destroyObserver = new MutationObserver(function (mutations) { + mutations.forEach(function (mutation) { + var removedNodes = Array.prototype.slice.call(mutation.removedNodes) // Transform NodeList into an Array + removedNodes.forEach(function (removedNode) { + if (removedNode === iframe) { + closeIFrame(iframe) + } + }) + }) + }) + destroyObserver.observe(iframe.parentNode, { + childList: true + }) + } + + var MutationObserver = getMutationObserver() + if (MutationObserver) { + createDestroyObserver(MutationObserver) + } + + addEventListener(iframe, 'load', iFrameLoaded) + trigger('init', msg, iframe, undefined, true) + } + + function checkOptions(options) { + if ('object' !== typeof options) { + throw new TypeError('Options is not an object') + } + } + + function copyOptions(options) { + // eslint-disable-next-line no-restricted-syntax + for (var option in defaults) { + if (Object.prototype.hasOwnProperty.call(defaults, option)) { + settings[iframeId][option] = Object.prototype.hasOwnProperty.call( + options, + option + ) + ? options[option] + : defaults[option] + } + } + } + + function getTargetOrigin(remoteHost) { + return '' === remoteHost || + null !== remoteHost.match(/^(about:blank|javascript:|file:\/\/)/) + ? '*' + : remoteHost + } + + function depricate(key) { + var splitName = key.split('Callback') + + if (splitName.length === 2) { + var name = + 'on' + splitName[0].charAt(0).toUpperCase() + splitName[0].slice(1) + this[name] = this[key] + delete this[key] + warn( + iframeId, + "Deprecated: '" + + key + + "' has been renamed '" + + name + + "'. The old method will be removed in the next major version." + ) + } + } + + function processOptions(options) { + options = options || {} + settings[iframeId] = { + firstRun: true, + iframe: iframe, + remoteHost: iframe.src && iframe.src.split('/').slice(0, 3).join('/') + } + + checkOptions(options) + Object.keys(options).forEach(depricate, options) + copyOptions(options) + + if (settings[iframeId]) { + 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) + } + } + + var frameTimer = {} + function debounceFrameEvents(fn, time, frameId) { + if (!frameTimer[frameId]) { + frameTimer[frameId] = setTimeout(function () { + frameTimer[frameId] = null + fn() + }, time) + } + } + + // Not testable in PhantomJS + /* istanbul ignore next */ + + function fixHiddenIFrames() { + function checkIFrames() { + function checkIFrame(settingId) { + function chkDimension(dimension) { + return ( + '0px' === + (settings[settingId] && settings[settingId].iframe.style[dimension]) + ) + } + + function isVisible(el) { + return null !== el.offsetParent + } + + if ( + settings[settingId] && + isVisible(settings[settingId].iframe) && + (chkDimension('height') || chkDimension('width')) + ) { + trigger( + 'Visibility change', + 'resize', + settings[settingId].iframe, + settingId + ) + } + } + + Object.keys(settings).forEach(function (key) { + checkIFrame(key) + }) + } + + 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 = getMutationObserver() + if (MutationObserver) { + createMutationObserver() + } + } + + function resizeIFrames(event) { + function resize() { + sendTriggerMsg('Window ' + event, 'resize') + } + + log('window', 'Trigger event: ' + event) + debouce(resize, 16) + } + + // Not testable in PhantomJS + /* istanbul ignore next */ + 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 ( + settings[iframeId] && + 'parent' === settings[iframeId].resizeFrom && + settings[iframeId].autoResize && + !settings[iframeId].firstRun + ) + } + + Object.keys(settings).forEach(function (iframeId) { + if (isIFrameResizeEnabled(iframeId)) { + trigger(eventName, event, settings[iframeId].iframe, iframeId) + } + }) + } + + function setupEventListeners() { + addEventListener(window, 'message', iFrameListener) + + addEventListener(window, 'resize', function () { + resizeIFrames('resize') + }) + + addEventListener(document, 'visibilitychange', tabVisible) + + addEventListener(document, '-webkit-visibilitychange', tabVisible) + } + + 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