templates/vitrine/loader/search.html.twig line 1

  1. <style>
  2. .iq-card:hover .block-social-info {
  3.     opacity: 1;
  4.   }
  5.   .iq-card .block-social-info{
  6.     left: auto;
  7.   }
  8. </style>
  9. <script type="text/javascript">
  10.     const UBSearch = function(){
  11.         var program, progress, timestamp, empty = "{{'Aucun rĂ©sultat trouvĂ© !'|trans }}";
  12.         const container = "#search-offcanvas-body",
  13.         getContent = (d)=>{
  14.             $("#count-search").html("("+d.length+")");
  15.             if(d.length == 0) return `<div class="w-100 text-center"><h4>`+empty+`</h4></div>`;
  16.             const web_movie_detail = ("{{path('web_movie_detail', {'_1_':'_2_'})}}");
  17.             const web_serie_detail = ("{{path('web_series_detail', {'_1_':'_2_'})}}");
  18.             var movies = "", movie_link;
  19.             
  20.             d.forEach(el => {
  21.                 if(el.type){
  22.                     movie_link = web_movie_detail.replace('_1_', 'm').replace('_2_',el.id);
  23.                 }else if(el.nepisode){
  24.                     movie_link = web_movie_detail.replace('_1_', 'e').replace('_2_',el.id);
  25.                 }else{
  26.                     movie_link = web_serie_detail.replace('_1_', 's').replace('_2_',el.id);
  27.                 }
  28.                 
  29.                 movies += `
  30.                     <div class="col mb-4">
  31.                         <div class="iq-card card-hover">
  32.                             <div class="block-images position-relative w-100">
  33.                                 <div class="img-box w-100">
  34.                                     <a href="javascript:void();" class="position-absolute top-0 bottom-0 start-0 end-0"></a>
  35.                                     <img src="{{asset('`+el.cover+`', 'covers')}}" alt="`+el.title+`" class="img-fluid object-cover w-100 d-block border-0">
  36.                                 </div>
  37.                                 <div class="card-description with-transition">
  38.                                     <div class="cart-content">
  39.                                         <div class="content-left">
  40.                                             <h5 class="iq-title text-capitalize">
  41.                                                 <a href="`+movie_link+`">`+el.title+`</a>
  42.                                             </h5>
  43.                                             <small>`+composeEpisodeName(el.nseason, el.nepisode)+` `+el.episode+`</small>
  44.                                             <div class="movie-time d-flex align-items-center my-2">
  45.                                                 <span class="movie-time-text font-normal">`+el.release+`</span>
  46.                                             </div>
  47.                                         </div>
  48.                                     </div>
  49.                                 </div>
  50.                                 <div class="block-social-info align-items-center">
  51.                                     <ul class="p-0 m-0 d-flex gap-2 music-play-lists">
  52.                                         <li class="share position-relative d-flex align-items-center text-center mb-0">
  53.                                             <span class="w-100 h-100 d-inline-block bg-transparent">
  54.                                                 <i class="fas fa-share-alt"></i>
  55.                                             </span>
  56.                                             <div class="share-wrapper">
  57.                                                 <div class="share-boxs d-inline-block">
  58.                                                     <svg width="15" height="40" class="share-shape" viewBox="0 0 15 40" fill="none" xmlns="http://www.w3.org/2000/svg">
  59.                                                         <path fill-rule="evenodd" clip-rule="evenodd" d="M14.8842 40C6.82983 37.2868 1 29.3582 1 20C1 10.6418 6.82983 2.71323 14.8842 0H0V40H14.8842Z" fill="#191919"></path>
  60.                                                     </svg>
  61.                                                     <div class=" overflow-hidden">
  62.                                                         <a href="" target="_blank">
  63.                                                             <i class="fab fa-facebook-f"></i>
  64.                                                         </a>
  65.                                                         <a href="" target="_blank">
  66.                                                             <i class="fab fa-twitter"></i>
  67.                                                         </a>
  68.                                                         <a href="#">
  69.                                                             <i class="fas fa-link"></i>
  70.                                                         </a>
  71.                                                     </div>
  72.                                                 </div>
  73.                                             </div>
  74.                                         </li>
  75.                                     </ul>
  76.                                     <div class="iq-button ms-2">
  77.                                         <a href="`+movie_link+`" class="btn text-uppercase position-relative rounded-circle">
  78.                                             <i class="fa-solid fa-play ms-0"></i>
  79.                                         </a>
  80.                                     </div>
  81.                                 </div>
  82.                             </div>
  83.                         </div>
  84.                     </div>
  85.                 `;
  86.             });
  87.                 
  88.             return `
  89.                 <div class="mb-5">
  90.                     <div class="container-fluid">       
  91.                         <div class="card-style-grid">
  92.                             <div class="row row-cols-xl-5 row-cols-md-4 row-cols-2">
  93.                             `+movies+`
  94.                             </div>
  95.                         </div>
  96.                     </div>
  97.                 </div>
  98.             `;
  99.         };
  100.         return {
  101.             init: ()=>{
  102.                 $("#search-input").on('keyup', (e)=>{
  103.                     clearTimeout(timestamp);
  104.                     timestamp = setTimeout(()=>{
  105.                         $(container).html(`<div class="w-100 text-center"><span class="spinner-border spinner-border-sm align-middle ms-2"></span></div>`);
  106.                         $.ajax({
  107.                             url: "{{path('app_search_filter')}}",
  108.                             method: "post",
  109.                             data: {"search":$(e.target).val()},
  110.                             dataType: 'json',
  111.                             success: function(r) {
  112.                                 $(container).html(getContent(r.data));
  113.                             },
  114.                             error: function (r) { 
  115.                                 $(container).html(getContent([]));
  116.                             },
  117.                         });
  118.                     }, 1500);
  119.                 }); // Recherche dans l'input search
  120.             }
  121.         }
  122.     }();
  123.     UBSearch.init();
  124. </script>