Spaces:
Sleeping
Sleeping
Update templates/menu.html
Browse files- templates/menu.html +146 -47
templates/menu.html
CHANGED
|
@@ -40,17 +40,66 @@
|
|
| 40 |
.menu-card.visible {
|
| 41 |
opacity: 1;
|
| 42 |
}
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
height: 200px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
width: 100%;
|
|
|
|
| 46 |
object-fit: cover;
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
opacity: 0;
|
| 49 |
-
transition: opacity 0.
|
| 50 |
}
|
| 51 |
-
|
|
|
|
| 52 |
opacity: 1;
|
| 53 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
.card-title {
|
| 55 |
font-size: 1.2rem;
|
| 56 |
font-weight: bold;
|
|
@@ -672,6 +721,11 @@
|
|
| 672 |
height: 20px;
|
| 673 |
font-size: 10px;
|
| 674 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 675 |
}
|
| 676 |
</style>
|
| 677 |
</head>
|
|
@@ -730,24 +784,28 @@
|
|
| 730 |
{% for item in items %}
|
| 731 |
<div class="col-md-6 mb-4">
|
| 732 |
<div class="card menu-card">
|
| 733 |
-
<
|
| 734 |
-
<
|
| 735 |
-
|
| 736 |
-
|
| 737 |
-
|
| 738 |
-
|
| 739 |
-
|
| 740 |
-
|
| 741 |
-
|
| 742 |
-
|
| 743 |
-
|
| 744 |
-
|
| 745 |
-
|
| 746 |
-
|
| 747 |
-
|
| 748 |
-
|
| 749 |
-
|
| 750 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 751 |
<div class="addbutton">
|
| 752 |
<div class="card-body d-flex align-items-center justify-content-between">
|
| 753 |
<div>
|
|
@@ -800,7 +858,9 @@
|
|
| 800 |
<a href="{{ url_for('cart.cart') }}" class="view-cart-button">
|
| 801 |
<i class="bi bi-cart"></i>
|
| 802 |
view Cart
|
| 803 |
-
|
|
|
|
|
|
|
| 804 |
</a>
|
| 805 |
</div>
|
| 806 |
|
|
@@ -859,6 +919,30 @@
|
|
| 859 |
|
| 860 |
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
|
| 861 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 862 |
// Dynamically populate menuItems from ordered_menu
|
| 863 |
const menuItems = [
|
| 864 |
{% for section, items in ordered_menu.items() %}
|
|
@@ -1016,6 +1100,45 @@
|
|
| 1016 |
}
|
| 1017 |
|
| 1018 |
document.addEventListener('DOMContentLoaded', function () {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1019 |
const avatarContainer = document.querySelector('.avatar-dropdown-container');
|
| 1020 |
const dropdownMenu = document.querySelector('.dropdown-menu');
|
| 1021 |
|
|
@@ -1062,7 +1185,6 @@
|
|
| 1062 |
}
|
| 1063 |
});
|
| 1064 |
|
| 1065 |
-
const menuImages = document.querySelectorAll('.menu-image');
|
| 1066 |
const cardObserver = new IntersectionObserver((entries, observer) => {
|
| 1067 |
entries.forEach(entry => {
|
| 1068 |
if (entry.isIntersecting) {
|
|
@@ -1076,30 +1198,7 @@
|
|
| 1076 |
threshold: 0.1
|
| 1077 |
});
|
| 1078 |
|
| 1079 |
-
const imageObserver = new IntersectionObserver((entries, observer) => {
|
| 1080 |
-
entries.forEach(entry => {
|
| 1081 |
-
if (entry.isIntersecting) {
|
| 1082 |
-
const img = entry.target;
|
| 1083 |
-
const src = img.getAttribute('data-src');
|
| 1084 |
-
if (src && img.src !== src) {
|
| 1085 |
-
img.src = src;
|
| 1086 |
-
}
|
| 1087 |
-
img.onload = () => img.classList.add('loaded');
|
| 1088 |
-
img.onerror = () => {
|
| 1089 |
-
img.src = '/static/placeholder.jpg';
|
| 1090 |
-
img.classList.add('loaded');
|
| 1091 |
-
};
|
| 1092 |
-
observer.unobserve(img);
|
| 1093 |
-
}
|
| 1094 |
-
});
|
| 1095 |
-
}, {
|
| 1096 |
-
root: null,
|
| 1097 |
-
rootMargin: '200px',
|
| 1098 |
-
threshold: 0.01
|
| 1099 |
-
});
|
| 1100 |
-
|
| 1101 |
menuCards.forEach(card => cardObserver.observe(card));
|
| 1102 |
-
menuImages.forEach(img => imageObserver.observe(img));
|
| 1103 |
|
| 1104 |
const toggleLinks = document.querySelectorAll('.toggle-details');
|
| 1105 |
toggleLinks.forEach(link => {
|
|
|
|
| 40 |
.menu-card.visible {
|
| 41 |
opacity: 1;
|
| 42 |
}
|
| 43 |
+
|
| 44 |
+
/* Video Container Styles */
|
| 45 |
+
.video-container {
|
| 46 |
+
position: relative;
|
| 47 |
+
width: 100%;
|
| 48 |
height: 200px;
|
| 49 |
+
overflow: hidden;
|
| 50 |
+
border-radius: 15px 15px 0 0;
|
| 51 |
+
background-color: #000;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
.video-container video {
|
| 55 |
width: 100%;
|
| 56 |
+
height: 100%;
|
| 57 |
object-fit: cover;
|
| 58 |
+
transition: opacity 0.5s ease;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
.video-container .video-placeholder {
|
| 62 |
+
position: absolute;
|
| 63 |
+
top: 0;
|
| 64 |
+
left: 0;
|
| 65 |
+
width: 100%;
|
| 66 |
+
height: 100%;
|
| 67 |
+
display: flex;
|
| 68 |
+
align-items: center;
|
| 69 |
+
justify-content: center;
|
| 70 |
+
background-color: #f0f0f0;
|
| 71 |
+
color: #666;
|
| 72 |
+
font-size: 14px;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
.video-container .play-button {
|
| 76 |
+
position: absolute;
|
| 77 |
+
top: 50%;
|
| 78 |
+
left: 50%;
|
| 79 |
+
transform: translate(-50%, -50%);
|
| 80 |
+
width: 50px;
|
| 81 |
+
height: 50px;
|
| 82 |
+
background-color: rgba(0, 0, 0, 0.7);
|
| 83 |
+
border-radius: 50%;
|
| 84 |
+
display: flex;
|
| 85 |
+
align-items: center;
|
| 86 |
+
justify-content: center;
|
| 87 |
+
cursor: pointer;
|
| 88 |
+
z-index: 10;
|
| 89 |
opacity: 0;
|
| 90 |
+
transition: opacity 0.3s ease;
|
| 91 |
}
|
| 92 |
+
|
| 93 |
+
.video-container:hover .play-button {
|
| 94 |
opacity: 1;
|
| 95 |
}
|
| 96 |
+
|
| 97 |
+
.video-container .play-button i {
|
| 98 |
+
color: white;
|
| 99 |
+
font-size: 20px;
|
| 100 |
+
margin-left: 3px;
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
.card-title {
|
| 104 |
font-size: 1.2rem;
|
| 105 |
font-weight: bold;
|
|
|
|
| 721 |
height: 20px;
|
| 722 |
font-size: 10px;
|
| 723 |
}
|
| 724 |
+
|
| 725 |
+
/* Mobile video adjustments */
|
| 726 |
+
.video-container {
|
| 727 |
+
height: 150px;
|
| 728 |
+
}
|
| 729 |
}
|
| 730 |
</style>
|
| 731 |
</head>
|
|
|
|
| 784 |
{% for item in items %}
|
| 785 |
<div class="col-md-6 mb-4">
|
| 786 |
<div class="card menu-card">
|
| 787 |
+
<div class="video-container">
|
| 788 |
+
<video
|
| 789 |
+
id="video-{{ loop.index }}"
|
| 790 |
+
preload="metadata"
|
| 791 |
+
poster="{{ item.Image1__c if item.Image1__c else '/static/placeholder.jpg' }}"
|
| 792 |
+
data-src="{{ item.Video1__c }}"
|
| 793 |
+
muted
|
| 794 |
+
loop
|
| 795 |
+
>
|
| 796 |
+
<source src="{{ item.Video1__c }}" type="video/mp4">
|
| 797 |
+
Your browser does not support the video tag.
|
| 798 |
+
</video>
|
| 799 |
+
{% if not item.Video1__c %}
|
| 800 |
+
<div class="video-placeholder">
|
| 801 |
+
No video available
|
| 802 |
+
</div>
|
| 803 |
+
{% endif %}
|
| 804 |
+
<div class="play-button" onclick="togglePlay(this)">
|
| 805 |
+
<i class="bi bi-play-fill"></i>
|
| 806 |
+
</div>
|
| 807 |
+
</div>
|
| 808 |
+
|
| 809 |
<div class="addbutton">
|
| 810 |
<div class="card-body d-flex align-items-center justify-content-between">
|
| 811 |
<div>
|
|
|
|
| 858 |
<a href="{{ url_for('cart.cart') }}" class="view-cart-button">
|
| 859 |
<i class="bi bi-cart"></i>
|
| 860 |
view Cart
|
| 861 |
+
<span id="cart-item-count" class="cart-icon-badge {% if cart_item_count > 0 %}active{% endif %}">
|
| 862 |
+
{{ cart_item_count if cart_item_count > 0 else '' }}
|
| 863 |
+
</span>
|
| 864 |
</a>
|
| 865 |
</div>
|
| 866 |
|
|
|
|
| 919 |
|
| 920 |
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
|
| 921 |
<script>
|
| 922 |
+
// Video Handling Functions
|
| 923 |
+
function togglePlay(button) {
|
| 924 |
+
const videoContainer = button.closest('.video-container');
|
| 925 |
+
const video = videoContainer.querySelector('video');
|
| 926 |
+
|
| 927 |
+
if (video.paused) {
|
| 928 |
+
// Load video source if not already loaded
|
| 929 |
+
if (!video.src && video.dataset.src) {
|
| 930 |
+
video.src = video.dataset.src;
|
| 931 |
+
}
|
| 932 |
+
video.play()
|
| 933 |
+
.then(() => {
|
| 934 |
+
button.innerHTML = '<i class="bi bi-pause-fill"></i>';
|
| 935 |
+
})
|
| 936 |
+
.catch(e => {
|
| 937 |
+
console.log('Video play error:', e);
|
| 938 |
+
// Show error to user if needed
|
| 939 |
+
});
|
| 940 |
+
} else {
|
| 941 |
+
video.pause();
|
| 942 |
+
button.innerHTML = '<i class="bi bi-play-fill"></i>';
|
| 943 |
+
}
|
| 944 |
+
}
|
| 945 |
+
|
| 946 |
// Dynamically populate menuItems from ordered_menu
|
| 947 |
const menuItems = [
|
| 948 |
{% for section, items in ordered_menu.items() %}
|
|
|
|
| 1100 |
}
|
| 1101 |
|
| 1102 |
document.addEventListener('DOMContentLoaded', function () {
|
| 1103 |
+
// Initialize video handling
|
| 1104 |
+
const videoContainers = document.querySelectorAll('.video-container');
|
| 1105 |
+
|
| 1106 |
+
videoContainers.forEach(container => {
|
| 1107 |
+
const video = container.querySelector('video');
|
| 1108 |
+
|
| 1109 |
+
// Only load video when container is in viewport
|
| 1110 |
+
const observer = new IntersectionObserver((entries) => {
|
| 1111 |
+
entries.forEach(entry => {
|
| 1112 |
+
if (entry.isIntersecting && video.dataset.src && !video.src) {
|
| 1113 |
+
video.src = video.dataset.src;
|
| 1114 |
+
observer.unobserve(entry.target);
|
| 1115 |
+
}
|
| 1116 |
+
});
|
| 1117 |
+
}, {
|
| 1118 |
+
rootMargin: '200px',
|
| 1119 |
+
threshold: 0.1
|
| 1120 |
+
});
|
| 1121 |
+
|
| 1122 |
+
observer.observe(container);
|
| 1123 |
+
|
| 1124 |
+
// Handle hover play/pause
|
| 1125 |
+
container.addEventListener('mouseenter', () => {
|
| 1126 |
+
if (video.src) {
|
| 1127 |
+
video.play().catch(e => console.log('Autoplay prevented:', e));
|
| 1128 |
+
}
|
| 1129 |
+
});
|
| 1130 |
+
|
| 1131 |
+
container.addEventListener('mouseleave', () => {
|
| 1132 |
+
if (!video.paused) {
|
| 1133 |
+
video.pause();
|
| 1134 |
+
const playButton = container.querySelector('.play-button');
|
| 1135 |
+
if (playButton) {
|
| 1136 |
+
playButton.innerHTML = '<i class="bi bi-play-fill"></i>';
|
| 1137 |
+
}
|
| 1138 |
+
}
|
| 1139 |
+
});
|
| 1140 |
+
});
|
| 1141 |
+
|
| 1142 |
const avatarContainer = document.querySelector('.avatar-dropdown-container');
|
| 1143 |
const dropdownMenu = document.querySelector('.dropdown-menu');
|
| 1144 |
|
|
|
|
| 1185 |
}
|
| 1186 |
});
|
| 1187 |
|
|
|
|
| 1188 |
const cardObserver = new IntersectionObserver((entries, observer) => {
|
| 1189 |
entries.forEach(entry => {
|
| 1190 |
if (entry.isIntersecting) {
|
|
|
|
| 1198 |
threshold: 0.1
|
| 1199 |
});
|
| 1200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1201 |
menuCards.forEach(card => cardObserver.observe(card));
|
|
|
|
| 1202 |
|
| 1203 |
const toggleLinks = document.querySelectorAll('.toggle-details');
|
| 1204 |
toggleLinks.forEach(link => {
|