window.addEventListener('DOMContentLoaded', function() { jQuery(document).ready(function($) { // Function to open the modal dialog function openModal(url) { var modal = document.getElementById('custom-modal'); var iframe = modal.querySelector('iframe'); var title = modal.querySelector('.modal-title'); var loadingOverlay = modal.querySelector('.loading-overlay'); // Get the loading overlay element // Show loading overlay loadingOverlay.style.display = 'flex'; iframe.src = url; title.innerHTML = 'CHECKOUT'; // Wait for the iframe to load iframe.onload = function() { // Hide loading overlay once the iframe is loaded loadingOverlay.style.display = 'none'; }; modal.style.display = 'block'; } // Function to close the modal dialog function closeModal() { var modal = document.getElementById('custom-modal'); modal.style.display = 'none'; } // Attach click event handlers to specific buttons $('.elementor-button-link').on('click', function(e) { e.preventDefault(); var buttonText = $(this).text().toLowerCase(); // Get the button text in lowercase if (buttonText.includes("buy now") || buttonText.includes("order now") || buttonText.includes("purchase")) { var url = $(this).attr('href'); // Get the URL from the button's href attribute openModal(url); } }); // Close the modal when the close button is clicked $('.close-modal').on('click', function() { closeModal(); }); }); });