' + '';
document.body.insertAdjacentHTML('beforeend', modal);
const cpModalheader = document.querySelector('.cp-modal-header');
if (cpModalheader) {
cpModalheader.insertAdjacentHTML('afterend', '' + cta.outerHTML + '
');
closeListeners();
}
document.body.classList.add('cp-modal-open');
}
function removeCtModal() {
const modal = document.querySelector('.cp-modal');
if (modal) {
modal.remove();
document.body.classList.remove('cp-modal-open');
}
}
document.addEventListener('DOMContentLoaded', function () {
/* Get page parameters */
const getUrlParam = param => new URLSearchParams(window.location.search).get(param);
const getOffsetTop = element => {
let offsetTop = 0;
while (element) {
offsetTop += element.offsetTop;
element = element.offsetParent;
}
return offsetTop;
};
/* Display cta zone in modal if called by url */
let current_cta = getUrlParam('cta');
if (current_cta) {
const cta = document.querySelector('#cta-' + current_cta);
if (cta) {
appendCtModal(cta);
}
}
let coupon_copied = getUrlParam('cpid');
if (coupon_copied) {
const coupon = document.querySelector('#cta-' + coupon_copied);
if (coupon) {
const couponBonusCode = coupon.querySelector('[class*="bonus-code"]');
const value = couponBonusCode.querySelector('[class*="value"] span');
const valueCopied = value.dataset.copiedtext;
const button = couponBonusCode.querySelector('[class*="button"]');
button.innerHTML = valueCopied;
couponBonusCode.classList.add('copied');
}
}
/* --------- Bonus code sticky --------- */
const bookmakerCta = document.querySelector('div[data-coupon][data-sticky]:not(.lightmode)');
if (bookmakerCta) {
if (screen.width < 767) {
const bookmakerCtaHeight = bookmakerCta.offsetHeight;
bookmakerCta.style.height = bookmakerCtaHeight + 'px';
let initialScrollEvent = true;
let couponStickyBottom = '0px';
let observer = new MutationObserver(function (m) {
if (m[0].addedNodes[0]) {
if (m[0].addedNodes[0].nodeName === 'DIV') {
const bodyElements = document.querySelectorAll('body > *');
bodyElements.forEach(bodyElement => {
const bodyElementStyles = window.getComputedStyle(bodyElement);
if (bodyElementStyles.getPropertyValue('position') == 'fixed' && bodyElementStyles.getPropertyValue('bottom') == '0px' && bodyElementStyles.getPropertyValue('display') != 'none' && bodyElementStyles.getPropertyValue('visibility') != 'hidden' && bodyElementStyles.getPropertyValue('opacity') != '0' && !bodyElement.classList.contains('cp-modal') && bodyElement instanceof HTMLElement) {
setTimeout(() => {
if (bodyElementStyles.getPropertyValue('height') > couponStickyBottom) {
couponStickyBottom = bodyElementStyles.getPropertyValue('height');
}
}, 500);
}
});
}
}
});
observer.observe(document.body, {
childList: true
});
window.addEventListener('scroll', function () {
if (!initialScrollEvent) {
const bookmakerCtaRow = bookmakerCta.querySelector('[class$="row"]');
if (window.scrollY >= getOffsetTop(bookmakerCta) + bookmakerCta.offsetHeight) {
bookmakerCta.classList.add('sticky');
bookmakerCtaRow.style.bottom = couponStickyBottom;
} else {
bookmakerCta.classList.remove('sticky');
bookmakerCtaRow.style.bottom = '0px';
}
}
initialScrollEvent = false;
});
if (window.scrollY >= getOffsetTop(bookmakerCta) + bookmakerCta.offsetHeight) {
const bookmakerCtaRow = bookmakerCta.querySelector('[class$="row"]');
bookmakerCta.classList.add('sticky');
bookmakerCtaRow.style.bottom = couponStickyBottom;
} else {
const bookmakerCtaRow = bookmakerCta.querySelector('[class$="row"]');
bookmakerCta.classList.remove('sticky');
bookmakerCtaRow.style.bottom = '0px';
}
}
window.addEventListener('resize', function () {
if (screen.width > 767 && bookmakerCta) {
bookmakerCta.classList.remove('sticky');
}
});
}
/*
* text mode script
*/
document.querySelectorAll('.textmode').forEach(element => {
element.addEventListener('click', function () {
if (!this.dataset.clicked) {
const elementWidth = this.offsetWidth + 'px';
this.style.width = elementWidth;
const textArea = document.createElement('textarea');
textArea.value = this.textContent.trim();
document.body.appendChild(textArea);
textArea.select();
document.execCommand('copy');
document.body.removeChild(textArea);
this.classList.add('clicked');
this.textContent = this.dataset.copy;
this.dataset.clicked = 'true';
setTimeout(() => {
this.textContent = this.dataset.visit;
}, 1000);
} else {
const url = decodeURIComponent(escape(atob(this.dataset.url)));
if (this.dataset.target === '0') {
window.open(url, '_blank');
} else {
window.location.href = url;
}
}
});
});
});
/******/ })()
;
//# sourceMappingURL=general.5653c57d2dc1e16647a9.js.map