src/Eccube/Resource/template/default/sticky-nav.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. {% block javascript %}
  9.     <script>
  10.         $(document).ready(function () {
  11.             $("#nav").hide();
  12.             $('.open-category').on('click', function () {
  13.                 $('.open-category').toggleClass('active bg-[#F7F6F2]');
  14.                 $("#nav").toggleClass('panelactive');
  15.                 $('#nav').removeClass('opacity-0');
  16.                 $('#nav').slideToggle(500)
  17.             });
  18.             $('.open-category a').click(function () {
  19.                 $('.open-category').removeClass('active');
  20.                 $('#nav').removeClass('panelactive');
  21.             });
  22.             $('.close-category').click(function () {
  23.                 $('#nav').slideToggle(500)
  24.                  $('.open-category').removeClass('bg-[#F7F6F2]');
  25.             });
  26.             $('.js-hamburger-menu').on('click', function (){
  27.                 if($('.navigation').hasClass('active')){
  28.                     $(".sticky-nav").removeClass('opacity-0');
  29.                 }else{
  30.                     $(".sticky-nav").addClass('opacity-0');
  31.                 }
  32.             })
  33.         })
  34.     </script>
  35.     {# ページ毎のスクロールイベント #}
  36.     {% if app.request.get('_route') == 'homepage' %}
  37.         <script>
  38.             $(document).ready(function () {
  39.                 $(".pc-category").removeClass('opacity-0');
  40.                 $(window).on("scroll", function () {
  41.                     // フッター
  42.                     const point = window.pageYOffset;
  43.                     const docHeight = $(document).height();
  44.                     const dispHeight = $(window).height();
  45.                     const sliderHeight = $(".footer").height();
  46.                     const footerInnerHeight = $('.footer').innerHeight();
  47.                     if (point > docHeight-dispHeight-footerInnerHeight) {
  48.                         $(".sticky-nav").addClass('opacity-0');
  49.                     }else{
  50.                         $(".sticky-nav").removeClass('opacity-0');
  51.                     }
  52.                     // TOPページ
  53.                     const mvHeight = $(".mv").height();
  54.                     if (mvHeight - 300 < $(this).scrollTop()) {
  55.                         if(point > docHeight-dispHeight-footerInnerHeight == false){
  56.                             $(".sticky-nav").removeClass('opacity-0');
  57.                         }
  58.                     }else{
  59.                         $('#nav').fadeOut(500)
  60.                         $(".sticky-nav").addClass('opacity-0');
  61.                         $('.open-category').removeClass('bg-[#F7F6F2]');
  62.                     }
  63.                 });
  64.             });
  65.         </script>
  66.     {% else %}
  67.         <script>
  68.             $(document).ready(function () {
  69.                 $(".sticky-nav").removeClass('opacity-0');
  70.                 $(".pc-category").removeClass('opacity-0');
  71.                     $(window).on("scroll", function () {
  72.                     // フッター
  73.                     const point = window.pageYOffset;
  74.                     const docHeight = $(document).height();
  75.                     const dispHeight = $(window).height();
  76.                     const sliderHeight = $(".footer").height();
  77.                     const footerInnerHeight = $('.footer').innerHeight();
  78.                     if (point > docHeight-dispHeight-footerInnerHeight) {
  79.                         $(".sticky-nav").addClass('opacity-0');
  80.                     }else{
  81.                         $(".sticky-nav").removeClass('opacity-0');
  82.                     }
  83.                 });
  84.             })
  85.         </script>
  86.     {% endif %}
  87.     <script>
  88.         $(document).ready(function () {
  89.             var targetPages = [
  90.                 '/contact/complete',
  91.                 '/contact/confirm',
  92.                 '/contact',
  93.                 '/contact/showroom',
  94.                 '/contact/catalog',
  95.                 '/contact/other',
  96.                 '/contact/coordinate',
  97.                 '/contact/form',
  98.                 '/entry/activate',
  99.                 '/entry/complete',
  100.                 '/entry/confirm',
  101.                 '/entry',
  102.                 '/forgot/complete',
  103.                 '/forgot',
  104.                 '/forgot/reset',
  105.                 '/help/agreement',
  106.                 '/help/privacy',
  107.                 '/help/sitemap',
  108.                 '/help/tradelaw',
  109.                 '/mypage/change_complete',
  110.                 '/mypage/change',
  111.                 '/mypage/delivery_edit',
  112.                 '/mypage/delivery',
  113.                 '/mypage/favorite',
  114.                 '/mypage/',
  115.                 '/mypage/login',
  116.                 '/mypage/withdraw_complete',
  117.                 '/mypage/withdraw_confirm',
  118.                 '/mypage/withdraw',
  119.                 '/user_data/catalog',
  120.                 '/user_data/corporate',
  121.                 '/user_data/guide_detail',
  122.                 '/user_data/guide_top',
  123.                 '/user_data/movie',
  124.                 '/user_data/naire',
  125.                 '/user_data/photo_service',
  126.                 '/user_data/pick_up-altar',
  127.                 '/user_data/pick_up-altar',
  128.                 '/user_data/qa',
  129.                 '/user_data/reading_detail',
  130.                 '/user_data/reading',
  131.                 '/user_data/service',
  132.                 '/user_data/service',
  133.                 '/cart',
  134.                 '/shopping/alert',
  135.                 '/shopping/confirm',
  136.                 '/shopping/complete',
  137.                 '/shopping',
  138.                 '/shopping/login',
  139.                 '/shopping/nomember',
  140.                 '/shopping/shipping_edit',
  141.                 '/shopping/shipping_multiple_edit',
  142.                 '/shopping/shipping_multiple',
  143.                 '/shopping',
  144.                 '/shopping/error',
  145.             ];
  146.             var currentUrl = location.pathname;
  147.             if ($.inArray(currentUrl, targetPages) !== -1) {
  148.                 console.log("test");
  149.                 $(".sticky-nav").hide();
  150.                 $(".pc-category").hide();
  151.             }
  152.         });
  153.     </script>
  154. {% endblock %}
  155. {% set Categories = repository('Eccube\\Entity\\Category').getList() %}
  156. {% set categories = [
  157.     {
  158.         'name': 'お仏壇',
  159.         'id':'2',
  160.     },
  161.     {
  162.         'name': 'お位牌',
  163.          'id':'1',
  164.     },
  165.     {
  166.         'name': '仏具',
  167.          'id':'3',
  168.     },
  169.     {
  170.         'name': 'セット',
  171.          'id':'4',
  172.     },
  173.     {
  174.         'name': '手元供養',
  175.          'id':'21',
  176.     },
  177. ] %}
  178. {% block main %}
  179.     <div class="bg-manakaBeige w-full fixed top-[82px] lg:top-[56px] z-10 md:hidden pc-category opacity-0">
  180.         <ul class="flex items-center gap-4 h-[82px] max-w-[1440px] justify-end mx-auto pr-4">
  181.             {% if app.request.get('_route') == 'product_list' %}
  182.                 {% for category in categories %}
  183.                     <li class="drop-shadow-lg bg-[#FBFBF9] px-1.5 py-0.5 rounded-3xl w-[86px] text-center {% if Category.id == category.id %}text-white !bg-[#D0CBBE]{% endif %}">
  184.                         <a href="{{url('product_list',{'category_id':category.id})}}" class="cursor-pointer hover text-[15px] tracking-widest leading-8 ">
  185.                             {{category.name}}
  186.                         </a>
  187.                     </li>
  188.                 {% endfor %}
  189.             {% else %}
  190.                 {% for category in categories %}
  191.                     <li class="drop-shadow-lg bg-[#FBFBF9] px-1.5 py-0.5 rounded-3xl w-[86px] text-center">
  192.                         <a href="{{url('product_list',{'category_id':category.id})}}" class="cursor-pointer hover text-[15px] tracking-widest leading-8 ">
  193.                             {{category.name}}
  194.                         </a>
  195.                     </li>
  196.                 {% endfor %}
  197.             {% endif %}
  198.         </ul>
  199.     </div>
  200.     <div
  201.         class="md:flex hidden fixed bg-white bottom-0 left-0 z-20 w-full items-center border-[#F7F6F2] border-t sticky-nav opacity-0 duration-700">
  202.         {# 商品カテゴリー #}
  203.         <button class="flex flex-col items-center justify-center p-4 w-full gap-2 open-category">
  204.             <svg xmlns="http://www.w3.org/2000/svg" width="25" height="24" viewbox="0 0 25 24" fill="none">
  205.                 <path d="M9.5 5H7.5C6.96957 5 6.46086 5.21071 6.08579 5.58579C5.71071 5.96086 5.5 6.46957 5.5 7V19C5.5 19.5304 5.71071 20.0391 6.08579 20.4142C6.46086 20.7893 6.96957 21 7.5 21H17.5C18.0304 21 18.5391 20.7893 18.9142 20.4142C19.2893 20.0391 19.5 19.5304 19.5 19V7C19.5 6.46957 19.2893 5.96086 18.9142 5.58579C18.5391 5.21071 18.0304 5 17.5 5H15.5M9.5 5C9.5 5.53043 9.71071 6.03914 10.0858 6.41421C10.4609 6.78929 10.9696 7 11.5 7H13.5C14.0304 7 14.5391 6.78929 14.9142 6.41421C15.2893 6.03914 15.5 5.53043 15.5 5M9.5 5C9.5 4.46957 9.71071 3.96086 10.0858 3.58579C10.4609 3.21071 10.9696 3 11.5 3H13.5C14.0304 3 14.5391 3.21071 14.9142 3.58579C15.2893 3.96086 15.5 4.46957 15.5 5M12.5 12H15.5M12.5 16H15.5M9.5 12H9.51M9.5 16H9.51" stroke="#222222" stroke-linecap="round" stroke-linejoin="round"/>
  206.             </svg>
  207.             <p class="text-xs">商品カテゴリー</p>
  208.         </button>
  209.         <hr
  210.         class="h-10 bg-[#F7F6F2] w-[2px] border-none">
  211.         {# 問い合わせ #}
  212.         <a href="{{url('contact')}}" class="flex flex-col items-center justify-center p-3 w-full gap-2">
  213.             <svg xmlns="http://www.w3.org/2000/svg" width="25" height="24" viewbox="0 0 25 24" fill="none">
  214.                 <path d="M3.5 8L11.39 13.26C11.7187 13.4793 12.1049 13.5963 12.5 13.5963C12.8951 13.5963 13.2813 13.4793 13.61 13.26L21.5 8M5.5 19H19.5C20.0304 19 20.5391 18.7893 20.9142 18.4142C21.2893 18.0391 21.5 17.5304 21.5 17V7C21.5 6.46957 21.2893 5.96086 20.9142 5.58579C20.5391 5.21071 20.0304 5 19.5 5H5.5C4.96957 5 4.46086 5.21071 4.08579 5.58579C3.71071 5.96086 3.5 6.46957 3.5 7V17C3.5 17.5304 3.71071 18.0391 4.08579 18.4142C4.46086 18.7893 4.96957 19 5.5 19Z" stroke="#222222" stroke-linecap="round" stroke-linejoin="round"/>
  215.             </svg>
  216.             <p class="text-xs">お問い合わせ</p>
  217.         </a>
  218.     </div>
  219.     <nav class="fixed bottom-[72px] w-full md:grid grid-cols-3 gap-3 hidden py-7 px-8 bg-white border-[#F7F6F2] border-t z-10 opacity-0" id="nav">
  220.         <div class="close-category absolute top-2 right-3">
  221.             <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewbox="0 0 16 16" fill="none" class="">
  222.                 <path d="M4 12L12 4M4 4L12 12" stroke="#E2DFD6" stroke-linecap="round" stroke-linejoin="round"/>
  223.             </svg>
  224.         </div>
  225.         {% for category in categories %}
  226.             <a href="{{url('product_list',{'category_id':category.id})}}" class="max-w-[calc(100%÷{{ category|length }})] bg-white border border-[#E2DFD6] py-2 px-4 block whitespace-nowrap text-center rounded hover">
  227.                 {{category.name}}
  228.             </a>
  229.         {% endfor %}
  230.         <a href="{{url('homepage')}}" class="w-full bg-white border border-[#E2DFD6] py-2 px-4 block whitespace-nowrap text-center rounded hover">
  231.             TOP
  232.         </a>
  233.     </nav>
  234. {% endblock %}