app/template/bravers/Block/category_menu_sp.twig line 1

Open in your IDE?
  1. {#
  2. This file is part of EC-CUBE
  3. Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  4. http://www.ec-cube.co.jp/
  5. For the full copyright and license information, please view the LICENSE
  6. file that was distributed with this source code.
  7. #}
  8. {% macro tree(Category) %}
  9.     {% from _self import tree %}
  10.     <a href="{{ url('product_list') }}?category_id={{ Category.id }}">
  11.         <span>{{ Category.name }}</span>
  12.         {% if Category.children|length > 0 %}
  13.             <img class="ic_plus" src="{{ asset('assets/img/common/ic_plus.svg') }}" alt="お気に入り" width="12" height="12" loading="lazy">
  14.             <img class="ic_minus d-none" src="{{ asset('assets/img/common/ic_minus.svg') }}" alt="お気に入り" width="12" height="12" loading="lazy">
  15.         {% else %}
  16.             <img src="{{ asset('assets/img/common/ic_chervon_right.svg') }}" alt="お気に入り" width="6" height="9" loading="lazy">
  17.         {% endif %}
  18.     </a>
  19.     {% if Category.children|length > 0 %}
  20.         <ul class="d-none">
  21.             {% for ChildCategory in Category.children %}
  22.                 <li>
  23.                     {{ tree(ChildCategory) }}
  24.                 </li>
  25.             {% endfor %}
  26.         </ul>
  27.     {% endif %}
  28. {% endmacro %}
  29. <script>
  30.     $(document).ready(function() {
  31.         $(".ec-drawer_hamburger__category .ec-drawer_hamburger__category__nav li ul li a, .ec-drawer_hamburger__category .ec-drawer_hamburger__category__nav li .firstBtn").on("click", function(e) {
  32.             $(this).toggleClass("active");
  33.             if ($(this).hasClass("active")) {
  34.                 $(this).find(".ic_plus").addClass("d-none");
  35.                 $(this).find(".ic_minus").removeClass("d-none");
  36.                 $(this).closest("li").find("ul").removeClass("d-none");
  37.             } else {
  38.                 $(this).find(".ic_plus").removeClass("d-none");
  39.                 $(this).find(".ic_minus").addClass("d-none");
  40.                 $(this).closest("li").find("ul").addClass("d-none");
  41.             }
  42.         });
  43.         $('.ec-drawer_hamburger__category ul a').click(function(e) {
  44.             var child = $(this).siblings();
  45.             if (child.length > 0) {
  46.                 e.preventDefault(); // Prevent the default link behavior
  47.                 if (child.is(':visible')) {
  48.                     return true;
  49.                 } else {
  50.                     child.slideToggle();
  51.                     return false;
  52.                 }
  53.             }
  54.         });
  55.     });
  56. </script>
  57. {# @see https://github.com/bolt/bolt/pull/2388 #}
  58. {% from _self import tree %}
  59. <div class="ec-drawer_hamburger__category">
  60.     <div class="ec-drawer_hamburger__category__heading">
  61.         <p>{{ '商品カテゴリー・メーカーから探す'|trans }}</p>
  62.     </div>
  63.     <div class="ec-drawer_hamburger__category__nav">
  64.         <ul class="ec-drawer_hamburger__category__nav__list">
  65.             {% for Category in TopCategories %}
  66.                 <li>
  67.                     {% if Category.id == constant('Customize\\Common\\Constant::DEFAULT_CATEGORY_ID') or Category.id == constant('Customize\\Common\\Constant::MANUFACTURER_CATEGORY_ID') %}
  68.                         <a href="javascript:void(0)" class="firstBtn">
  69.                             <span>{{ Category.name }}</span>
  70.                             <img class="ic_plus" src="{{ asset('assets/img/common/ic_plus.svg') }}" alt="お気に入り" width="12" height="12" loading="lazy">
  71.                             <img class="ic_minus d-none" src="{{ asset('assets/img/common/ic_minus.svg') }}" alt="お気に入り" width="12" height="12" loading="lazy">
  72.                         </a>
  73.                         {% if Category.children|length > 0 %}
  74.                             <ul>
  75.                                 {% for ChildCategory in Category.children %}
  76.                                     <li>
  77.                                         {{ tree(ChildCategory) }}
  78.                                     </li>
  79.                                 {% endfor %}
  80.                             </ul>
  81.                         {% endif %}
  82.                     {% endif %}
  83.                 </li>
  84.             {% endfor %}
  85.         </ul>
  86.     </div>
  87. </div>