Spaces:
Sleeping
Sleeping
Update app.py
Browse files94 unmodified lines959697989910010110210310410519 unmodified lines1251261271281291305 unmodified lines13613713813914014118 unmodified lines16016116216316416516616716816994 unmodified lines# JavaScript for popup modalpopup_js = """<script>function showPopup(name, description, price, image) {const popup = document.getElementById("custom-popup");const overlay = document.getElementById("overlay");popup.innerHTML = `<img src="${image}" alt="${name}" style="width: 100%; height: 200px; align-item:center; border-radius: 10px; margin-bottom: 10px;"><h3 style="margin-top: 10px;">${name}</h3><p>${description}</p><p style="font-weight: bold;">Price: ${price}</p>19 unmodified lines<button onclick="closePopup()" style="margin-top: 20px; padding: 10px 20px; background-color: #007bff; color: white; border: none; border-radius: 5px; cursor: pointer;">Add to Cart</button><button onclick="closePopup()" style="margin-top: 20px; margin-left: 10px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;">Close</button>`;popup.style.display = "block";overlay.style.display = "block";}5 unmodified linesoverlay.style.display = "none";}</script>"""# HTML for popup modal18 unmodified lines</div><div style='flex: 1; text-align: center;'><img src='{dish['image']}' alt='{dish['name']}' style='width: 120px; height: 80px; object-fit: cover; border-radius: 10px;'><button onclick="showPopup('{dish['name']}', '{dish['description']}', '{dish['price']}', '{dish['image']}')"style='margin-top: 10px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;'>Add</button></div></div>"""94 unmodified lines959697989910010110210310410510610710810911011119 unmodified lines1311321331341351361371381391401411425 unmodified lines14814915015115215315418 unmodified lines17317417517617717817918094 unmodified lines# JavaScript for popup modalpopup_js = """<script>function showPopup(name, description, price, image, element) {const popup = document.getElementById("custom-popup");const overlay = document.getElementById("overlay");// Get the bounding rectangle of the clicked elementconst rect = element.getBoundingClientRect();const offsetX = 10; // Offset for better alignmentconst offsetY = 10;popup.innerHTML = `<img src="${image}" alt="${name}" style="width: 200px; height: auto; border-radius: 10px; margin-bottom: 10px;"><h3 style="margin-top: 10px;">${name}</h3><p>${description}</p><p style="font-weight: bold;">Price: ${price}</p>19 unmodified lines<button onclick="closePopup()" style="margin-top: 20px; padding: 10px 20px; background-color: #007bff; color: white; border: none; border-radius: 5px; cursor: pointer;">Add to Cart</button><button onclick="closePopup()" style="margin-top: 20px; margin-left: 10px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;">Close</button>`;// Set popup position based on the clicked elementpopup.style.position = "absolute";popup.style.top = `${rect.top + window.scrollY + offsetY}px`;popup.style.left = `${rect.left + window.scrollX + offsetX}px`;popup.style.display = "block";overlay.style.display = "block";}5 unmodified linesoverlay.style.display = "none";}</script>"""# HTML for popup modal18 unmodified lines</div><div style='flex: 1; text-align: center;'><img src='{dish['image']}' alt='{dish['name']}' style='width: 120px; height: 80px; object-fit: cover; border-radius: 10px;'><button onclick="showPopup('{dish['name']}', '{dish['description']}', '{dish['price']}', '{dish['image']}', this)"style="margin-top: 10px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;">Add</button></div></div>"""
app.py+17-6