{% extends 'base.html.twig' %}
{% block title %}Livre index{% endblock %}
{% block body %}
<style>
.filter .form-group {
width: 33%;
display: inline-block;
}
.filter{
max-width: none;
}
.form-control{
border-radius: 2.25rem;
}
</style>
<div id="cover">
{{form_start(form,{attr:{class:'filter'}})}}
{{form_row(form.q,{attr:{class:''}})}}
{{form_row(form.categories,{attr:{class:''}})}}
{# {{form_row(form.ville,{attr:{class:''}})}} #}
<div class="form-group">
<button type="submit" class="btn form-control btn-primary" style="padding:0;">{% trans %}Search{% endtrans %}
<!--i class="fa fa-search" aria-hidden="true"></i-->
</button></div>
{{form_end(form, {'render_rest': false})}}
</div>
<hr style="display: inline-block;margin-top: 300px;">
<h1><b>{% trans %}New books{% endtrans %}</b></h1>
<div class="scrollmenu" id="scrollmenu">
{% for livre in lastbooks %}
<div class="card draggable">
<a class="" href="{{ path('app_livre_show', {'id': livre.id}) }}">
<img alt="" src="/uploads/{{ livre.photo }}" onerror="this.src='/img/book.avif'" class="height-grid-card" style="height:100%;">
<div class="card-body p-0">
<h6 class="primary-color card-title font-weight-bold">{{ livre.titre }}</h6>
</div>
</a>
</div>
{% endfor %}
</div>
<h1><b>{% trans %}Available books{% endtrans %}</b></h1>
<div class="row">
<div class="grid box">
{% for livre in livres %}
<div class="card">
<a class="favori-icon" href="{{ path('addfavori', {'id': livre.id}) }}"> <i class="fa fa-heart" aria-hidden="true"></i> </a>
<a class="" href="{{ path('app_livre_show', {'id': livre.id}) }}">
<img alt="" src="/uploads/{{ livre.photo }}" onerror="this.src='/img/book.avif'" class="height-grid-card" style="height:100%;">
<div class="card-body p-2">
<h2 class="primary-color card-title font-weight-bold">{{ livre.titre }}</h2>
{# <span class="new-secondary text-secondary small-text">
{{ livre.description|slice(0, 250) }}
{% if livre.description|length > 250 %}
<span id="dots_{{ loop.index }}">...</span>{% endif %}
<span id="more_{{ loop.index }}" style="display: none;">{{ livre.description|slice(250) }}</span>
{% if livre.description|length > 250 %}
<a style="text-decoration: underline; cursor: pointer;color: #320258;" onclick="myFunction('{{ loop.index }}')" id="myBtn_{{ loop.index }}">Lire plus</a>
{% endif %}
</span> #}
{% trans %}Author{% endtrans %} : {{ livre.auteur }}<br>
{% trans %}Language{% endtrans %} : {{livre.language}}<br>
{% trans %}Country{% endtrans %} : {{livre.user.country}}
<div class="par">user : <a class="primary-color" href="{{ path('app_user_show', {'id': livre.user.id}) }}">{{ livre.user.username }}</a></div>
</div>
{# <div class="body2">
<span class="card-title price float-left" > {{ livre.prix }} Dhs / Séance</span> #}
{# <button type="button" class="btn btn-success">Réserver une séance</button>
<a class="btn btn-success"href="{{ path('app_livre_show', {'id': livre.id}) }}">
See the book
</a>
<span class="text-center p-2"><span class="fa fa-star checked"></span>
<span class="fa fa-star checked"></span>
<span class="fa fa-star checked"></span>
<span class="fa fa-star checked"></span>
<span class="fa fa-star {{ random(['', 'checked']) }}"></span>
</span>
</div> #}
</a>
</div>
{% endfor %}
</div>
</div>
{# <div class="side-bar card">
<button type="button" class="btn btn-success">Réserver le livre</button>
</div> #}
{{knp_pagination_render(livres)}}
<script>
function myFunction(id) {
var dotsElement = document.getElementById('dots_' + id);
var moreTextElement = document.getElementById('more_' + id);
var btnTextElement = document.getElementById('myBtn_' + id);
if (dotsElement.style.display === 'none') {
dotsElement.style.display = 'inline';
btnTextElement.innerHTML = 'Lire plus';
moreTextElement.style.display = 'none';
} else {
dotsElement.style.display = 'none';
btnTextElement.innerHTML = 'Lire moins';
moreTextElement.style.display = 'inline';
}
}
</script>
<script>
var menu = document.getElementById("scrollmenu");
var isDragging = false;
var startX, scrollLeft;
menu.addEventListener("mousedown", startDrag);
menu.addEventListener("touchstart", startDrag);
document.addEventListener("mouseup", stopDrag);
document.addEventListener("touchend", stopDrag);
menu.addEventListener("mousemove", dragMenu);
menu.addEventListener("touchmove", dragMenu);
function startDrag(e) {
isDragging = true;
startX = e.pageX || e.touches[0].pageX;
scrollLeft = menu.scrollLeft;
menu.style.cursor = "grabbing";
}
function stopDrag() {
isDragging = false;
menu.style.cursor = "grab";
}
function dragMenu(e) {
if (!isDragging) return;
e.preventDefault();
var x = e.pageX || e.touches[0].pageX;
menu.scrollLeft = scrollLeft - (x - startX) * 2; // Adjust scroll speed here
}
</script>
{% endblock %}