function modifyVideos(){
const videoPlayers=document.querySelectorAll("iframe[src*='youtube.com'], .elementor-video",
);
videoPlayers.forEach((elem)=> {
elem.classList.add("rbx-shadow", "rbx-corner-br", "rbx-corner-auto");
});
}
function setCornerSize(){
const autoCornerSizeElements=document.querySelectorAll(".rbx-corner-auto");
autoCornerSizeElements.forEach((element)=> {
let cornerSize=element.offsetWidth / 10;
if(element.offsetWidth <=element.offsetHeight){
cornerSize=element.offsetWidth / 6;
}
element.setAttribute("style",
`--rbx-corner-size: ${cornerSize}px !important;`,
);
});
}
function getComputedStyleColor(element, property){
return window.getComputedStyle(element, null).getPropertyValue(property);
}
function applyCSSColorAsFill(){
const svgPathElements=document.querySelectorAll("path.cls-1");
svgPathElements.forEach((element)=> {
element.style.fill=null;
});
const svgElements=document.querySelectorAll("svg");
svgElements.forEach((element)=> {
const fillColor=getComputedStyleColor(element, "color");
const svgPaths=element.querySelectorAll("path");
svgPaths.forEach((path)=> {
if(fillColor&&fillColor!=="none"){
if(path.getAttribute("stroke")){
path.setAttribute("stroke", fillColor);
}else{
path.setAttribute("fill", fillColor);
}}
});
});
}
let gradientIdx=0;
function applySVGGradient(){
const svgGradientElements=document.querySelectorAll(".rbx-svg-gradient svg",
);
svgGradientElements.forEach((element, idx)=> {
if(!element.querySelector("defs")){
const defs=document.createElementNS("http://www.w3.org/2000/svg",
"defs",
);
element.appendChild(defs);
}
const gradientDef=`
<linearGradient id="rbx-svg-gradient-${gradientIdx + 1000}">
<stop offset="-100%" stop-color="#FFD74A" />
<stop offset="100%" stop-color="#DB2B0B" />
</linearGradient>
`;
element.querySelector("defs").innerHTML +=gradientDef;
const svgPaths=element.querySelectorAll("path");
svgPaths.forEach((path)=> {
if(!!path.getAttribute("stroke")){
path.setAttribute("stroke",
`url(#rbx-svg-gradient-${gradientIdx + 1000})`,
);
}else{
path.setAttribute("fill",
`url(#rbx-svg-gradient-${gradientIdx + 1000})`,
);
}});
gradientIdx +=1;
});
}
function applyEmptyLinkWorkaround(){
const emptyLinks=document.querySelectorAll(".elementor-button-link[href=''], .elementor-button-link[href='#']",
);
emptyLinks.forEach((link)=> {
link.classList.remove("elementor-animation-grow");
link.style.backgroundColor="transparent";
link.style.cursor="default";
link.addEventListener("click", (e)=> {
e.preventDefault();
});
});
}
let currentIntegrationFilter=null;
function initIntegrationFilter(){
if(!document.getElementById("integration-filter")){
return;
}
const showAllButton=document.getElementById("show-all-integrations");
const showAllContainer=document.getElementById("show-all-integrations-container",
);
const filterButtons=document.querySelectorAll("#integration-filter .rbx-button-rainbow a",
);
const loopContainer=document.querySelectorAll("div[data-loop]");
const headingItems=document.querySelectorAll("div[data-heading]");
function resetAll(){
loopContainer.forEach((item)=> {
item.style.display="block";
});
headingItems.forEach((item)=> {
item.style.display="flex";
});
filterButtons.forEach((otherBtns)=> {
otherBtns.closest(".rbx-button-rainbow").classList.remove("inactive");
});
currentIntegrationFilter=null;
showAllContainer.classList.remove("visible");
}
showAllButton.addEventListener("click", (e)=> {
e.preventDefault();
resetAll();
});
filterButtons.forEach((button)=> {
button.addEventListener("click", (e)=> {
e.preventDefault();
const type=e.target.textContent.trim().toLowerCase();
if(type===currentIntegrationFilter){
resetAll();
return;
}
filterButtons.forEach((otherBtns)=> {
if(otherBtns.textContent.trim().toLowerCase()===type){
button.closest(".rbx-button-rainbow").classList.remove("inactive");
}else{
otherBtns.closest(".rbx-button-rainbow").classList.add("inactive");
}});
loopContainer.forEach((item)=> {
if(item.getAttribute("data-loop").trim().toLowerCase()===type){
item.style.display="block";
}else{
item.style.display="none";
}});
headingItems.forEach((item)=> {
if(item.getAttribute("data-heading").trim().toLowerCase()===type){
item.style.display="flex";
}else{
item.style.display="none";
}});
currentIntegrationFilter=type;
showAllContainer.classList.add("visible");
});
});
}
function initPricingToggle(){
const btnsMonthly=document.querySelectorAll(".btn-price-month");
const btnsYearly=document.querySelectorAll(".btn-price-year");
if(!btnsMonthly.length||!btnsYearly.length){
return;
}
document.querySelectorAll(".price-year").forEach((el)=> {
el.style.display=btnsMonthly[0].classList.contains("inactive")
? "flex"
: "none";
});
document.querySelectorAll(".price-month").forEach((el)=> {
el.style.display=btnsYearly[0].classList.contains("inactive")
? "flex"
: "none";
});
btnsMonthly.forEach((btnMonthly)=> {
btnMonthly.addEventListener("click", (e)=> {
e.preventDefault();
btnsMonthly.forEach((btn)=> btn.classList.remove("inactive"));
btnsYearly.forEach((btn)=> btn.classList.add("inactive"));
document.querySelectorAll(".price-year").forEach((el)=> {
el.style.display="none";
});
document.querySelectorAll(".price-month").forEach((el)=> {
el.style.display="flex";
});
});
});
btnsYearly.forEach((btnYearly)=> {
btnYearly.addEventListener("click", (e)=> {
e.preventDefault();
btnsYearly.forEach((btn)=> btn.classList.remove("inactive"));
btnsMonthly.forEach((btn)=> btn.classList.add("inactive"));
document.querySelectorAll(".price-month").forEach((el)=> {
el.style.display="none";
});
document.querySelectorAll(".price-year").forEach((el)=> {
el.style.display="flex";
});
});
});
}
function initPricingTableShowMore(){
const showMoreButtons=document.querySelectorAll(".btn-pricing-show-all");
showMoreButtons.forEach((button)=> {
button.addEventListener("click", (e)=> {
e.preventDefault();
document
.querySelectorAll(".rbx-pricing-container.collapsed")
.forEach((table)=> {
table.classList.remove("collapsed");
});
document.querySelectorAll(".btn-pricing-show-all").forEach((btn)=> {
btn.style.display="none";
});
});
});
}
function fixIconBoxLinks(){
const iconBoxes=document.querySelectorAll(".elementor-icon-box-wrapper");
iconBoxes.forEach((iconBox)=> {
const link=iconBox.querySelector("a");
const description=iconBox.querySelector(".elementor-icon-box-description",
);
if(link&&description){
description.addEventListener("click", ()=> {
window.location.href=link.getAttribute("href");
});
description.style.cursor="pointer";
}});
}
function initRegistrationFormSubmitEvent(){
document.addEventListener("submit_success", function (e, data){
console.log("Form submitted successfully", e, data);
});
}
function loadTrGtm(){
fetch("/wp-admin/admin-ajax.php?action=geoip_detect2_get_info_from_current_ip").then((response)=> {
response.json().then((data)=> {
if(data.country.iso_code==="TR"){
const script=document.createElement("script");
script.src="https://www.googletagmanager.com/gtag/js?id=G-T99D32BLDN";
script.async=true;
document.head.appendChild(script);
script.onload=()=> {
const gtmScript=document.createElement("script");
gtmScript.innerHTML=`
window.dataLayer=window.dataLayer||[];
function gtag(){
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'G-T99D32BLDN');
`;
document.head.appendChild(gtmScript);
};
console.log("TR GTM script loaded");
}else{
console.log("Not TR");
}});
});
}
document.addEventListener("DOMContentLoaded", ()=> {
modifyVideos();
setCornerSize();
applyCSSColorAsFill();
applySVGGradient();
initIntegrationFilter();
initPricingToggle();
initPricingTableShowMore();
fixIconBoxLinks();
initRegistrationFormSubmitEvent();
loadTrGtm();
});