{"version":3,"sources":["iframe-communication.min.js"],"names":["window","document","HTMLIFrameElement","communication","isIframe","urlParams","params","element","callback","newHeight","lastHeight","self","initGoogleTagManager","gtmId","getParam","appConfig","body","getElementsByTagName","inlineScript","createElement","noscript","innerHTML","appendChild","insertBefore","firstChild","Object","assign","calculationTool","location","href","hrefBase","replace","search","origin","match","RegExp","forEach","param","index","arr","split","config","getConfig","name","getLocation","sendMessage","type","data","parent","postMessage","event","tools_message_type","tools_message_data","dataLayer","push","sendResizeMessage","height","documentElement","offsetHeight","sendScrollToMessage","position","sendAuthLoginMessage","referenceBack","redirect","userId","profileId","sendAuthRegisterMessage","sendUserActionMessage","action","sendStartNewCalculationMessage","sendLoadCalculationMessage","sendCancelCalculationMessage","sendFinishCalculationMessage","sendSaveCalculationMessage","sendShareCalculationMessage","hash","emails","sendCalculationResultsMessage","sendDownloadCalculationResultsMessage","sendChangeStepMessage","step","sendPreviousStepMessage","sendNextStepMessage","sendEmailMessage","attachments","sendContactRequest","Array","isArray","sendQuotationMessage","bom","setCookie","value","getCookie","cookieCallback","removeEventListener","addEventListener","deleteCookie","setStorage","getStorage","storageCallback","deleteStorage","getOffset","offsetCallback","onMessage","onMessages","onInitMessage","onResizeMessage","onScrollMessage","version","build","clientHeight","run","onElementHeightChangeTimer","clearTimeout","setTimeout","prototype","iframe","this","registeredMessageEventListeners","src","contentWindow","width","innerWidth","iframeOffsetTop","offsetTop","iframeScrollTop","scrollY","parentScrollTop","sendScrollMessage","getBoundingClientRect","top","messageEventListener","onReadyMessage","onScrollToMessage","onAuthLoginMessage","onAuthRegisterMessage","onUserActionMessage","onStartNewCalculationMessage","onLoadCalculationMessage","onCancelCalculationMessage","onFinishCalculationMessage","onSaveCalculationMessage","onShareCalculationMessage","onSendCalculationResultsMessage","onDownloadCalculationResultsMessage","onSendEmailMessage","onSendQuotationMessage","onChangeStepMessage","onGetCookie","result","cookie","JSON","parse","undefined","onSetCookie","onDeleteCookie","onGetStorage","key","localStorage","getItem","onSetStorage","onDeleteStorage","onGetOffset","viewportHeight","innerHeight","destroyCommunication","item","classList","add","remove","style","overflow","parseInt","scrollTo","stringify","join","setItem","removeItem","resizeEventListener","scrollEventListener","frameElement","nodeName"],"mappings":"CAAA,SAAUA,EAAQC,EAAUC,GACxB,aA8lCA,SAASC,EAAcC,GACnBA,EAAWA,IAAY,EAEvB,IAQQC,EACAC,EAmB8BC,EAASC,EACJC,EAAnCC,EA7BJC,EAAO,GAiDPC,EAAuB,WACvB,IAAIC,EAAQF,EAAKG,SAAS,SAG1B,GAFAD,EAAQA,GAASF,EAAKI,UAAUF,MAEhC,CAGA,IAAIG,EAAOf,EAASgB,qBAAqB,QAAQ,GAC7CC,EAAejB,EAASkB,cAAc,UACtCC,EAAWnB,EAASkB,cAAc,YAEtCD,EAAaG,UAAY,sUAAuUR,EAAO,MACvWO,EAASC,UAAY,4DAA8DR,EAAO,0EAE1FZ,EAASgB,qBAAqB,QAAQ,GAAGK,YAAYJ,GACrDF,EAAKO,aAAaH,EAAUJ,EAAKQ,cAs9BrC,OAv7BAb,EAAKI,UAAYU,OAAOC,OAAO,GAVf,CACZC,gBAAmB,KACnBd,MAAS,OAsBbF,EAAKiB,SAAW,CACZC,KAAQ7B,EAAO4B,SAASC,KACxBC,SAAY9B,EAAO4B,SAASC,KAAKE,QAAQ/B,EAAO4B,SAASI,OAAQ,IACjEC,OAAUjC,EAAO4B,SAASK,OAC1BD,OAAUhC,EAAO4B,SAASI,OAC1B1B,QA1GID,EAAYL,EAAO4B,SAASI,OAAOE,MAAM,IAAIC,OAAO,uBACpD7B,EAAS,GAETD,GACAA,EAAU+B,QAAQ,SAAUC,EAAOC,EAAOC,GACtCF,EAAQA,EAAMN,QAAQ,SAAU,IAAIS,MAAM,KAC1ClC,EAAO+B,EAAM,IAAMA,EAAM,KAI1B/B,IA8GXK,EAAK8B,OAAS,SAAUA,GACpB,QAAqB,IAAVA,IAA0BA,EACjC,KAAM,+BAEV,QAAqC,IAA1BA,EAAOd,kBA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,IAAKgB,EAAM,IAAK4G,KAAKuB,UAAUnF,GAAQ,YAAYoF,KAAK,IAC1G9K,EAASqJ,OAASA,IAMtBlC,EAAOuC,eAAe,SAAUhH,EAAMhB,EAAiBmB,GACnD,IAAIwG,EAAS,CAAC,kBAAmB3H,EAAiB,IAAKgB,EAAM,IAAK,kDAAkDoI,KAAK,IACzH9K,EAASqJ,OAASA,IAMtBlC,EAAOwC,eAKPxC,EAAO4C,aAAa,SAAUrE,EAAOhD,EAAMhB,EAAiBmB,GACxD,IAAI+G,EAAM,kBAAmBlI,EAAiB,IAAKgB,EAEnD3C,EAAO8J,aAAakB,QAAQnB,EAAKN,KAAKuB,UAAUnF,MAMpDyB,EAAO6C,gBAAgB,SAAUtH,EAAMhB,EAAiBmB,GACpD,IAAI+G,EAAM,kBAAmBlI,EAAiB,IAAKgB,EAEnD3C,EAAO8J,aAAamB,WAAWpB,KAMnCzC,EAAO8C,cAKP,IAAIgB,EAAsB,WACtB9D,EAAOY,qBAEXhI,EAAO+F,iBAAiB,SAAUmF,GAAqB,GACvD5D,EAAgChE,KAAK4H,GAKrC,IAAIC,EAAsB,WACtB/D,EAAOY,qBAKX,OAHAhI,EAAO+F,iBAAiB,SAAUoF,GAAqB,GACvD7D,EAAgChE,KAAK6H,GAE9B/D,GAorCNpH,IAAWA,EAAOgD,QAAYhD,EAAOoL,cAAgD,UAAhCpL,EAAOoL,aAAaC,cACtC,IAAzBrL,EAAOG,gBACdH,EAAOG,cAAgBA,GAAc,IAEzCH,EAAOG,cAAgBA,GAAc,GAhoE7C,CAkoEGH,OAAQC","file":"iframe-communication.min.js","sourcesContent":["(function(window, document, HTMLIFrameElement) {\r\n 'use strict'\r\n\r\n /**\r\n * @namespace ParentToIframeCommunication\r\n * @description\r\n * The interface for sending messages from website to iframe.\r\n * \r\n *

Installation

\r\n *
Static pages (HTML, PHP)
\r\n * Include JS scripts after iframe html element.
\r\n * Include library file after script tag with initialization of communication library.\r\n * <iframe id=\"myIframe\" src=\"url/to/iframe?userId=12345&lang=en-EN\"></iframe>\r\n * <script>\r\n * //\r\n * // Initialize library.\r\n * //\r\n * function initCommunication() {\r\n * // Get iframe element and init communication library.\r\n * const iframe = document.getElementById('myIframe').communication()\r\n * \r\n * // Event listeners examples.\r\n * iframe\r\n * .onAuthLoginMessage(() => {\r\n * ...\r\n * })\r\n * .onAuthRegisterMessage(() => {\r\n * ...\r\n * })\r\n * ...\r\n * }\r\n * \r\n * </script>\r\n * <script src=\"url/to/external-script/iframe-communication.min.js?time=[CURRENT_TIMESTAMP]\" onload=\"initCommunication()\" defer></script>\r\n * \r\n * \r\n *
VUE.js
\r\n * Add iframe element to the component template:\r\n * <template>\r\n * ...\r\n * <div class=\"iframe\">\r\n * <iframe\r\n * ref=\"tool-iframe\"\r\n * :src=\"url/to/iframe?userId=12345&lang=en-EN\"\r\n * ></iframe>\r\n * </div>\r\n * ...\r\n * </template>\r\n * \r\n * \r\n * Create callback for script event listener:\r\n * methods: {\r\n * &nbsp;&nbsp;&nbsp;&nbsp;...\r\n * &nbsp;&nbsp;&nbsp;&nbsp;initCommunication() {\r\n * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Get iframe element and init communication library.\r\n * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const iframe = this.$refs[\"tool-iframe\"].communication()\r\n * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Event listeners examples.\r\n * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iframe\r\n * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.onAuthLoginMessage(() => {\r\n * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.$router.push({ name: \"LoginPage\" })\r\n * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;})\r\n * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.onAuthRegisterMessage(() => {\r\n * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.$router.push({ name: \"RegisterPage\" })\r\n * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;})\r\n * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;...\r\n * &nbsp;&nbsp;&nbsp;&nbsp;}\r\n * &nbsp;&nbsp;&nbsp;&nbsp;...\r\n * }\r\n * \r\n * \r\n * Add script to mounted lifecycle hook:\r\n * mounted() {\r\n * &nbsp;&nbsp;&nbsp;&nbsp;...\r\n * &nbsp;&nbsp;&nbsp;&nbsp;const communicationScript = document.createElement(\"script\")\r\n * &nbsp;\r\n * &nbsp;&nbsp;&nbsp;&nbsp;communicationScript.setAttribute(\"src\", \"url/to/external-script/iframe-communication.min.js?time=[CURRENT_TIMESTAMP]\")\r\n * &nbsp;&nbsp;&nbsp;&nbsp;communicationScript.addEventListener(\"load\", this.initCommunication)\r\n * &nbsp;\r\n * &nbsp;&nbsp;&nbsp;&nbsp;this.$el.appendChild(communicationScript)\r\n * &nbsp;&nbsp;&nbsp;&nbsp;...\r\n * }\r\n * \r\n * \r\n * Add destroy method to beforeUnmount hook:\r\n * beforeUnmount() {\r\n * &nbsp;&nbsp;&nbsp;&nbsp;...\r\n * &nbsp;&nbsp;&nbsp;&nbsp;this.$refs[\"tool-iframe\"].destroyCommunication()\r\n * &nbsp;&nbsp;&nbsp;&nbsp;...\r\n * }\r\n * \r\n * \r\n *

Information

\r\n * The interface has some built-in messages types that are fired automatically:\r\n * \r\n * - \"init\" - Fire when iframe element was loaded.\r\n * - \"resize-width\" - Fire when window width change.\r\n * - \"scroll\" - Fire when scroll position change.\r\n *
\r\n * \r\n *
Interface
\r\n * @example\r\n * ...\r\n * \r\n * \r\n * \r\n * ...\r\n * \r\n * \r\n */\r\n HTMLIFrameElement.prototype.communication = function (config) {\r\n var iframe = this\r\n\r\n /*\r\n * The config object.\r\n * \r\n * @param {object} config\r\n */\r\n config = Object.assign({}, config)\r\n\r\n /*\r\n * The registered message event listeners.\r\n *\r\n * @var {array}\r\n */\r\n var registeredMessageEventListeners = []\r\n\r\n /**\r\n * Send custom message to iframe.\r\n * \r\n * @param {string} type The name of message type.\r\n * @param {object} data The message data.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Send custom message to iframe.\r\n * iframe.sendMessage('message-type-name', {\r\n * key: 'value',\r\n * ...\r\n * })\r\n */\r\n iframe.sendMessage = function (type, data) {\r\n var origin = iframe.src.match(/(^[^\\/]*\\/\\/[^\\/]*)/g)\r\n \r\n iframe.contentWindow.postMessage({\r\n type: type,\r\n data: data\r\n }, '*')\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Send resize width message to iframe.\r\n *

This method is performed automatically each time the browser window size changes.

\r\n * \r\n * @param {string} [type] The name of message type (optional).\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Send resize-width message to iframe.\r\n * iframe.sendResizeMessage()\r\n */\r\n iframe.sendResizeMessage = function (type) {\r\n type = type || 'resize-width'\r\n\r\n iframe.sendMessage(type, {\r\n width: window.innerWidth,\r\n iframeOffsetTop: iframe.offsetTop,\r\n iframeScrollTop: window.scrollY - iframe.offsetTop,\r\n parentScrollTop: window.scrollY\r\n })\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Send scroll message to iframe.\r\n *

This method is performed automatically each time the browser window scroll changes.

\r\n * \r\n * @param {string} [type] The name of message type (optional).\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Send resize-width message to iframe.\r\n * iframe.sendScrollMessage()\r\n */\r\n iframe.sendScrollMessage = function (type) {\r\n type = type || 'scroll'\r\n\r\n iframe.sendMessage(type, {\r\n iframeOffsetTop: iframe.getBoundingClientRect().top + window.scrollY,\r\n iframeScrollTop: iframe.getBoundingClientRect().top * -1,\r\n parentScrollTop: window.scrollY\r\n })\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Listen custom message from iframe.\r\n * \r\n * @param {string} type The name of message type.\r\n * @param {function (data: object, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Listen custom message from iframe.\r\n * iframe.onMessage('message-type-name', function (data, type) {\r\n * ...\r\n * })\r\n */\r\n iframe.onMessage = function (type, callback) {\r\n var messageEventListener = function (event) {\r\n if ((!type && typeof event.data.type == 'undefined') || (type && event.data.type != type))\r\n return\r\n\r\n callback(event.data.data, event.data.type)\r\n }\r\n\r\n window.addEventListener(\"message\", messageEventListener, false)\r\n registeredMessageEventListeners.push(messageEventListener)\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Listen all messages from iframe.\r\n * \r\n * @param {function (data: object, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Listen all messages from iframe.\r\n * iframe.onMessages(function (data, type) {\r\n * ...\r\n * })\r\n */\r\n iframe.onMessages = function (callback) {\r\n iframe.onMessage(null, callback)\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Listen ready message from iframe.\r\n * \r\n * @param {function (data: object, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Listen ready message from iframe.\r\n * iframe.onReadyMessage(function (data, type) {\r\n * ...\r\n * })\r\n */\r\n iframe.onReadyMessage = function (callback) {\r\n iframe.onMessage('ready', callback)\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Listen scroll to message from iframe.\r\n * \r\n * @param {function (data: object, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Listen scroll-to message from iframe.\r\n * iframe.onScrollToMessage(function (data, type) {\r\n * ...\r\n * })\r\n */\r\n iframe.onScrollToMessage = function (callback) {\r\n iframe.onMessage('scroll-to', callback)\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Listen auth login message from iframe.\r\n * \r\n * @param {function (data: object, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Listen auth login message from iframe.\r\n * iframe.onAuthLoginMessage(function (data, type) {\r\n * ...\r\n * })\r\n */\r\n iframe.onAuthLoginMessage = function (callback) {\r\n var messageEventListener = function (event) {\r\n if (typeof event.data.type == 'undefined' || event.data.type != 'redirect' || typeof event.data.data.redirect == 'undefined' || event.data.data.redirect !== 'login')\r\n return\r\n\r\n callback(event.data.data, event.data.type)\r\n }\r\n\r\n window.addEventListener(\"message\", messageEventListener, false)\r\n registeredMessageEventListeners.push(messageEventListener)\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Listen auth register message from iframe.\r\n * \r\n * @param {function (data: object, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Listen auth register message from iframe.\r\n * iframe.onAuthRegisterMessage(function (data, type) {\r\n * ...\r\n * })\r\n */\r\n iframe.onAuthRegisterMessage = function (callback) {\r\n var messageEventListener = function (event) {\r\n if (typeof event.data.type == 'undefined' || event.data.type != 'redirect' || typeof event.data.data.redirect == 'undefined' || event.data.data.redirect !== 'register')\r\n return\r\n\r\n callback(event.data.data, event.data.type)\r\n }\r\n\r\n window.addEventListener(\"message\", messageEventListener, false)\r\n registeredMessageEventListeners.push(messageEventListener)\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Listen user action message from iframe.\r\n * \r\n * @param {function (data: object, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Listen user action message from iframe.\r\n * iframe.onUserActionMessage(function (data, type) {\r\n * ...\r\n * })\r\n */\r\n iframe.onUserActionMessage = function (callback) {\r\n iframe.onMessage('user-action', callback)\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Listen start new calculation action message from iframe.\r\n * \r\n * @param {function (data: object, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Listen start new calculation action message from iframe.\r\n * iframe.onStartNewCalculationMessage(function (data, type) {\r\n * ...\r\n * })\r\n */\r\n iframe.onStartNewCalculationMessage = function (callback) {\r\n iframe.onMessage('user-action', function (data, type) {\r\n if (typeof data.action == 'undefined' || data.action != 'start new calculation')\r\n return\r\n\r\n callback(data, type)\r\n })\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Listen load calculation action message from iframe.\r\n * \r\n * @param {function (data: object, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Listen load calculation action message from iframe.\r\n * iframe.onLoadCalculationMessage(function (data, type) {\r\n * ...\r\n * })\r\n */\r\n iframe.onLoadCalculationMessage = function (callback) {\r\n iframe.onMessage('user-action', function (data, type) {\r\n if (typeof data.action == 'undefined' || data.action != 'load calculation')\r\n return\r\n\r\n callback(data, type)\r\n })\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Listen cancel calculation action message from iframe.\r\n * \r\n * @param {function (data: object, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Listen cancel calculation action message from iframe.\r\n * iframe.onCancelCalculationMessage(function (data, type) {\r\n * ...\r\n * })\r\n */\r\n iframe.onCancelCalculationMessage = function (callback) {\r\n iframe.onMessage('user-action', function (data, type) {\r\n if (typeof data.action == 'undefined' || data.action != 'cancel calculation')\r\n return\r\n\r\n callback(data, type)\r\n })\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Listen finish calculation action message from iframe.\r\n * \r\n * @param {function (data: object, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Listen finish calculation action message from iframe.\r\n * iframe.onFinishCalculationMessage(function (data, type) {\r\n * ...\r\n * })\r\n */\r\n iframe.onFinishCalculationMessage = function (callback) {\r\n iframe.onMessage('user-action', function (data, type) {\r\n if (typeof data.action == 'undefined' || data.action != 'finish calculation')\r\n return\r\n\r\n callback(data, type)\r\n })\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Listen save calculation action message from iframe.\r\n * \r\n * @param {function (data: object, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Listen save calculation action message from iframe.\r\n * iframe.onSaveCalculationMessage(function (data, type) {\r\n * ...\r\n * })\r\n */\r\n iframe.onSaveCalculationMessage = function (callback) {\r\n iframe.onMessage('user-action', function (data, type) {\r\n if (typeof data.action == 'undefined' || data.action != 'save calculation')\r\n return\r\n\r\n callback(data, type)\r\n })\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Listen share calculation action message from iframe.\r\n * \r\n * @param {function (data: object, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Listen share calculation action message from iframe.\r\n * iframe.onShareCalculationMessage(function (data, type) {\r\n * ...\r\n * })\r\n */\r\n iframe.onShareCalculationMessage = function (callback) {\r\n iframe.onMessage('user-action', function (data, type) {\r\n if (typeof data.action == 'undefined' || data.action != 'share calculation')\r\n return\r\n\r\n callback(data, type)\r\n })\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Listen send calculation action message from iframe.\r\n * \r\n * @param {function (data: object, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Listen send calculation action message from iframe.\r\n * iframe.onSendCalculationResultsMessage(function (data, type) {\r\n * ...\r\n * })\r\n */\r\n iframe.onSendCalculationResultsMessage = function (callback) {\r\n iframe.onMessage('user-action', function (data, type) {\r\n if (typeof data.action == 'undefined' || data.action != 'send calculation results')\r\n return\r\n\r\n callback(data, type)\r\n })\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Listen donwload calculation action message from iframe.\r\n * \r\n * @param {function (data: object, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Listen donwload calculation action message from iframe.\r\n * iframe.onDownloadCalculationResultsMessage(function (data, type) {\r\n * ...\r\n * })\r\n */\r\n iframe.onDownloadCalculationResultsMessage = function (callback) {\r\n iframe.onMessage('user-action', function (data, type) {\r\n if (typeof data.action == 'undefined' || data.action != 'download calculation results')\r\n return\r\n\r\n callback(data, type)\r\n })\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Listen send email action message from iframe.\r\n * \r\n * @param {function (data: object, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Listen send email action message from iframe.\r\n * iframe.onSendEmailMessage(function (data, type) {\r\n * ...\r\n * })\r\n */\r\n iframe.onSendEmailMessage = function (callback) {\r\n iframe.onMessage('email', function (data, type) {\r\n callback(data, type)\r\n })\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Listen send quotation action message from iframe.\r\n * \r\n * @param {function (data: object, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Listen send quotation action message from iframe.\r\n * iframe.onSendQuotationMessage(function (data, type) {\r\n * ...\r\n * })\r\n */\r\n iframe.onSendQuotationMessage = function (callback) {\r\n iframe.onMessage('quotation', function (data, type) {\r\n callback(data, type)\r\n })\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Listen change step action message from iframe.\r\n * \r\n * @param {function (data: object, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Listen change step action message from iframe.\r\n * iframe.onChangeStepMessage(function (data, type) {\r\n * ...\r\n * })\r\n */\r\n iframe.onChangeStepMessage = function (callback) {\r\n iframe.onMessage('user-action', function (data, type) {\r\n if (typeof data.action == 'undefined' || data.action != 'change step' || data.action != 'previous step' || data.action != 'next step')\r\n return\r\n\r\n callback(data, type)\r\n })\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Listen get cookie message from iframe.\r\n * \r\n * @param {function (value: object, name: string, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Listen get cookie action message from iframe.\r\n * iframe.onGetCookie(function (value, name, type) {\r\n * ...\r\n * })\r\n */\r\n iframe.onGetCookie = function (callback) {\r\n iframe.onMessage('get-cookie', function (data, type) {\r\n var result = document.cookie.match(new RegExp('_communication_'+ data.calculationTool +'_'+ data.name + '=([^;]+)'))\r\n result && (result = JSON.parse(result[1]))\r\n result = result\r\n ? {\r\n name: data.name,\r\n value: result,\r\n calculationTool: data.calculationTool\r\n }\r\n : undefined\r\n \r\n iframe.sendMessage('send-cookie', result)\r\n \r\n if (typeof callback != 'undefined')\r\n callback(\r\n result ? result.value : undefined,\r\n result ? result.name : undefined,\r\n data.calculationTool,\r\n type\r\n )\r\n })\r\n\r\n return iframe\r\n }\r\n \r\n /**\r\n * Listen set cookie message from iframe.\r\n * \r\n * @param {function (value: object, name: string, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Listen get cookie action message from iframe.\r\n * iframe.onSetCookie(function (value, name, calculationTool, type) {\r\n * ...\r\n * })\r\n */\r\n iframe.onSetCookie = function (callback) {\r\n iframe.onMessage('set-cookie', function (data, type) {\r\n callback(data.value, data.name, data.calculationTool, type)\r\n })\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Listen delete cookie message from iframe.\r\n * \r\n * @param {function (value: object, name: string, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Listen get cookie action message from iframe.\r\n * iframe.onDeleteCookie(function (name, calculationTool, type) {\r\n * ...\r\n * })\r\n */\r\n iframe.onDeleteCookie = function (callback) {\r\n iframe.onMessage('delete-cookie', function (data, type) {\r\n callback(data.name, data.calculationTool, type)\r\n })\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Listen get storage message from iframe.\r\n * \r\n * @param {function (value: object, name: string, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Listen get storage action message from iframe.\r\n * iframe.onGetStorage(function (value, name, type) {\r\n * ...\r\n * })\r\n */\r\n iframe.onGetStorage = function (callback) {\r\n iframe.onMessage('get-storage', function (data, type) {\r\n var key = '_communication_'+ data.calculationTool +'_'+ data.name,\r\n result = localStorage.getItem(key)\r\n\r\n result && (result = JSON.parse(result))\r\n result = result\r\n ? {\r\n name: data.name,\r\n value: result,\r\n calculationTool: data.calculationTool\r\n }\r\n : undefined\r\n \r\n iframe.sendMessage('send-storage', result)\r\n \r\n if (typeof callback != 'undefined')\r\n callback(\r\n result ? result.value : undefined,\r\n result ? result.name : undefined,\r\n data.calculationTool,\r\n type\r\n )\r\n })\r\n\r\n return iframe\r\n }\r\n \r\n /**\r\n * Listen set storage message from iframe.\r\n * \r\n * @param {function (value: object, name: string, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Listen get storage action message from iframe.\r\n * iframe.onSetStorage(function (value, name, calculationTool, type) {\r\n * ...\r\n * })\r\n */\r\n iframe.onSetStorage = function (callback) {\r\n iframe.onMessage('set-storage', function (data, type) {\r\n callback(data.value, data.name, data.calculationTool, type)\r\n })\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Listen delete storage message from iframe.\r\n * \r\n * @param {function (value: object, name: string, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Listen get storage action message from iframe.\r\n * iframe.onDeleteStorage(function (name, calculationTool, type) {\r\n * ...\r\n * })\r\n */\r\n iframe.onDeleteStorage = function (callback) {\r\n iframe.onMessage('delete-storage', function (data, type) {\r\n callback(data.name, data.calculationTool, type)\r\n })\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Listen get offset message from iframe.\r\n * \r\n * @param {function (data: object, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Listen get offset action message from iframe.\r\n * iframe.onGetOffset(function (data, type) {\r\n * ...\r\n * })\r\n */\r\n iframe.onGetOffset = function (callback) {\r\n iframe.onMessage('get-offset', function (data, type) {\r\n var result = {\r\n iframeOffsetTop: iframe.getBoundingClientRect().top + window.scrollY,\r\n iframeScrollTop: iframe.getBoundingClientRect().top * -1,\r\n parentScrollTop: window.scrollY,\r\n viewportHeight: window.innerHeight\r\n }\r\n \r\n iframe.sendMessage('send-offset', result)\r\n \r\n if (typeof callback != 'undefined')\r\n callback(result, type)\r\n })\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * Destroy communication library and remove all event listeners.\r\n * \r\n * @return {void}\r\n * \r\n * @memberof ParentToIframeCommunication.prototype\r\n * @example\r\n * // Destroy communication.\r\n * iframe.destroyCommunication()\r\n */\r\n iframe.destroyCommunication = function () {\r\n registeredMessageEventListeners.forEach(function (item) {\r\n window.removeEventListener('message', item)\r\n })\r\n }\r\n\r\n /*\r\n * Listen iframe on load event.\r\n */\r\n iframe.addEventListener('load', function () {\r\n iframe.sendResizeMessage('init')\r\n }, false)\r\n\r\n /*\r\n * Listen event \"ready\" from iframe.\r\n */\r\n iframe.onMessage('ready', function (data) {\r\n iframe.height = data.height\r\n iframe.classList.add('loaded')\r\n iframe.classList.remove('loading')\r\n })\r\n\r\n /*\r\n * Listen event \"resize-height\" from iframe.\r\n */\r\n iframe.onMessage('resize-height', function (data) {\r\n iframe.height = data.height\r\n })\r\n\r\n /*\r\n * Init iframe style.\r\n */\r\n iframe.style.overflow = 'hidden'\r\n\r\n /*\r\n * Listen event \"scroll-to\" from iframe.\r\n */\r\n iframe.onScrollToMessage(function (data) {\r\n var offsetTop = parseInt(iframe.getBoundingClientRect().top + window.scrollY + data.position)\r\n window.scrollTo(0, offsetTop)\r\n })\r\n\r\n /*\r\n * Listen event \"get-cookie\" from iframe.\r\n */\r\n iframe.onGetCookie()\r\n\r\n /*\r\n * Listen event \"set-cookie\" from iframe.\r\n */\r\n iframe.onSetCookie(function (value, name, calculationTool, type) {\r\n var cookie = ['_communication_'+ calculationTool +'_'+ name, '=', JSON.stringify(value), ';path=/;'].join('')\r\n document.cookie = cookie\r\n })\r\n\r\n /*\r\n * Listen event \"delete-cookie\" from iframe.\r\n */\r\n iframe.onDeleteCookie(function (name, calculationTool, type) {\r\n var cookie = ['_communication_'+ calculationTool +'_'+ name, '=', ';path=/;Expires=Thu, 01 Jan 1970 00:00:01 GMT;'].join('')\r\n document.cookie = cookie\r\n })\r\n\r\n /*\r\n * Listen event \"get-storage\" from iframe.\r\n */\r\n iframe.onGetStorage()\r\n\r\n /*\r\n * Listen event \"set-storage\" from iframe.\r\n */\r\n iframe.onSetStorage(function (value, name, calculationTool, type) {\r\n var key = '_communication_'+ calculationTool +'_'+ name\r\n\r\n window.localStorage.setItem(key, JSON.stringify(value));\r\n })\r\n\r\n /*\r\n * Listen event \"delete-storage\" from iframe.\r\n */\r\n iframe.onDeleteStorage(function (name, calculationTool, type) {\r\n var key = '_communication_'+ calculationTool +'_'+ name\r\n\r\n window.localStorage.removeItem(key);\r\n })\r\n\r\n /*\r\n * Listen event \"get-offset\" from iframe.\r\n */\r\n iframe.onGetOffset()\r\n\r\n /*\r\n * Listen window on resize event.\r\n */\r\n var resizeEventListener = function () {\r\n iframe.sendScrollMessage()\r\n }\r\n window.addEventListener('resize', resizeEventListener, false)\r\n registeredMessageEventListeners.push(resizeEventListener)\r\n\r\n /*\r\n * Listen window on scroll event.\r\n */\r\n var scrollEventListener = function () {\r\n iframe.sendScrollMessage()\r\n }\r\n window.addEventListener(\"scroll\", scrollEventListener, false)\r\n registeredMessageEventListeners.push(scrollEventListener)\r\n\r\n return iframe\r\n }\r\n\r\n /**\r\n * @namespace IframeToParentCommunication\r\n * @return {instance}\r\n * @description\r\n * The interface for sending messages from iframe to a parent.\r\n * \r\n *

Installation

\r\n * Include library file on iframe document.\r\n * <script src=\"path/to/script/iframe.communication.min.js\"></script>\r\n * \r\n * \r\n *

Initialization

\r\n * Include JS scripts after library include script tag.\r\n *
Set config param \"calculationTool\", \"version\" and \"build\".\r\n * <script>\r\n * // Initialization\r\n * communication.config({\r\n * calculationTool: 'calculator-name',\r\n * version: 'calculator-version',\r\n * build: 'calculator-build-number'\r\n * })\r\n * ...\r\n * \r\n * \r\n *

Information

\r\n * The interface for sending messages from iframe to a parent.\r\n *

The interface has some built-in messages types that are fired automatically:\r\n * \r\n * - \"ready\" - Fire when iframe element DOM is fully loaded.\r\n * - \"resize-height\" - Fire when iframe element height change.\r\n *

\r\n * \r\n * The interface allows to reading and saving information in a cookie file, which is stored in the parent window.\r\n * - Get cookie by name\r\n *
\r\n     * communication.getCookie('cookie-name', function (value, name, type) {\r\n     *     ...\r\n     * })\r\n     * - Set cookie value\r\n     * 
\r\n     * communication.setCookie('cookie-name', {\r\n     *     key: 'value',\r\n     *     ...\r\n     * })\r\n     * 
\r\n * \r\n * The interface allows to reading and saving information in a browser local storage, which is stored in the parent window.\r\n * - Get storage by name\r\n *
\r\n     * communication.getStorage('storage-name', function (value, name, type) {\r\n     *     ...\r\n     * })\r\n     * - Set storage value\r\n     * 
\r\n     * communication.setStorage('storage-name', {\r\n     *     key: 'value',\r\n     *     ...\r\n     * })\r\n     * 
\r\n * \r\n *

Google Tag Manager

\r\n * The interface can automatically send event to dataLayer.\r\n * \r\n * - Installation\r\n *

Set config param \"gtmId\" to initialization method.

\r\n *
\r\n     * // Initialization\r\n     * communication.config({\r\n     *     ...\r\n     *     gtmId: 'GTM-XXXX',\r\n     *     ...\r\n     * })\r\n     * 
\r\n * - How it work?\r\n *

Event is automatically pushed to the data layer when the interface sends message to parent window.

\r\n *
\r\n     * dataLayer.push({\r\n     *     event: 'tools_message_sent',\r\n     *     tools_message_type: type,\r\n     *     tools_message_data: data\r\n     * })\r\n     * 
\r\n * \r\n *
Interface
\r\n * @example\r\n * ...\r\n * \r\n * \r\n * \r\n * \r\n */\r\n function communication(isIframe) {\r\n isIframe = isIframe || false;\r\n\r\n var self = {}\r\n\r\n /*\r\n * Get url params\r\n * \r\n * @return {object}\r\n */\r\n var getUrlParams = function () {\r\n var urlParams = window.location.search.match(new RegExp(/(?:[\\?\\&])([^&]+)/g)),\r\n params = {}\r\n\r\n if (urlParams) {\r\n urlParams.forEach(function (param, index, arr) {\r\n param = param.replace(/\\?|\\&/g, '').split('=')\r\n params[param[0]] = param[1]\r\n })\r\n }\r\n\r\n return params\r\n }\r\n\r\n /*\r\n * Listener element height change.\r\n * \r\n * @param {DOMElement} element\r\n * @param {function} callback\r\n * @return {void}\r\n */\r\n var onElementHeightChange = function (element, callback) {\r\n var lastHeight = element.clientHeight, newHeight\r\n \r\n (function run() {\r\n newHeight = element.clientHeight\r\n if (lastHeight != newHeight)\r\n callback()\r\n\r\n lastHeight = newHeight\r\n if (element.onElementHeightChangeTimer)\r\n clearTimeout(element.onElementHeightChangeTimer)\r\n \r\n element.onElementHeightChangeTimer = setTimeout(run)\r\n })()\r\n }\r\n\r\n /*\r\n * Init google tag manager script.\r\n * \r\n * @return {void}\r\n */\r\n var initGoogleTagManager = function () {\r\n var gtmId = self.getParam('gtmId')\r\n gtmId = gtmId || self.appConfig.gtmId\r\n \r\n if (! gtmId)\r\n return\r\n\r\n var body = document.getElementsByTagName('body')[0],\r\n inlineScript = document.createElement('script'),\r\n noscript = document.createElement('noscript')\r\n\r\n inlineScript.innerHTML = \"(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','\"+ gtmId +\"');\"\r\n noscript.innerHTML = ''\r\n\r\n document.getElementsByTagName('head')[0].appendChild(inlineScript) \r\n body.insertBefore(noscript, body.firstChild)\r\n }\r\n\r\n /*\r\n * Send google tag manager event.\r\n *\r\n * @param {object} data\r\n * @return {void}\r\n * */\r\n var sendGoogleTagManagerEvent = function (data) {\r\n var gtmId = self.getParam('gtmId') || self.appConfig.gtmId\r\n\r\n if (! gtmId || typeof dataLayer == 'undefined')\r\n return\r\n\r\n dataLayer.push(data)\r\n }\r\n\r\n /*\r\n * Default config. \r\n */\r\n var defConfig = {\r\n \"calculationTool\": null,\r\n \"gtmId\": null\r\n }\r\n\r\n /*\r\n * The config object.\r\n * \r\n * @param {object} appConfig\r\n */\r\n self.appConfig = Object.assign({}, defConfig)\r\n\r\n /**\r\n * The location object.\r\n * \r\n * @param {object} location\r\n * @param {string} location.href The iframe full url.\r\n * @param {string} location.hrefBase The iframe base url.\r\n * @param {string} location.origin The iframe origin url.\r\n * @param {string} location.search The iframe url search.\r\n * @param {object} location.params The iframe url params.\r\n * \r\n * @memberof IframeToParentCommunication\r\n */\r\n self.location = {\r\n \"href\": window.location.href,\r\n \"hrefBase\": window.location.href.replace(window.location.search, ''),\r\n \"origin\": window.location.origin,\r\n \"search\": window.location.search,\r\n \"params\": getUrlParams()\r\n };\r\n\r\n /**\r\n * Set config.\r\n * \r\n * @param {object} config\r\n * @param {string} config.calculationTool The calculation tool name.\r\n * @param {string} [config.version] The calculation tool version (optional).\r\n * @param {string} [config.build] The calculation tool build (optional).\r\n * @param {string} [config.gtmId] The google tag manager id (optional).\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n */\r\n self.config = function (config) {\r\n if (typeof config == 'undefined' || !config)\r\n throw 'Parameter config is required'\r\n\r\n if (typeof config.calculationTool == 'undefined' || !config.calculationTool)\r\n throw 'Parameter config.calculationTool is required'\r\n\r\n self.appConfig = Object.assign(self.appConfig, config || {})\r\n\r\n if (! isIframe)\r\n initGoogleTagManager()\r\n\r\n return window.communication\r\n }\r\n\r\n /**\r\n * Get value from config static members.\r\n * \r\n * @param {string} [name] The name of config object (optional).\r\n * @return {mixed}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Get calculationTool config param.\r\n * iframe.getConfig('calculationTool')\r\n * \r\n * // Get all config params.\r\n * iframe.getConfig()\r\n */\r\n self.getConfig = function (name) {\r\n return typeof name != 'undefined'\r\n ? (self.appConfig[name] || null)\r\n : self.appConfig\r\n }\r\n\r\n /**\r\n * Get param value from location static members.\r\n * \r\n * @param {string} name The param name of location object.\r\n * @return {mixed}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Get iframe location href.\r\n * iframe.getLocation('href')\r\n */\r\n self.getLocation = function (name) {\r\n if (typeof name == 'undefined' || !name)\r\n throw 'Parameter name is required'\r\n\r\n return self.location[name] || null\r\n }\r\n\r\n /**\r\n * Get param value from iframe url search.\r\n *\r\n * @param {string} [name] The param name (optional).\r\n * @return {mixed}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Get iframe url param.\r\n * iframe.getParam('userId')\r\n * \r\n * // Get all iframe url params.\r\n * iframe.getParam()\r\n */\r\n self.getParam = function (name) {\r\n return typeof name != 'undefined'\r\n ? (self.location.params[name] || null)\r\n : self.location.params\r\n }\r\n\r\n /**\r\n * Send custom message to parent.\r\n * \r\n * @param {string} type The name of message type.\r\n * @param {object} data The message data.\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Send custom message to parent.\r\n * communication.sendMessage('message-type-name', {\r\n * key: 'value',\r\n * ...\r\n * })\r\n */\r\n self.sendMessage = function (type, data) {\r\n if (typeof type == 'undefined' || !type)\r\n throw 'Parameter type is required'\r\n\r\n if (typeof data == 'undefined' || !data)\r\n throw 'Parameter data is required'\r\n\r\n window.parent.postMessage({\r\n type: type,\r\n data: data\r\n }, '*')\r\n\r\n sendGoogleTagManagerEvent({\r\n event: 'tools_message_sent',\r\n tools_message_type: type,\r\n tools_message_data: data\r\n })\r\n\r\n return window.communication\r\n }\r\n\r\n /**\r\n * Send resize message to parent.\r\n *

This method is performed automatically each time the browser window size changes.

\r\n * \r\n * @param {string} [type] The name of message type (optional).\r\n * @param {object} [data] The message data (optional).\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Send resize-height message to parent.\r\n * communication.sendResizeMessage()\r\n */\r\n self.sendResizeMessage = function (type, data) {\r\n if (! isIframe)\r\n return window.communication\r\n\r\n type = type || 'resize-height'\r\n\r\n var data = Object.assign(data || {}, {\r\n height: document.documentElement.offsetHeight\r\n })\r\n\r\n self.sendMessage(type, data)\r\n\r\n return window.communication\r\n }\r\n\r\n /**\r\n * Send scroll-to message to parent.\r\n * \r\n * @param {number} position The offset top position.\r\n * @param {string} [type] The name of message type (optional).\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Send scroll-to message to parent.\r\n * communication.sendScrollToMessage(0)\r\n */\r\n self.sendScrollToMessage = function (position, type) {\r\n if (! isIframe)\r\n return window.communication\r\n\r\n type = type || 'scroll-to'\r\n\r\n self.sendMessage(type, {\r\n position: position\r\n })\r\n\r\n return window.communication\r\n }\r\n\r\n /**\r\n * Send auth login message to parent.\r\n * \r\n * @param {object} [data] The message data (optional).\r\n * @param {string} [data.referenceBack=location.href] The redirect iframe location href (optional).\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Send auth login message to parent.\r\n * communication.sendAuthLoginMessage()\r\n */\r\n self.sendAuthLoginMessage = function (data) {\r\n if (! isIframe)\r\n return window.communication\r\n\r\n var data = Object.assign({\r\n referenceBack: self.getLocation('href')\r\n }, data || {})\r\n\r\n data = Object.assign(data, {\r\n redirect: 'login',\r\n calculationTool: self.appConfig.calculationTool,\r\n userId: self.getParam('userId'),\r\n profileId: self.getParam('profileId')\r\n })\r\n\r\n self.sendMessage('redirect', data)\r\n\r\n return window.communication\r\n }\r\n\r\n /**\r\n * Send auth login message to parent.\r\n * \r\n * @param {object} [data] The message data (optional).\r\n * @param {string} [data.referenceBack=location.href] The redirect iframe location href (optional).\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Send auth register message to parent.\r\n * communication.sendAuthRegisterMessage()\r\n */\r\n self.sendAuthRegisterMessage = function (data) {\r\n if (! isIframe)\r\n return window.communication\r\n\r\n var data = Object.assign({\r\n referenceBack: self.getLocation('href')\r\n }, data || {})\r\n\r\n data = Object.assign(data, {\r\n redirect: 'register',\r\n calculationTool: self.appConfig.calculationTool,\r\n userId: self.getParam('userId'),\r\n profileId: self.getParam('profileId')\r\n })\r\n\r\n self.sendMessage('redirect', data)\r\n\r\n return window.communication\r\n }\r\n\r\n /**\r\n * Send user action message to parent.\r\n * \r\n * @param {string} action The action name.\r\n * @param {object} [data] The message data (optional).\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Send user action message to parent.\r\n * communication.sendUserActionMessage('start new calculation')\r\n */\r\n self.sendUserActionMessage = function (action, data) {\r\n if (typeof action == 'undefined' || !action)\r\n throw 'Parameter action is required'\r\n\r\n var data = Object.assign(data || {}, {\r\n action: action,\r\n calculationTool: self.appConfig.calculationTool,\r\n userId: self.getParam('userId'),\r\n profileId: self.getParam('profileId')\r\n })\r\n\r\n self.sendMessage('user-action', data)\r\n\r\n return window.communication\r\n }\r\n\r\n /**\r\n * Send start new calculation action message to parent.\r\n * \r\n * @param {object} [data] The message data (optional).\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Send start new calculation message to parent.\r\n * communication.sendStartNewCalculationMessage()\r\n */\r\n self.sendStartNewCalculationMessage = function (data) {\r\n self.sendUserActionMessage('start new calculation', data)\r\n }\r\n\r\n /**\r\n * Send load calculation action message to parent.\r\n * \r\n * @param {object} [data] The message data (optional).\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Send load calculation message to parent.\r\n * communication.sendLoadCalculationMessage()\r\n */\r\n self.sendLoadCalculationMessage = function (data) {\r\n self.sendUserActionMessage('load calculation', data)\r\n }\r\n\r\n /**\r\n * Send cancel calculation action message to parent.\r\n * \r\n * @param {object} [data] The message data (optional).\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Send cancel calculation message to parent.\r\n * communication.sendCancelCalculationMessage()\r\n */\r\n self.sendCancelCalculationMessage = function (data) {\r\n self.sendUserActionMessage('cancel calculation', data)\r\n }\r\n\r\n /**\r\n * Send finish calculation action message to parent.\r\n * \r\n * @param {object} [data] The message data (optional).\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Send finish calculation message to parent.\r\n * communication.sendFinishCalculationMessage()\r\n */\r\n self.sendFinishCalculationMessage = function (data) {\r\n self.sendUserActionMessage('finish calculation', data)\r\n }\r\n\r\n /**\r\n * Send save calculation action message to parent.\r\n * \r\n * @param {object} [data] The message data (optional).\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Send save calculation message to parent.\r\n * communication.sendSaveCalculationMessage()\r\n */\r\n self.sendSaveCalculationMessage = function (data) {\r\n self.sendUserActionMessage('save calculation', data)\r\n }\r\n\r\n /**\r\n * Send share calculation action message to parent.\r\n * \r\n * @param {object} data The message data.\r\n * @param {string} data.hash The share hash.\r\n * @param {string} data.emails The emails.\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Send share calculation message to parent.\r\n * communication.sendShareCalculationMessage()\r\n */\r\n self.sendShareCalculationMessage = function (data) {\r\n if (typeof data == 'undefined' || !data)\r\n throw 'Parameter data is required'\r\n\r\n if (typeof data.hash == 'undefined' || !data.hash)\r\n throw 'Parameter data.hash is required'\r\n\r\n if (typeof data.emails == 'undefined' || !data.emails)\r\n throw 'Parameter data.emails is required'\r\n\r\n var data = Object.assign(data || {}, {\r\n calculationTool: self.appConfig.calculationTool,\r\n userId: self.getParam('userId'),\r\n profileId: self.getParam('profileId')\r\n })\r\n\r\n self.sendUserActionMessage('share calculation', data)\r\n }\r\n\r\n /**\r\n * Send calculation results action message to parent.\r\n * \r\n * @param {object} [data] The message data (optional).\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Send calculation results message to parent.\r\n * communication.sendCalculationResultsMessage()\r\n */\r\n self.sendCalculationResultsMessage = function (data) {\r\n self.sendUserActionMessage('send calculation results', data)\r\n }\r\n\r\n /**\r\n * Send download calculation results action message to parent.\r\n * \r\n * @param {object} [data] The message data (optional).\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Send download calculation results message to parent.\r\n * communication.sendDownloadCalculationResultsMessage()\r\n */\r\n self.sendDownloadCalculationResultsMessage = function (data) {\r\n self.sendUserActionMessage('download calculation results', data)\r\n }\r\n\r\n /**\r\n * Send change step action message to parent.\r\n * \r\n * @param {int} step The step value.\r\n * @param {object} [data] The message data (optional).\r\n * @param {string} [action='change step'] The name of message type (optional).\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Send change step message to parent.\r\n * communication.sendChangeStepMessage(2)\r\n */\r\n self.sendChangeStepMessage = function (step, data, action) {\r\n if (typeof step == 'undefined' || !step)\r\n throw 'Parameter step is required'\r\n\r\n action = action || 'change step'\r\n\r\n var data = Object.assign(data || {}, {\r\n step: step,\r\n action: action,\r\n userId: self.getParam('userId'),\r\n profileId: self.getParam('profileId')\r\n })\r\n\r\n self.sendUserActionMessage(action, data)\r\n }\r\n\r\n /**\r\n * Send previous step action message to parent.\r\n * \r\n * @param {int} step The step value.\r\n * @param {object} [data] The message data (optional).\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Send start new calculation message to parent.\r\n * communication.sendPreviousStepMessage(1)\r\n */\r\n self.sendPreviousStepMessage = function (step, data) {\r\n if (typeof step == 'undefined' || !step)\r\n throw 'Parameter step is required'\r\n\r\n self.sendChangeStepMessage(step, data, 'previous step')\r\n }\r\n\r\n /**\r\n * Send next step action message to parent.\r\n * \r\n * @param {int} step The step value.\r\n * @param {object} [data] The message data (optional).\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Send start new calculation message to parent.\r\n * communication.sendNextStepMessage(3)\r\n */\r\n self.sendNextStepMessage = function (step, data) {\r\n if (typeof step == 'undefined' || !step)\r\n throw 'Parameter step is required'\r\n\r\n self.sendChangeStepMessage(step, data, 'next step')\r\n }\r\n\r\n /**\r\n * Send email message to parent.\r\n * \r\n * @param {object} [data] The message data (optional).\r\n * @param {boolean} [data.sendContactRequest] Contact request flag (optional).\r\n * @param {array} [data.attachments] The URLs of the attachments to be send (optional).\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Send email message to parent.\r\n * communication.sendEmailMessage()\r\n */\r\n self.sendEmailMessage = function (data) {\r\n var data = Object.assign({\r\n attachments: [],\r\n sendContactRequest: false\r\n }, data || {})\r\n\r\n if (Array.isArray(data.attachments) === false)\r\n throw 'Parameter attachments must be array'\r\n\r\n data = Object.assign(data, {\r\n calculationTool: self.appConfig.calculationTool,\r\n userId: self.getParam('userId'),\r\n profileId: self.getParam('profileId')\r\n })\r\n\r\n self.sendMessage('email', data)\r\n\r\n return window.communication\r\n }\r\n\r\n /**\r\n * Send quotation message to parent.\r\n * \r\n * @param {object} [data] The message data (optional).\r\n * @param {boolean} [data.sendContactRequest] Contact request flag (optional).\r\n * @param {object} [data.bom] BOM of created project (optional).\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Send quotation message to parent.\r\n * communication.sendQuotationMessage()\r\n */\r\n self.sendQuotationMessage = function (data) {\r\n var data = Object.assign({\r\n bom: {},\r\n sendContactRequest: false\r\n }, data || {})\r\n\r\n data = Object.assign(data, {\r\n calculationTool: self.appConfig.calculationTool,\r\n userId: self.getParam('userId'),\r\n profileId: self.getParam('profileId')\r\n })\r\n\r\n self.sendMessage('quotation', data)\r\n\r\n return window.communication\r\n }\r\n\r\n /**\r\n * Set cookie.\r\n * \r\n * @param {string} name The cookie name.\r\n * @param {object} value The cookie value.\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Set cookie in parent.\r\n * communication.setCookie('cookie-name', {\r\n * key: 'value',\r\n * ...\r\n * })\r\n */\r\n self.setCookie = function (name, value) {\r\n if (! isIframe)\r\n return\r\n\r\n if (typeof name == 'undefined')\r\n throw 'Parameter name is required'\r\n\r\n if (typeof value == 'undefined' || !value)\r\n throw 'Parameter value is required'\r\n\r\n self.sendMessage('set-cookie', {\r\n name: name,\r\n value: value,\r\n calculationTool: self.appConfig.calculationTool,\r\n userId: self.getParam('userId'),\r\n profileId: self.getParam('profileId')\r\n })\r\n }\r\n\r\n /**\r\n * Get cookie.\r\n * \r\n * @param {string} name The cookie name.\r\n * @param {function (value: object, name: string, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Get cookie by name from parent.\r\n * communication.getCookie('cookie-name', function (value, name, type) {\r\n * ...\r\n * })\r\n */\r\n self.getCookie = function (name, callback) {\r\n if (! isIframe)\r\n return window.communication\r\n\r\n if (typeof name == 'undefined')\r\n throw 'Parameter name is required'\r\n\r\n if (typeof callback == 'undefined' || !callback)\r\n throw 'Parameter callback is required'\r\n\r\n var cookieCallback = function (event) {\r\n if (typeof event.data.type == 'undefined' || event.data.type != 'send-cookie' || typeof event.data.data == 'undefined' || typeof event.data.data.name == 'undefined' || event.data.data.name != name)\r\n return\r\n\r\n callback(event.data.data.value, event.data.data.name, event.data.data.calculationTool, event.data.type)\r\n window.removeEventListener(\"message\", cookieCallback, false)\r\n }\r\n window.addEventListener(\"message\", cookieCallback, false)\r\n\r\n self.sendMessage('get-cookie', {\r\n name: name,\r\n calculationTool: self.appConfig.calculationTool,\r\n userId: self.getParam('userId'),\r\n profileId: self.getParam('profileId')\r\n })\r\n\r\n return window.communication\r\n }\r\n\r\n /**\r\n * Delete cookie.\r\n * \r\n * @param {string} name The cookie name.\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Delete cookie in parent.\r\n * communication.deleteCookie('cookie-name')\r\n */\r\n self.deleteCookie = function (name) {\r\n if (! isIframe)\r\n return\r\n\r\n if (typeof name == 'undefined')\r\n throw 'Parameter name is required'\r\n\r\n self.sendMessage('delete-cookie', {\r\n name: name,\r\n calculationTool: self.appConfig.calculationTool,\r\n userId: self.getParam('userId'),\r\n profileId: self.getParam('profileId')\r\n })\r\n }\r\n\r\n /**\r\n * Set storage.\r\n * \r\n * @param {string} name The storage name.\r\n * @param {object} value The storage value.\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Set storage in parent.\r\n * communication.setStorage('storage-name', {\r\n * key: 'value',\r\n * ...\r\n * })\r\n */\r\n self.setStorage = function (name, value) {\r\n if (! isIframe)\r\n return\r\n\r\n if (typeof name == 'undefined')\r\n throw 'Parameter name is required'\r\n\r\n if (typeof value == 'undefined' || !value)\r\n throw 'Parameter value is required'\r\n\r\n self.sendMessage('set-storage', {\r\n name: name,\r\n value: value,\r\n calculationTool: self.appConfig.calculationTool,\r\n userId: self.getParam('userId'),\r\n profileId: self.getParam('profileId')\r\n })\r\n }\r\n\r\n /**\r\n * Get storage.\r\n * \r\n * @param {string} name The storage name.\r\n * @param {function (value: object, name: string, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Get storage by name from parent.\r\n * communication.getStorage('storage-name', function (value, name, type) {\r\n * ...\r\n * })\r\n */\r\n self.getStorage = function (name, callback) {\r\n if (! isIframe)\r\n return window.communication\r\n\r\n if (typeof name == 'undefined')\r\n throw 'Parameter name is required'\r\n\r\n if (typeof callback == 'undefined' || !callback)\r\n throw 'Parameter callback is required'\r\n\r\n var storageCallback = function (event) {\r\n if (typeof event.data.type == 'undefined' || event.data.type != 'send-storage' || typeof event.data.data == 'undefined' || typeof event.data.data.name == 'undefined' || event.data.data.name != name)\r\n return\r\n\r\n callback(event.data.data.value, event.data.data.name, event.data.data.calculationTool, event.data.type)\r\n window.removeEventListener(\"message\", storageCallback, false)\r\n }\r\n window.addEventListener(\"message\", storageCallback, false)\r\n\r\n self.sendMessage('get-storage', {\r\n name: name,\r\n calculationTool: self.appConfig.calculationTool,\r\n userId: self.getParam('userId'),\r\n profileId: self.getParam('profileId')\r\n })\r\n\r\n return window.communication\r\n }\r\n\r\n /**\r\n * Delete storage.\r\n * \r\n * @param {string} name The storage name.\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Delete storage in parent.\r\n * communication.deleteStorage('storage-name')\r\n */\r\n self.deleteStorage = function (name) {\r\n if (! isIframe)\r\n return\r\n\r\n if (typeof name == 'undefined')\r\n throw 'Parameter name is required'\r\n\r\n self.sendMessage('delete-storage', {\r\n name: name,\r\n calculationTool: self.appConfig.calculationTool,\r\n userId: self.getParam('userId'),\r\n profileId: self.getParam('profileId')\r\n })\r\n }\r\n\r\n /**\r\n * Get iframe offset.\r\n * \r\n * @param {function (data: object, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Get iframe offset from parent.\r\n * communication.getOffset(function (data, type) {\r\n * ...\r\n * })\r\n */\r\n self.getOffset = function (callback) {\r\n if (! isIframe)\r\n return window.communication\r\n\r\n if (typeof callback == 'undefined' || !callback)\r\n throw 'Parameter callback is required'\r\n\r\n var offsetCallback = function (event) {\r\n if (typeof event.data.type == 'undefined' || event.data.type != 'send-offset' || typeof event.data.data == 'undefined')\r\n return\r\n\r\n callback(event.data.data, event.data.type)\r\n window.removeEventListener(\"message\", offsetCallback, false)\r\n }\r\n window.addEventListener(\"message\", offsetCallback, false)\r\n\r\n self.sendMessage('get-offset', {})\r\n\r\n return window.communication\r\n }\r\n\r\n /**\r\n * Listen custom message from parent.\r\n * \r\n * @param {string} type The name of message type.\r\n * @param {function (data: object, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Listen custom message from parent.\r\n * communication.onMessage('message-type-name', function (data, type) {\r\n * ...\r\n * })\r\n */\r\n self.onMessage = function (type, callback) {\r\n if (! isIframe)\r\n return window.communication\r\n\r\n if (typeof type == 'undefined')\r\n throw 'Parameter type is required'\r\n\r\n if (typeof callback == 'undefined' || !callback)\r\n throw 'Parameter callback is required'\r\n\r\n window.addEventListener(\"message\", function (event) {\r\n if ((!type && typeof event.data.type == 'undefined') || (type && event.data.type != type))\r\n return\r\n\r\n callback(event.data.data, event.data.type)\r\n }, false)\r\n\r\n return window.communication\r\n }\r\n\r\n /**\r\n * Listen all messages from parent.\r\n * \r\n * @param {function (data: object, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Listen all messages from parent.\r\n * communication.onMessages(function (data, type) {\r\n * ...\r\n * })\r\n */\r\n self.onMessages = function (callback) {\r\n if (! isIframe)\r\n return window.communication\r\n\r\n if (typeof callback == 'undefined' || !callback)\r\n throw 'Parameter callback is required'\r\n\r\n self.onMessage(null, callback)\r\n\r\n return window.communication\r\n }\r\n\r\n /**\r\n * Listen init message from parent.\r\n * \r\n * @param {function (data: object, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Listen init message from parent.\r\n * communication.onInitMessage(function (data, type) {\r\n * ...\r\n * })\r\n */\r\n self.onInitMessage = function (callback) {\r\n if (typeof callback == 'undefined' || !callback)\r\n throw 'Parameter callback is required'\r\n\r\n self.onMessage('init', callback)\r\n\r\n return window.communication\r\n }\r\n\r\n /**\r\n * Listen resize message from parent.\r\n * \r\n * @param {function (data: object, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Listen resize message from parent.\r\n * communication.onResizeMessage(function (data, type) {\r\n * ...\r\n * })\r\n */\r\n self.onResizeMessage = function (callback) {\r\n if (typeof callback == 'undefined' || !callback)\r\n throw 'Parameter callback is required'\r\n\r\n self.onMessage('resize-width', callback)\r\n\r\n return window.communication\r\n }\r\n\r\n /**\r\n * Listen scroll message from parent.\r\n * \r\n * @param {function (data: object, type: string)} callback The message callback function.\r\n * @return {instance}\r\n * \r\n * @memberof IframeToParentCommunication.prototype\r\n * @example\r\n * // Listen scroll message from parent.\r\n * communication.onScrollMessage(function (data, type) {\r\n * ...\r\n * })\r\n */\r\n self.onScrollMessage = function (callback) {\r\n if (typeof callback == 'undefined' || !callback)\r\n throw 'Parameter callback is required'\r\n\r\n self.onMessage('scroll', callback)\r\n\r\n return window.communication\r\n }\r\n\r\n /*\r\n * Listen event \"init\" from parent.\r\n */\r\n if (isIframe) {\r\n self.onMessage('init', function () {\r\n initGoogleTagManager()\r\n self.sendResizeMessage('ready', {\r\n \"calculationTool\": self.appConfig.calculationTool,\r\n \"version\": self.appConfig.version || null,\r\n \"build\": self.appConfig.build || null,\r\n })\r\n })\r\n }\r\n \r\n /*\r\n * Listen event \"resize-width\" from parent.\r\n */\r\n if (isIframe) {\r\n self.onMessage('resize-width', function () {\r\n self.sendResizeMessage()\r\n })\r\n }\r\n \r\n /*\r\n * Listen body height change.\r\n */\r\n if (isIframe) {\r\n onElementHeightChange(document.body, function() {\r\n self.sendResizeMessage()\r\n })\r\n }\r\n\r\n return self\r\n }\r\n \r\n // Register library to iframe window\r\n if ((window !== window.parent) || (window.frameElement && window.frameElement.nodeName == \"IFRAME\")) {\r\n if (typeof window.communication === 'undefined')\r\n window.communication = communication(true)\r\n } else {\r\n window.communication = communication(false)\r\n }\r\n})(window, document, HTMLIFrameElement)\r\n"]}