if(document.getElementById('close-button')) { document.getElementById('close-button').addEventListener('click', function (e) { closeStickyBar(e); }) } var closeSBLinks = document.getElementsByClassName('fr-close-sticky-bar-link'); Array.from(closeSBLinks).forEach(function(element) { element.addEventListener('click', function(e) { closeStickyBar(e); }); }); function closeStickyBar(e){ e.preventDefault(); window.parent.document.getElementById("placeholderId").style.display = 'none'; window.parent.document.getElementById('show-st').style.visibility = 'visible'; if(+document.sticky.stickybar_type == 3){ // This check for ThirdParty we have two Iframe that's why overflow: hidden is using for ThirdParty. window.parent.document.body.style.overflow = 'hidden'; }else{ // My lead funnel & My Own Website Case window.parent.document.body.style.overflowY = 'auto'; window.parent.document.body.style.overflowX = 'hidden'; } try { window.parent.postMessage('lpStickyClosed', '*') } catch (e) {} } // If not Exit Intend then we will call this function Otherwise setTimeOut will be set when Exits Intend will called from main.js. if(document.sticky.intend != '0'){ setCloseIconSetTimeOut(); } var ctaMultiButtons = document.getElementsByClassName('sb-sticky-bar__btn'); Array.from(ctaMultiButtons).forEach(function(element, index) { element.addEventListener('click', function(e) { let currentButton = element.getAttribute('data-stickybar-button'); if (document.sticky && document.sticky.ctaButtons[currentButton].buttonType == '1' && document.sticky.ctaButtons[currentButton].isFancyBox == '1') { // Funnel Case e.preventDefault(); if(document.sticky.ctaButtons[currentButton].domain){ window.parent.showFunnelInIframe(document.sticky.ctaButtons[currentButton].domain); } } if (document.sticky && document.sticky.ctaButtons[currentButton].buttonType === '4') { closeStickyBar(e); } }); }); function onWindowResize() { if(document.querySelector('.sb-sticky-bar__close')) { var scrollBarWidth = window.parent.innerWidth - window.parent.document.body.clientWidth if(document.sticky.stickybar_style != "leadpax"){ document.querySelector('.sb-sticky-bar .sb-sticky-bar__close').style.right = 38 + (scrollBarWidth / 2) + 'px'; } } } onWindowResize() window.onresize = onWindowResize; function getFontFamilies (){ const regex = /font-family:.+?;/gm; var stickyBarClass = ".sb-sticky-bar"; if(document.sticky.stickybar_style == "leadpax") { stickyBarClass = ".sb-leadpax-box" } const str = $(stickyBarClass).html().replace(/"/g,''); let m; let a = []; while ((m = regex.exec(str)) !== null) { // This is necessary to avoid infinite loops with zero-width matches if (m.index === regex.lastIndex) { regex.lastIndex++; } // The result can be accessed through the `m`-variable. m.forEach((match, groupIndex) => { let value = $.trim(match.replace('font-family:','').replace(';',':ital,wght@0,300;0,400;0,700;1,400;1,700')); if(a.indexOf(value) == -1){ a.push(value); } }); WebFontConfig = { google: { families: a } }; var wf = document.createElement('script'); wf.src = 'https://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js'; wf.type = 'text/javascript'; wf.async = true; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(wf, s); } } /** * get title,button, and content font size and set the object * @param $element * @param target * @returns {{}} */ function getChildrenToChangeFontSize($element, target = '') { let elements = {}; jQuery.each($element, function(i, childWithStyle){ let arr = []; jQuery.each(jQuery(this).find('.fr-view p [style]'), function(k, buttonEle){ let fontSize = parseInt(buttonEle.style.fontSize); if(fontSize > 0) { arr.push({ el: buttonEle.tagName.toLowerCase()+'-'+k, fontSize: fontSize }); if(target == 'button') { elements[`button_${i}`] = arr; } else{ elements = arr; } } }); }); return elements; } /** * load font size when load the Rebel Local * @param e */ function loadFontSize(e) { fontHandler = { 'heading': getChildrenToChangeFontSize(jQuery('.sb-sticky-bar__p')), 'button': getChildrenToChangeFontSize(jQuery('.sb-sticky-bar .sb-sticky-bar__btn'),'button'), 'description': getChildrenToChangeFontSize(jQuery('.sb-sticky-bar__content__p')) } } /** * font set on button, title and content html elements on desktop and mobile devices * @param e * @returns {boolean} */ function fontChanges() { if(typeof fontHandler !== "object") { return false; } jQuery.each(fontHandler, function (key, obj) { if(Object.keys(obj).length){ if(key == 'button'){ jQuery.each(obj, function(k, ele){ k = k.replaceAll('button_',''); setFontSize(ele,'#sb-sticky-bar__btn'+k); }); } else{ let selector = '.sb-sticky-bar__content__p'; if(key == 'heading'){ selector = '.sb-sticky-bar__p'; } setFontSize(obj,selector); } } }); } /** * if device is mobile/tablet so will reduce the 25% font size other than set font size which one getting from DB * @param data * @param ele */ function setFontSize(data, ele){ let isDesktop = true; if(window.outerWidth < 768) { isDesktop = false; } jQuery.each(data, function(e, s){ let tag_key = s.el.split('-'); let font_size = (isDesktop)?s.fontSize:s.fontSize*0.75; jQuery(jQuery(ele).find(".fr-view p [style]")[tag_key[1]]).css("font-size",font_size); }); } // Set Timeout ON the CLose Icon function setCloseIconSetTimeOut(){ // Close Button is not exists in the leadPax. if(document.getElementById('close-button') != null){ if (document.sticky && (document.sticky.hide_page == true || document.sticky.hide_page == "true")) { let stickyInterval = document.sticky.hided === '1' ? 0 : parseInt(document.sticky.hided) * 1000; if(document.sticky.intend != '1' && document.sticky.intend != '0'){ let timeInterval = {'2': 5, '3': 10, '4': 20, '5': 30, '6': 45, '7': 60}; stickyInterval = stickyInterval + (timeInterval[document.sticky.intend] * 1000); } setTimeout(() => { document.getElementById('close-button').style.display = 'block'; }, stickyInterval); } } }