nagasurendra commited on
Commit
62feebe
·
verified ·
1 Parent(s): f4b07da

Update templates/menu.html

Browse files
Files changed (1) hide show
  1. templates/menu.html +15 -26
templates/menu.html CHANGED
@@ -335,6 +335,7 @@ form-check-input addon-option{
335
  }
336
  /* Custom Toggle Switch Styling */
337
 
 
338
  /* Flex container to align toggle buttons */
339
  .toggle-container {
340
  display: flex;
@@ -378,7 +379,6 @@ form-check-input addon-option{
378
  }
379
 
380
 
381
-
382
  /* Optional: Style the labels */
383
  .form-check-label {
384
  font-size: 16px;
@@ -468,23 +468,23 @@ form-check-input addon-option{
468
 
469
  <!-- Wrapper for the toggle buttons -->
470
  <div class="toggle-container">
471
- <!-- Veg Toggle Button -->
472
  <div class="form-check form-check-inline">
473
- <input type="radio" id="category-Veg" name="category" value="Veg"
474
  class="custom-toggle"
475
  {% if selected_category == "Veg" %}checked{% endif %} onchange="this.form.submit()">
476
  <label class="form-check-label" for="category-Veg">Veg</label>
477
  </div>
478
 
479
- <!-- Customized Dish Toggle Button -->
480
  <div class="form-check form-check-inline">
481
- <input type="radio" id="category-CustomizedDish" name="category" value="Customized Dish"
482
  class="custom-toggle"
483
  {% if selected_category == "Customized Dish" %}checked{% endif %} onchange="this.form.submit()">
484
  <label class="form-check-label" for="category-CustomizedDish">Customized Dish</label>
485
  </div>
486
  </div>
487
-
488
  <!-- Non-Veg logic handled in backend but not displayed in UI -->
489
  <input type="hidden" name="category" value="{% if selected_category == 'Non-Veg' %}Non-Veg{% endif %}">
490
  </form>
@@ -494,6 +494,7 @@ form-check-input addon-option{
494
 
495
 
496
 
 
497
 
498
  <!-- Show menu items only when Customized Dish is not selected -->
499
  <div class="container mt-4">
@@ -713,26 +714,14 @@ form-check-input addon-option{
713
  });
714
  }
715
 
716
- // This script will run when the page loads
717
- window.onload = function () {
718
- const vegToggle = document.getElementById('category-Veg');
719
- const customizedDishToggle = document.getElementById('category-CustomizedDish');
720
-
721
- // Add event listeners to both toggle buttons
722
- vegToggle.addEventListener('change', function () {
723
- if (!vegToggle.checked && !customizedDishToggle.checked) {
724
- // Reset to show all items when neither toggle is selected
725
- window.location.href = '/menu?category=All';
726
- }
727
- });
728
-
729
- customizedDishToggle.addEventListener('change', function () {
730
- if (!vegToggle.checked && !customizedDishToggle.checked) {
731
- // Reset to show all items when neither toggle is selected
732
- window.location.href = '/menu?category=All';
733
- }
734
- });
735
- };
736
 
737
 
738
  function addToCartFromModal() {
 
335
  }
336
  /* Custom Toggle Switch Styling */
337
 
338
+ /* Flex container to align toggle buttons */
339
  /* Flex container to align toggle buttons */
340
  .toggle-container {
341
  display: flex;
 
379
  }
380
 
381
 
 
382
  /* Optional: Style the labels */
383
  .form-check-label {
384
  font-size: 16px;
 
468
 
469
  <!-- Wrapper for the toggle buttons -->
470
  <div class="toggle-container">
471
+ <!-- Veg Toggle Button (Checkbox styled as toggle) -->
472
  <div class="form-check form-check-inline">
473
+ <input type="checkbox" id="category-Veg" name="category" value="Veg"
474
  class="custom-toggle"
475
  {% if selected_category == "Veg" %}checked{% endif %} onchange="this.form.submit()">
476
  <label class="form-check-label" for="category-Veg">Veg</label>
477
  </div>
478
 
479
+ <!-- Customized Dish Toggle Button (Checkbox styled as toggle) -->
480
  <div class="form-check form-check-inline">
481
+ <input type="checkbox" id="category-CustomizedDish" name="category" value="Customized Dish"
482
  class="custom-toggle"
483
  {% if selected_category == "Customized Dish" %}checked{% endif %} onchange="this.form.submit()">
484
  <label class="form-check-label" for="category-CustomizedDish">Customized Dish</label>
485
  </div>
486
  </div>
487
+
488
  <!-- Non-Veg logic handled in backend but not displayed in UI -->
489
  <input type="hidden" name="category" value="{% if selected_category == 'Non-Veg' %}Non-Veg{% endif %}">
490
  </form>
 
494
 
495
 
496
 
497
+
498
 
499
  <!-- Show menu items only when Customized Dish is not selected -->
500
  <div class="container mt-4">
 
714
  });
715
  }
716
 
717
+ // JavaScript to manage toggles being turned off independently
718
+ document.querySelectorAll('.custom-toggle').forEach(toggle => {
719
+ toggle.addEventListener('click', function() {
720
+ // If clicked, toggle its checked state (on or off)
721
+ this.checked = !this.checked;
722
+ });
723
+ });
724
+
 
 
 
 
 
 
 
 
 
 
 
 
725
 
726
 
727
  function addToCartFromModal() {