lokesh341 commited on
Commit
5a091c2
·
verified ·
1 Parent(s): 773dd33

Update templates/menu.html

Browse files
Files changed (1) hide show
  1. templates/menu.html +24 -4
templates/menu.html CHANGED
@@ -1136,8 +1136,6 @@
1136
  });
1137
  });
1138
 
1139
- // Removed static details population since we're using Salesforce data directly
1140
-
1141
  const menuCards = document.querySelectorAll('.menu-card');
1142
  const menuVideos = document.querySelectorAll('.menu-video');
1143
  const cardObserver = new IntersectionObserver((entries, observer) => {
@@ -1173,15 +1171,37 @@
1173
  });
1174
  menuCards.forEach(card => cardObserver.observe(card));
1175
  menuVideos.forEach(video => videoObserver.observe(video));
 
 
1176
  const toggleLinks = document.querySelectorAll('.toggle-details');
1177
  toggleLinks.forEach(link => {
1178
  link.addEventListener('click', function () {
1179
  const itemName = this.getAttribute('data-item-name').replace(/ /g, '-');
1180
  const detailsDiv = document.getElementById(`details-${itemName}`);
1181
- detailsDiv.classList.toggle('show');
1182
- this.innerText = detailsDiv.classList.contains('show') ? 'Hide Details' : 'Show Details';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1183
  });
1184
  });
 
1185
  const categoryButtons = document.querySelectorAll('.category-button');
1186
  const categoryForm = document.getElementById('categoryForm');
1187
  const selectedCategoryInput = document.getElementById('selectedCategoryInput');
 
1136
  });
1137
  });
1138
 
 
 
1139
  const menuCards = document.querySelectorAll('.menu-card');
1140
  const menuVideos = document.querySelectorAll('.menu-video');
1141
  const cardObserver = new IntersectionObserver((entries, observer) => {
 
1171
  });
1172
  menuCards.forEach(card => cardObserver.observe(card));
1173
  menuVideos.forEach(video => videoObserver.observe(video));
1174
+
1175
+ // Updated toggle logic for single active details section
1176
  const toggleLinks = document.querySelectorAll('.toggle-details');
1177
  toggleLinks.forEach(link => {
1178
  link.addEventListener('click', function () {
1179
  const itemName = this.getAttribute('data-item-name').replace(/ /g, '-');
1180
  const detailsDiv = document.getElementById(`details-${itemName}`);
1181
+ const isCurrentlyShown = detailsDiv.classList.contains('show');
1182
+
1183
+ // Close all other details sections
1184
+ document.querySelectorAll('.item-details.show').forEach(otherDetails => {
1185
+ if (otherDetails !== detailsDiv) {
1186
+ otherDetails.classList.remove('show');
1187
+ const otherLink = otherDetails.previousElementSibling;
1188
+ if (otherLink && otherLink.classList.contains('toggle-details')) {
1189
+ otherLink.innerText = 'Show Details';
1190
+ }
1191
+ }
1192
+ });
1193
+
1194
+ // Toggle the current details section
1195
+ if (!isCurrentlyShown) {
1196
+ detailsDiv.classList.add('show');
1197
+ this.innerText = 'Hide Details';
1198
+ } else {
1199
+ detailsDiv.classList.remove('show');
1200
+ this.innerText = 'Show Details';
1201
+ }
1202
  });
1203
  });
1204
+
1205
  const categoryButtons = document.querySelectorAll('.category-button');
1206
  const categoryForm = document.getElementById('categoryForm');
1207
  const selectedCategoryInput = document.getElementById('selectedCategoryInput');