Spaces:
Sleeping
Sleeping
Update app.py
Browse files140 unmodified lines14114214314414414514614718 unmodified lines1661671681691691701711721731741751761771781791801811821834 unmodified lines188189190191192193194195196197198140 unmodified lines
# JavaScript for managing the pop-up gr.HTML(f""" <div id="popup" style="display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); <div id="popup" style="display: none; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: white; padding: 20px; border-radius: 10px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); z-index: 1000; text-align: center; width: 500px;"> <img id="popup-image" src="" alt="" style="width: 100%; height: auto; border-radius: 10px;">18 unmodified lines color: white; border: none; border-radius: 5px; cursor: pointer;">Close</button> </div> <script> function showPopup(image, title, description, price) { function showPopup(event, (image, title, description, price)) { document.getElementById('popup-image').src = image; document.getElementById('popup-title').textContent = title; document.getElementById('popup-description').textContent = description; document.getElementById('popup-price').textContent = "Price: " + price;
// Set the position of the popup
popup.style.left = `${event.pageX + 10}px`; // Add a small offset popup.style.top = `${event.pageY + 10}px`; // Add a small offset
// Display the popup document.getElementById('popup').style.display = 'block'; }4 unmodified lines const selectedExtras = Array.from(document.querySelectorAll('input[name=extras]:checked')).map(cb => cb.value).join(", "); alert(dishName + " with " + spiceLevel + " spice level and extras: " + selectedExtras + " has been added to the cart!"); }
const menuItems = document.querySelectorAll('.menu-item'); menuItems.forEach(item => {item.addEventListener('click', function(event) {showPopup(event, item.getAttribute('data-name')); });}); </script> """)
app.py+13-2