Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -129,43 +129,34 @@ modal_and_cart_js = """
|
|
| 129 |
};
|
| 130 |
let finalized = false;
|
| 131 |
function openModal(name, image, description, price) {
|
| 132 |
-
if (finalized) {
|
| 133 |
-
alert("You cannot add more items after finalizing your order.");
|
| 134 |
-
return;
|
| 135 |
-
}
|
| 136 |
-
|
| 137 |
const modal = document.getElementById('modal');
|
| 138 |
-
const buttonRect = event.target.getBoundingClientRect();
|
| 139 |
|
| 140 |
-
// Set modal width based on device size
|
| 141 |
if (window.innerWidth <= 768) {
|
| 142 |
-
modal.style.width = '90%';
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
const modalWidth = modal.offsetWidth;
|
| 148 |
-
const modalHeight = modal.offsetHeight;
|
| 149 |
|
| 150 |
-
|
| 151 |
-
const
|
| 152 |
-
const modalLeft = window.scrollX + buttonRect.left + buttonRect.width / 2 - modalWidth / 2;
|
| 153 |
|
| 154 |
-
// Apply positioning styles
|
| 155 |
modal.style.display = 'block';
|
|
|
|
| 156 |
modal.style.top = `${modalTop}px`;
|
| 157 |
modal.style.left = `${modalLeft}px`;
|
| 158 |
|
| 159 |
-
// Populate modal content
|
| 160 |
-
document.getElementById('modal-image').src = image;
|
| 161 |
document.getElementById('modal-name').innerText = name;
|
|
|
|
| 162 |
document.getElementById('modal-description').innerText = description;
|
| 163 |
document.getElementById('modal-price').innerText = `$${price}`;
|
|
|
|
| 164 |
|
| 165 |
-
|
| 166 |
-
document.getElementById('
|
| 167 |
-
document.getElementById('special-instructions').value = '';
|
| 168 |
}
|
|
|
|
|
|
|
| 169 |
|
| 170 |
function closeModal() {
|
| 171 |
document.getElementById('modal').style.display = 'none';
|
|
@@ -335,8 +326,8 @@ def app():
|
|
| 335 |
|
| 336 |
# Modal window
|
| 337 |
modal_window = gr.HTML("""
|
| 338 |
-
|
| 339 |
-
|
| 340 |
<button onclick="closeModal()" style="background: none; border: none; font-size: 18px; cursor: pointer;">×</button>
|
| 341 |
</div>
|
| 342 |
<img id="modal-image" style="width: 100%; height: auto; border-radius: 8px; margin-bottom: 20px;" />
|
|
|
|
| 129 |
};
|
| 130 |
let finalized = false;
|
| 131 |
function openModal(name, image, description, price) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
const modal = document.getElementById('modal');
|
| 133 |
+
const buttonRect = event.target.getBoundingClientRect();
|
| 134 |
|
|
|
|
| 135 |
if (window.innerWidth <= 768) {
|
| 136 |
+
modal.style.width = '90%';
|
| 137 |
+
} else {
|
| 138 |
+
modal.style.width = '30%';
|
| 139 |
+
}
|
|
|
|
|
|
|
|
|
|
| 140 |
|
| 141 |
+
const modalTop = window.scrollY + buttonRect.top + buttonRect.height + 20;
|
| 142 |
+
const modalLeft = window.scrollX + buttonRect.left + buttonRect.width / 2 - modal.offsetWidth / 2;
|
|
|
|
| 143 |
|
|
|
|
| 144 |
modal.style.display = 'block';
|
| 145 |
+
modal.style.position = 'absolute';
|
| 146 |
modal.style.top = `${modalTop}px`;
|
| 147 |
modal.style.left = `${modalLeft}px`;
|
| 148 |
|
|
|
|
|
|
|
| 149 |
document.getElementById('modal-name').innerText = name;
|
| 150 |
+
document.getElementById('modal-image').src = image;
|
| 151 |
document.getElementById('modal-description').innerText = description;
|
| 152 |
document.getElementById('modal-price').innerText = `$${price}`;
|
| 153 |
+
}
|
| 154 |
|
| 155 |
+
function closeModal() {
|
| 156 |
+
document.getElementById('modal').style.display = 'none';
|
|
|
|
| 157 |
}
|
| 158 |
+
</script>
|
| 159 |
+
|
| 160 |
|
| 161 |
function closeModal() {
|
| 162 |
document.getElementById('modal').style.display = 'none';
|
|
|
|
| 326 |
|
| 327 |
# Modal window
|
| 328 |
modal_window = gr.HTML("""
|
| 329 |
+
<div id="modal" style="display: none; position: absolute; background: white; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); padding: 20px; z-index: 1000;">
|
| 330 |
+
<div style="text-align: right;">
|
| 331 |
<button onclick="closeModal()" style="background: none; border: none; font-size: 18px; cursor: pointer;">×</button>
|
| 332 |
</div>
|
| 333 |
<img id="modal-image" style="width: 100%; height: auto; border-radius: 8px; margin-bottom: 20px;" />
|