Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -128,32 +128,47 @@ modal_and_cart_js = """
|
|
| 128 |
"Veg Manchurian": 12
|
| 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 |
const modal = document.getElementById('modal');
|
| 137 |
-
modal.style.display = 'block';
|
| 138 |
modal.style.position = 'fixed';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
if (window.innerWidth <= 768) {
|
|
|
|
| 140 |
modal.style.width = '90%';
|
| 141 |
-
modal.style.top = `${event.touches ? event.touches[0].screenY : event.clientY}px`;
|
| 142 |
} else {
|
|
|
|
| 143 |
modal.style.width = '30%';
|
| 144 |
-
|
|
|
|
| 145 |
}
|
|
|
|
| 146 |
modal.style.left = '50%';
|
| 147 |
-
modal.style.transform = 'translate(-50%, 0)';
|
|
|
|
|
|
|
| 148 |
document.getElementById('modal-image').src = image;
|
| 149 |
document.getElementById('modal-name').innerText = name;
|
| 150 |
document.getElementById('modal-description').innerText = description;
|
| 151 |
document.getElementById('modal-price').innerText = price;
|
|
|
|
|
|
|
| 152 |
const extrasInputs = document.querySelectorAll('input[name="biryani-extra"]');
|
| 153 |
extrasInputs.forEach(input => input.checked = false);
|
| 154 |
document.getElementById('quantity').value = 1;
|
| 155 |
document.getElementById('special-instructions').value = '';
|
| 156 |
}
|
|
|
|
| 157 |
function closeModal() {
|
| 158 |
document.getElementById('modal').style.display = 'none';
|
| 159 |
}
|
|
|
|
| 128 |
"Veg Manchurian": 12
|
| 129 |
};
|
| 130 |
let finalized = false;
|
| 131 |
+
function openModal(name, image, description, price, event) {
|
| 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 |
+
modal.style.display = 'block'; // Display the modal
|
| 139 |
modal.style.position = 'fixed';
|
| 140 |
+
|
| 141 |
+
// Reduce modal height for better display
|
| 142 |
+
modal.style.height = '50%'; // Adjust height to 50% of the viewport
|
| 143 |
+
modal.style.overflowY = 'auto'; // Add scrolling if content overflows
|
| 144 |
+
|
| 145 |
if (window.innerWidth <= 768) {
|
| 146 |
+
// Mobile: Use touch Y position
|
| 147 |
modal.style.width = '90%';
|
| 148 |
+
modal.style.top = `${event.touches ? event.touches[0].screenY : event.clientY - modal.offsetHeight / 2}px`;
|
| 149 |
} else {
|
| 150 |
+
// Laptop: Use mouse Y position without 7%
|
| 151 |
modal.style.width = '30%';
|
| 152 |
+
const adjustedY = event.clientY - modal.offsetHeight / 2; // Center based on modal height
|
| 153 |
+
modal.style.top = `${adjustedY}px`;
|
| 154 |
}
|
| 155 |
+
|
| 156 |
modal.style.left = '50%';
|
| 157 |
+
modal.style.transform = 'translate(-50%, 0)'; // Adjust transform to exclude vertical centering
|
| 158 |
+
|
| 159 |
+
// Set 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 |
+
// Reset inputs
|
| 166 |
const extrasInputs = document.querySelectorAll('input[name="biryani-extra"]');
|
| 167 |
extrasInputs.forEach(input => input.checked = false);
|
| 168 |
document.getElementById('quantity').value = 1;
|
| 169 |
document.getElementById('special-instructions').value = '';
|
| 170 |
}
|
| 171 |
+
|
| 172 |
function closeModal() {
|
| 173 |
document.getElementById('modal').style.display = 'none';
|
| 174 |
}
|