templates/games/list.html.twig line 1

  1. {% extends 'base.html.twig' %}
  2. {% trans_default_domain "gamepage" %}
  3. {% block title %}{{ ("category-" ~ category.slug)|trans({},"categories",app.request.getLocale()) }} | {% trans %}SpeakyPlanet{% endtrans %}{% endblock %}
  4. {% block pageTitle %}{{ ("category-" ~ category.slug)|trans({},"categories",app.request.getLocale()) }}{% endblock %}
  5. {% block body %}
  6. <script>
  7.     var currentPage = 1;
  8.     var maxPage = {{ nbPages }};
  9.     $(document).ready(function() {
  10.         $( ".pagination li" ).click(function() {
  11.                 
  12.                 console.log(currentPage);
  13.                 console.log(maxPage);
  14.             if($(this).hasClass('previous')){
  15.                 console.log('previous');
  16.                 if(currentPage > 1)
  17.                     currentPage--;
  18.             }else if($(this).hasClass('next')){
  19.                 console.log('next');
  20.                 if(currentPage < maxPage)
  21.                     currentPage++;
  22.             }else{
  23.                 console.log($( ".pagination li" ).index( this ));
  24.                 currentPage = $( ".pagination li" ).index( this );
  25.             }
  26.             $( ".pagination li" ).removeClass('active');
  27.             $( ".pagination li:nth-child("+ (currentPage+1) +")" ).addClass('active');
  28.             $( ".gamePage" ).hide();
  29.             $( "#page"+currentPage ).show();
  30.             return false;
  31.         });
  32.     });
  33. </script>
  34.     <style>
  35.         .card-text {
  36.             font-size: 10px;
  37.             font-weight: bold;
  38.             text-transform: uppercase;
  39.             color: #0071BC;
  40.             width: 265px;
  41.             margin: 0;
  42.         }
  43.         a:hover .card-text {
  44.             color: #f26528;
  45.         }
  46.         .card-body .theme {
  47.             font-size: 15px;
  48.             color: #0071BC;
  49.             width: 265px;
  50.             font-style: italic;
  51.         }
  52.         .bot-right {
  53.             bottom: 0;
  54.             right: 0;
  55.         }
  56.     </style>
  57.     {% set page = 1 %}
  58.     {% set lock = user is null or not user.isSubscribed %}
  59.     <div class="gamePage row row-cols-1 row-cols-sm-2 row-cols-md-3 g-4" id="page{{ page }}">
  60.         {% for game in games %}
  61.             
  62.             {% if loop.index0 > 0 and loop.index0%nbPerPage == 0 %}
  63.                 {% set page = page+1 %}
  64.                 <div class="clearfix" ></div>
  65.                 </div>
  66.                 <div class="gamePage row row-cols-1 row-cols-sm-2 row-cols-md-3 g-4" id="page{{ page }}" style="display: none;">
  67.             {% endif %}
  68.             {% set zoneId = 'game' ~ game.uniqueId %}
  69.             <a class="text-decoration-none text-muted" role="button"  href="{{ path('play_game', { 'slug': game.canonicalTitle }) }}">
  70.             <div class="col px-4 position-relative">
  71.                 <div class="card shadow-sm">
  72.                     <div class="text-center">
  73.                         <img class="card-img-top mx-auto d-block" alt="{{ game.canonicalTitle }}" src="{% if game.thumbnail is not null %}{{ asset(game.thumbnailUrl) }}{% endif %}" />
  74.                     </div>
  75.                     <div class="card-body py-1">
  76.                         <p class="card-text">{{ 'gtitle'|trans({},zoneId,app.request.getLocale()) }}</p>
  77.                         <p class="theme text-left py-0 my-0">{% if isTheme is defined and isTheme == 1 %}{% if game.mainCategory %}{{ ("category-" ~ game.mainCategory.slug)|trans({},'categories',app.request.getLocale()) }}{% endif %}{% else %}{% if game.mainTheme %}{{ ("category-" ~ game.mainTheme.slug)|trans({},'categories',app.request.getLocale()) }}{% endif %}{% endif %}</p>
  78.                         {#<div class="vote {{ 'r' ~ game.roundMark }}">&nbsp;</div>#}
  79.                     </div>
  80.                     {% if lock and not game.free %}
  81.                         <img class="position-absolute p-1 bot-right" src="{{ asset('images/default/locker.png') }}" alt="">
  82.                     {% endif %}
  83.                 </div>
  84.             </div>
  85.             </a>
  86.         {% else %}
  87.             <h3>Il n'y a actuellement aucun jeu dans cette catégorie.</h3> 
  88.         {% endfor %}
  89.     </div>
  90.     {% if nbPages >= 1 %}
  91.     <nav aria-label="Page navigation example">
  92.         <ul class="pagination justify-content-center py-4">
  93.             <li class="page-item previous">
  94.             <a class="page-link" href="#" aria-label="Previous">
  95.             <span aria-hidden="true">&laquo;</span>
  96.             </a>
  97.             </li>
  98.             {% for i in 1..nbPages %}
  99.                 <li class="page-item {% if loop.index0 == 0 %}active{% endif %}"><a class="page-link" href="#">{{ i }}</a></li>
  100.             {% endfor %}
  101.             <li class="page-item next">
  102.             <a class="page-link" href="#" aria-label="Next">
  103.             <span aria-hidden="true">&raquo;</span>
  104.             </a>
  105.             </li>
  106.         </ul>
  107.     </nav>
  108.     {% endif %}
  109. {% endblock %}