app/Plugin/BannerManagement42/Resource/template/index_slider.twig line 1

Open in your IDE?
  1. {# This file is part of BannerManagement42
  2. Copyright(c) U-Mebius Inc. All Rights Reserved.
  3. https://umebius.com/
  4. For the full copyright and license information, please view the LICENSE
  5. file that was distributed with this source code.
  6. #}
  7. <script>
  8.     $(function () {
  9.         $('.main_visual').slick('unslick')
  10.         $('.main_visual').html('')
  11.         {% for Banner in TopBanners %}
  12.         var $slide = $("<div class='item slick-slide'></div>");
  13.         var $img = $("<img src='{{ asset('banner/' ~ Banner.file_name, 'save_image') }}'>");
  14.         $img.attr('alt', '{{ Banner.alt }}')
  15.         {% if Banner.url %}
  16.         var $link = $('<a>').attr('href', '{{ Banner.url }}');
  17.         {% if Banner.link_method %}
  18.         $link.attr('target', '_blank');
  19.         {% endif %}
  20.         $link.html($img).appendTo($slide);
  21.         {% else %}
  22.         $img.appendTo($slide);
  23.         {% endif %}
  24.         $('.main_visual').append($slide)
  25.         {% endfor %}
  26.         var slider = $('.main_visual').slick({
  27.             dots: true,
  28.             arrows: false,
  29.             autoplay: true,
  30.             autoplaySpeed: 7000,
  31.             pauseOnHover: true,
  32.             speed: 800
  33.         });
  34.         $('.main_visual').css({
  35.             visibility: 'visible'
  36.         })
  37.         slider.slick('setPosition');
  38.     })
  39. </script>