IframeWidgetFunctional = { body: null, buttonOpen: null, buttonClose: null, popupBlock: null, contentBlock: null, innerBlock: null, iframe: null, iframeAdded: false, initDone: false, specialPartnerParams: null, parentSiteUrl: null, selectorClose: null, selectorInner: null, selectorWidget: null, selectorPopupBlock: null, nameIframe: null, cssText: '.___iframe_widget { opacity: 0; overflow: hidden;}.___iframe_widget.active { opacity: 1; overflow-x: hidden; overflow-y: auto;}.___iframe_widget__overlay { position: fixed; bottom: 0px; left: 0px; right: 0px; top: 0px; z-index: 10001; background-color: #000; opacity: 0.5;}.___iframe_widget__modal { position: fixed; bottom: 0px; left: 0px; right: 0px; top: 0px; z-index: 10002; overflow-x: hidden; overflow-y: auto;}.___iframe_widget__content { position: relative; width: 900px; height: 650px; margin-left: auto; margin-right: auto; /*margin-top: 40px;*/ /*margin-bottom: 40px;*/ background-color: #ffffff;}.___iframe_widget__close { line-height: 1; box-sizing: content-box; cursor: pointer; position: absolute; z-index: 10003; left: auto; right: 0; margin-top: 0; margin-right: -36px; width: 40px; height: 40px; padding: 10px; border-radius: 5px; /*background-color: rgba(86, 86, 86, 0.75);*/ text-align: center; vertical-align: middle; transition: background-color 0.4s; display: flex; align-items: center; justify-content: center;}.___iframe_widget__close:hover { /*background-color: rgba(86, 86, 86, 1);*/}.___iframe_widget__close svg { width: 24px; height: 24px; fill: rgb(255, 255, 255);}.vassatrend_close svg { margin-top: -6px;}.___iframe_widget__inner { position: relative; width: 100%; height: 100%; overflow: hidden; -webkit-overflow-scrolling: touch;}.___iframe_widget__iframe { width: 100%; height: 100%; border: none;}.___iframe_widget_body { overflow: hidden;}.___iframe_widget__inner .confirm-close-iframe { font-family: "Gotham Pro", "GothamPro", sans-serif; position: absolute; top: 0; width: 100%; height: 100%; background-color: rgba(141,141,141,0.3); display: flex; -webkit-box-orient: vertical; -webkit-box-direction: normal; flex-direction: column; -webkit-box-align: center; align-items: center; -webkit-box-pack: center; justify-content: flex-start;}.___iframe_widget__inner .confirm-close-iframe-content { background-color: white; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 20px; width: 310px; position: relative; top: 20px;}.___iframe_widget__inner .reject-text-iframe { letter-spacing: .6px; opacity: .8; font-family: Nekst, sans-serif; font-style: normal; font-weight: 400; font-size: 26px; line-height: 31px; text-align: center; color: #000000; margin-top: 16px; margin-bottom: 28px;}.___iframe_widget__inner .reject-buttons-iframe { display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; flex-direction: column; width: 100%; gap: 10px;}.___iframe_widget__inner .reject__button--no-iframe { min-width: 182px; height: 60px; padding: 10px 16px; cursor: pointer; -webkit-transition: all .4s; transition: all .4s; text-align: center; text-decoration: none; letter-spacing: .5px; background-color:#000000; -webkit-box-align: center; -ms-flex-align: center; align-items: center; -webkit-box-pack: justify; -ms-flex-pack: justify; justify-content: space-between; margin: 0; border: 1px solid transparent; border-radius: 0; text-transform: lowercase; font-family: Gilroy, sans-serif; font-style: normal; font-weight: 500; font-size: 16px; line-height: 20px; color: #FFFFFF;}.___iframe_widget__inner .reject__button--yes-iframe { min-width: 182px; height: 60px; padding: 10px 16px; cursor: pointer; -webkit-transition: all .4s; transition: all .4s; text-align: center; text-decoration: none; letter-spacing: .5px; color: #1e1e1e; -webkit-box-align: center; -ms-flex-align: center; align-items: center; -webkit-box-pack: justify; -ms-flex-pack: justify; justify-content: space-between; background-color: #fff; margin: 0; border: 1px solid black; border-radius: 0; text-transform: lowercase; font-family: Gilroy, sans-serif; font-style: normal; font-weight: 500; font-size: 16px; line-height: 20px;}.dk-animate-modal { animation-duration: 0.3s; -webkit-animation-duration: 0.3s; animation-fill-mode: both; -webkit-animation-fill-mode: both; -webkit-animation-name: slideTop; animation-name: slideTop;}@keyframes slideTop { 0% { transform: translateY(1rem); opacity: 0; } 100% { transform: translateY(0rem); opacity: 1; } 0% { transform: translateY(1rem); opacity: 0; }}@-webkit-keyframes slideTop { 0% { -webkit-transform: translateY(1rem); -webkit-opacity: 0; } 100% { -webkit-transform: translateY(0); -webkit-opacity: 1; } 0% { -webkit-transform: translateY(1rem); -webkit-opacity: 0; }}.___iframe_widget__content{ width:900px; height:650px; }', iframeHeight: '650', iframeWidth: '900', screenWidthForRedirect: '1024', urlIframe: 'https://shophawk.digift.ru/w', urlLanding: 'https://shophawk.digift.ru/', urlIframeCheckBalance: 'https://shophawk.digift.ru/wcb', urlIframeOnlyW: 'https://shophawk.digift.ru/wm', urlIframeOnlyGG: 'https://shophawk.digift.ru/groupOrder/wstart', urlIframeB2b: 'https://b2b.digift.ru/iframe/shophawk', urlLandingOnlyW: 'https://shophawk.digift.ru/lm', urlLandingOnlyGG: 'https://shophawk.digift.ru/groupOrder/lstart', urlLandingCheckBalance: 'https://shophawk.digift.ru/cb', urlRememberSpecParams: 'https://shophawk.digift.ru/partner/index/rememberSpecParams', urlWidgetData: 'https://shophawk.digift.ru/partner/index/getWidgetData', partnerColor: '#000000', closeSvg: '', modeDefault: 'default', modeBalance: 'balance', modeOnlyW: 'onlyW', modeOnlyGG: 'onlyGG', modeB2bWidget: 'b2bWidget', mark: null, actionUrl: null, defaultImgState: null, langData: {"ru":{"close_widget":"\u0412\u044b \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u0445\u043e\u0442\u0438\u0442\u0435 \u0432\u044b\u0439\u0442\u0438?","close_widget_no":"\u041d\u0435\u0442, \u043e\u0441\u0442\u0430\u0442\u044c\u0441\u044f","close_widget_yes":"\u0414\u0430, \u0432\u044b\u0439\u0442\u0438"}}, defaultLanguage: 'ru', currentLanguage: undefined, deprecatedQueryVars: ['r'], addSpecParams: function (params) { if (typeof params === 'object') { this.specialPartnerParams = params; } }, initMark: function () { var uuidv4 = function() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); }); }; this.mark = uuidv4(); }, init: function (selectors, checkBalanceSelectors) { /* https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/remove */ (function (arr) { arr.forEach(function (item) { if (item.hasOwnProperty('remove')) { return; } Object.defineProperty(item, 'remove', { configurable: true, enumerable: true, writable: true, value: function remove() { if (this.parentNode === null) { return; } this.parentNode.removeChild(this); } }); }); })([Element.prototype, CharacterData.prototype, DocumentType.prototype]); if ( this.initDone === false ) { this.initMark(); this.actionUrl = this.urlLanding; this.selectorClose = '__jsc_widget_close_' + this.mark; this.selectorInner = '__jsc_widget_inner_' + this.mark; this.selectorWidget = '__jsc_widget_iframe_' + this.mark; this.selectorPopupBlock = '__jsc_widget_' + this.mark; this.nameIframe = 'iframeWidgetN_' + this.mark; this.setCss(); this.setBlocks(); this.initCloseEvent(); this.parentSiteUrl = window.location.href; this.initDone = true; this.currentLanguage = this.defaultLanguage; } this.setEvents(selectors, checkBalanceSelectors); }, setDefaultLanguage: function (defaultLanguage) { if ((defaultLanguage !== null) && defaultLanguage !== undefined) { this.defaultLanguage = defaultLanguage; this.currentLanguage = defaultLanguage; } }, setCurrentLanguage: function (currrentLanguage) { if ((currrentLanguage !== null) && currrentLanguage !== undefined) { this.currentLanguage = currrentLanguage; } }, setParentSiteUrl: function (parentSiteUrl) { if (parentSiteUrl !== null) { this.parentSiteUrl = parentSiteUrl; } }, setDefaultImg: function (defaultImg) { if (Number(defaultImg) >= 0) { this.defaultImgState = Number(defaultImg) - 1; } }, openPopup: function (mode) { this.currentLanguage = this.defaultLanguage; window.addEventListener("message", function(event) { var originUrl = new URL(self.actionUrl).origin; if (event.origin !== originUrl) return; var eventData = typeof event.data === "string" ? JSON.parse(event.data) : event.data; if (eventData.event_id === "event-to-hidden-dgft-iframe-close") { document.getElementsByClassName("___iframe_widget__close")[0].style.display = 'none'; return; } if (eventData.event_id === "event-to-view-dgft-iframe-close") { document.getElementsByClassName("___iframe_widget__close")[0].style.display = 'block'; return; } if (eventData.event === "change-lang-w") { self.setCurrentLanguage(eventData.eventValue); return; } }); if (typeof mode === 'undefined') { mode = this.modeDefault; } var self = this; var openPopup = function () { /* vertical alignment, if possible */ var mtop = (window.innerHeight - self.iframeHeight) / 2; if (mode === 'b2bWidget') { self.contentBlock.style = 'margin: 0px;' + 'width: 100%;' + 'height: 100vh;' + 'background: transparent;'; self.buttonClose.style = 'margin-right: 0px'; } else { if (mtop > 0) { self.contentBlock.style = 'margin-top: ' + mtop + 'px;' + 'margin-bottom: ' + mtop + 'px;'; self.buttonClose.style = 'margin-right: -60px'; } } self.popupBlock.style.display = 'block'; setTimeout(function () { self.clAddClass(self.body,'___iframe_widget_body'); self.clAddClass(self.popupBlock,'active'); }, 30); if (self.iframeAdded == false) { self.innerBlock.appendChild(self.iframe); self.iframeAdded = true; } }; var openNewWindow = function () { self.openNewWindow(); return false; }; var part_url = self.prepareSpecialPartnerParams(); var createLandingUrl = function (mode) { if (self.defaultImgState >= 0 && self.defaultImgState !== null) { if (self.parentSiteUrl) { self.actionUrl = mode + '?parentSiteUrl=' + self.parentSiteUrl.replace('?', '&') + '&defaultImgState=' + self.defaultImgState; } else { self.actionUrl = mode + '?defaultImgState=' + self.defaultImgState; } } else { if (self.parentSiteUrl) { self.actionUrl = mode + '?parentSiteUrl=' + self.parentSiteUrl.replace('?', '&'); } else { self.actionUrl = mode; } } }; let filterDeprecatedParams = function (url) { let parsedUrl = new URL(url); self.deprecatedQueryVars.forEach(function (v) { if (parsedUrl.searchParams.get(v) !== null) { parsedUrl.searchParams.append('_' + v, parsedUrl.searchParams.get(v)); parsedUrl.searchParams.delete(v); } }); return parsedUrl.toString(); }; /* redirect to landing */ if (self.needNewWindowInsteadPopup()) { if (mode === self.modeDefault) { createLandingUrl(self.urlLanding); } else if (mode === self.modeBalance) { createLandingUrl(self.urlLandingCheckBalance); } else if (mode === self.modeOnlyW) { createLandingUrl(self.urlLandingOnlyW); } else if (mode === self.modeOnlyGG) { createLandingUrl(self.urlLandingOnlyGG); } else if (mode === self.modeB2bWidget) { self.actionUrl = self.urlIframeB2b; } else { createLandingUrl(self.urlLanding); } if ( part_url ) { self.actionUrl = self.actionUrl + '?k=' + part_url; } self.actionUrl = filterDeprecatedParams(self.actionUrl); openNewWindow(); } else { if (mode === self.modeDefault) { self.actionUrl = self.urlIframe; } else if (mode === self.modeBalance) { self.actionUrl = self.urlIframeCheckBalance; } else if (mode === self.modeOnlyW) { self.actionUrl = self.urlIframeOnlyW; } else if (mode === self.modeOnlyGG) { self.actionUrl = self.urlIframeOnlyGG; } else if (mode === self.modeB2bWidget) { self.actionUrl = self.urlIframeB2b; } else { self.actionUrl = self.urlIframe; } window.addEventListener("message", function(event) { var originUrl = new URL(self.actionUrl).origin; if (event.origin === originUrl && event.data === "event-to-close-dgft-iframe-popup") { self.closePopup(); } else { return; } }); if ( part_url ) { self.actionUrl = self.actionUrl + '?k=' + part_url; } var iframeSrc; if (self.defaultImgState >= 0 && self.defaultImgState !== null) { if (self.parentSiteUrl) { if (self.parentSiteUrl.includes("?")) { iframeSrc = self.actionUrl + '?parentSiteUrl=' + self.parentSiteUrl.replace('?', '&') + '&defaultImgState=' + self.defaultImgState; } else { iframeSrc = self.actionUrl + '?defaultImgState=' + self.defaultImgState; } } else { iframeSrc = self.actionUrl + '?defaultImgState=' + self.defaultImgState; } } else { if (self.parentSiteUrl) { if (self.parentSiteUrl.includes("?")) { iframeSrc = self.actionUrl + '?parentSiteUrl=' + self.parentSiteUrl.replace('?', '&'); } else { iframeSrc = self.actionUrl; } } else { iframeSrc = self.actionUrl; } } self.iframe.src = filterDeprecatedParams(iframeSrc); openPopup(); } }, /* private method */ closePopup: function () { var self = this; self.clRemoveClass(self.body,'___iframe_widget_body'); self.clRemoveClass(self.popupBlock,'active'); setTimeout(function () { self.popupBlock.style.display = 'none'; self.iframe.setAttribute('src', ''); }, 500); }, /* private method */ setCss: function () { var style = document.createElement('style'); style.setAttribute('type', 'text/css'); if ( style.styleSheet ) { style.styleSheet.cssText = this.cssText; } else { style.appendChild(document.createTextNode(this.cssText)); } var head = document.head || document.getElementsByTagName('head')[0]; head.appendChild(style); }, /* private method */ setBlocks: function () { this.body = document.body || document.getElementsByTagName('body')[0]; this.iframe = document.createElement('iframe'); this.iframe.setAttribute('src', this.urlIframe); this.iframe.setAttribute('name', this.nameIframe); this.iframe.setAttribute('scrolling', 'no'); this.iframe.className = '___iframe_widget__iframe ' + this.selectorWidget; this.innerBlock = document.createElement('div'); this.innerBlock.className = '___iframe_widget__inner ' + this.selectorInner; this.buttonClose = document.createElement('div'); if (window.location.origin.includes("vassatrend")) { this.buttonClose.className = '___iframe_widget__close vassatrend_close ' + this.selectorClose; } else { this.buttonClose.className = '___iframe_widget__close ' + this.selectorClose; } this.buttonClose.innerHTML = this.closeSvg; this.popupBlock = document.createElement('div'); this.popupBlock.className = '___iframe_widget ' + this.selectorPopupBlock; this.popupBlock.style.display = 'none'; this.contentBlock = document.createElement('div'); this.contentBlock.className = '___iframe_widget__content'; this.contentBlock.appendChild(this.buttonClose); this.contentBlock.appendChild(this.innerBlock); var overlay = document.createElement('div'); overlay.className = '___iframe_widget__overlay'; var modal = document.createElement('div'); modal.className = '___iframe_widget__modal'; modal.appendChild(this.contentBlock); this.popupBlock.appendChild(overlay); this.popupBlock.appendChild(modal); this.body.appendChild(this.popupBlock); }, /* @todo need refactoring */ initCloseEvent: function () { var self = this; var partnerColor = this.partnerColor; this.buttonClose.addEventListener("click", function () { var c1 = 'c1_' + self.mark; var c2 = 'c2_' + self.mark; var c3 = 'c3_' + self.mark; var c4 = 'c4_' + self.mark; var c5 = 'c5_' + self.mark; var template = document.createElement('div'); template.innerHTML = `
${self.langData[self.currentLanguage].close_widget}