Update templates/menu.html
Browse files- templates/menu.html +31 -6
templates/menu.html
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
|
2 |
<html lang="en">
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
@@ -1593,13 +1593,12 @@
|
|
1593 |
const suggestionsContainer = document.getElementById('autocompleteSuggestions');
|
1594 |
const debouncedFilterMenu = debounce(filterMenu, 300);
|
1595 |
|
1596 |
-
//
|
1597 |
searchBar.addEventListener('click', function (event) {
|
1598 |
event.stopPropagation();
|
1599 |
window.location.href = '/search';
|
1600 |
});
|
1601 |
|
1602 |
-
// Existing input event listener for autocomplete and filtering
|
1603 |
searchBar.addEventListener('input', function () {
|
1604 |
const input = sanitizeInput(this.value.trim().toLowerCase());
|
1605 |
suggestionsContainer.innerHTML = '';
|
@@ -1626,7 +1625,6 @@
|
|
1626 |
debouncedFilterMenu();
|
1627 |
});
|
1628 |
|
1629 |
-
// Close suggestions when clicking outside
|
1630 |
document.addEventListener('click', function (event) {
|
1631 |
if (!searchBar.contains(event.target) && !suggestionsContainer.contains(event.target)) {
|
1632 |
suggestionsContainer.style.display = 'none';
|
@@ -1687,7 +1685,6 @@
|
|
1687 |
});
|
1688 |
}
|
1689 |
|
1690 |
-
// Custom Dish Form Validation
|
1691 |
const customDishForm = document.getElementById('customDishForm');
|
1692 |
if (customDishForm) {
|
1693 |
customDishForm.addEventListener('submit', function(event) {
|
@@ -1874,7 +1871,7 @@
|
|
1874 |
micUnsupported.style.display = 'block';
|
1875 |
}
|
1876 |
|
1877 |
-
// Highlight item from search redirect
|
1878 |
const highlightItem = "{{ highlight_item | e }}";
|
1879 |
if (highlightItem) {
|
1880 |
const itemElement = document.querySelector(`[data-item-name="${highlightItem}"]`);
|
@@ -1884,6 +1881,33 @@
|
|
1884 |
setTimeout(() => {
|
1885 |
itemElement.style.backgroundColor = ''; // Remove highlight after 2 seconds
|
1886 |
}, 2000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1887 |
}
|
1888 |
}
|
1889 |
});
|
@@ -2060,3 +2084,4 @@
|
|
2060 |
</script>
|
2061 |
</body>
|
2062 |
</html>
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
<html lang="en">
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
|
|
1593 |
const suggestionsContainer = document.getElementById('autocompleteSuggestions');
|
1594 |
const debouncedFilterMenu = debounce(filterMenu, 300);
|
1595 |
|
1596 |
+
// Redirect to search page on click
|
1597 |
searchBar.addEventListener('click', function (event) {
|
1598 |
event.stopPropagation();
|
1599 |
window.location.href = '/search';
|
1600 |
});
|
1601 |
|
|
|
1602 |
searchBar.addEventListener('input', function () {
|
1603 |
const input = sanitizeInput(this.value.trim().toLowerCase());
|
1604 |
suggestionsContainer.innerHTML = '';
|
|
|
1625 |
debouncedFilterMenu();
|
1626 |
});
|
1627 |
|
|
|
1628 |
document.addEventListener('click', function (event) {
|
1629 |
if (!searchBar.contains(event.target) && !suggestionsContainer.contains(event.target)) {
|
1630 |
suggestionsContainer.style.display = 'none';
|
|
|
1685 |
});
|
1686 |
}
|
1687 |
|
|
|
1688 |
const customDishForm = document.getElementById('customDishForm');
|
1689 |
if (customDishForm) {
|
1690 |
customDishForm.addEventListener('submit', function(event) {
|
|
|
1871 |
micUnsupported.style.display = 'block';
|
1872 |
}
|
1873 |
|
1874 |
+
// Highlight and open modal for item from search redirect
|
1875 |
const highlightItem = "{{ highlight_item | e }}";
|
1876 |
if (highlightItem) {
|
1877 |
const itemElement = document.querySelector(`[data-item-name="${highlightItem}"]`);
|
|
|
1881 |
setTimeout(() => {
|
1882 |
itemElement.style.backgroundColor = ''; // Remove highlight after 2 seconds
|
1883 |
}, 2000);
|
1884 |
+
|
1885 |
+
// Find the ADD button and trigger the appropriate modal
|
1886 |
+
const addButton = itemElement.querySelector('.btn-primary');
|
1887 |
+
const buttonContainer = addButton.closest('.button-container');
|
1888 |
+
const section = buttonContainer.getAttribute('data-item-section');
|
1889 |
+
|
1890 |
+
if (section === 'Soft Drinks') {
|
1891 |
+
showSoftDrinkModal(addButton);
|
1892 |
+
} else {
|
1893 |
+
const name = sanitizeInput(buttonContainer.getAttribute('data-item-name'));
|
1894 |
+
const price = buttonContainer.getAttribute('data-item-price');
|
1895 |
+
const image = buttonContainer.getAttribute('data-item-image');
|
1896 |
+
const category = buttonContainer.getAttribute('data-item-category');
|
1897 |
+
// Use data from the button's onclick attribute or fetch from server
|
1898 |
+
const onclickAttr = addButton.getAttribute('onclick');
|
1899 |
+
if (onclickAttr) {
|
1900 |
+
const argsMatch = onclickAttr.match(/showItemDetails\((.*?)\)/);
|
1901 |
+
if (argsMatch) {
|
1902 |
+
const args = argsMatch[1].split(',').map(arg => arg.trim().replace(/['"]/g, ''));
|
1903 |
+
const [name, price, image, description, ingredients, nutrition, allergens, section, category] = args;
|
1904 |
+
showItemDetails(name, price, image, description, ingredients, nutrition, allergens, section, category);
|
1905 |
+
}
|
1906 |
+
} else {
|
1907 |
+
// Fallback if onclick isn't sufficient
|
1908 |
+
showItemDetails(name, price, image, 'No description available', 'Not specified', 'Not available', 'None listed', section, category);
|
1909 |
+
}
|
1910 |
+
}
|
1911 |
}
|
1912 |
}
|
1913 |
});
|
|
|
2084 |
</script>
|
2085 |
</body>
|
2086 |
</html>
|
2087 |
+
|