{% extends 'base.html.twig' %}
{% block title %} {{ parent() }} | {{ produit.nom }} {% endblock %}
{% block stylesheets %}
<link rel="stylesheet" href="{{ asset('css/fiche_produit.css') }}">
{% endblock %}
{% block content %}
{% set categories = app.session.get('categories') %}
<div itemscope itemtype="https://schema.org/Product" class="wrapper col-12 d-flex flex-lg-row flex-column ">
<meta itemprop="url" content="https://www.lebiodelo.com{{ app.request.getPathInfo }}">
<div class="col-lg-6 col-12">
<div id="carouselExampleIndicators" class="carousel carousel-dark slide" data-bs-ride="carousel">
<div class="carousel-indicators">
{% for photo in produit.photoProduits %}
{% if photo.position == 1 %}
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="{{ photo.position -1 }}" class="carousselIndiator active" aria-current="true" aria-label="Slide ~{{ photo.position}}"></button>
{% else %}
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="{{ photo.position -1 }}" class="carousselIndicator" aria-label="Slide ~{{ photo.position}}"></button>
{% endif %}
{% endfor %}
</div>
<div class="carousel-inner">
{% for photo in produit.photoProduits %}
{% if photo.position == 1 %}
<div class="carousel-item active">
<img itemprop="image" class="d-block mx-auto my-auto" src="{{ asset("img/photoProduitUpload/" ~ photo.nom ) }}" alt="slide "~{{ photo.position }}>
</div>
{% else %}
<div class="carousel-item">
<img class="d-block" src="{{ asset("img/photoProduitUpload/" ~ photo.nom ) }}" alt="slide "~{{ photo.position }}>
</div>
{% endif %}
{% endfor %}
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
</div>
<div class=" col-lg-5 col-10 mx-auto d-flex flex-column justify-centent-start">
<div class="data_content">
<div class="data d-flex flex-column justify-content-start align-items-start">
<nav itemprop='breadcrumb' aria-label="Breadcrumb" class="breadcrumb d-md-block d-none">
<ul>
<li><a href="{{ path('accueil') }}">ACCUEIL</a></li>
<li><a href="{{ path('catalogue') }}"> PRODUITS</a></li>
<li><a href="{{ path("categorie" , {'id' : produit.categorie.id}) }}"> {{ produit.categorie.nom|upper }}</a></li>
<li><span aria-current="page"> {{ produit.nom|upper}} </span></li>
</ul>
</nav>
<h1 itemprop="name" class='nom-produit mt-5'>{{ produit.nom|upper }} - {{ produit.prixPubTtc|number_format(2,',') }} EUR</h1>
<br>
<br>
<p itemprop="offers" itemscope itemtype="https://schema.org/Offer" class="prix"></p>
</div>
<form action="{{ path('panier_ajouter') }}" method="post">
<input type="hidden" name="id" value ="{{ produit.id }}">
<p itemprop="slogan" class="description">{{ produit.description|raw}}</p>
<br>
<p id='matieres' class=" mx-auto detail">{{ produit.matiere}}</p>
<br>
<p id='matieres' class=" mx-auto detail">{{ produit.motif}}</p>
<br>
<p> <img src="{{ asset('img/icones/bio.jpg') }}" style="width: 100px;" alt=""> Produits issus de l’Agriculture Biologique, certifiés par Ecocert. </p>
<p id='tailles' class=" mx-auto detail">{{ produit.taille}}</p>
<div class="col-12 d-flex">
<div class=' col-4 d-flex justify-content-start my-3'>
<div class="input-group">
<label id="label_qty" class ='my-auto' for="qty">Quantité</label>
<input class=" mx-auto " style="border-color:#DDD;" id= "qty" type="number" name="qty" id="qty" min="1" max="10" step="1" value="1">
</div>
</div>
<button type="submit" class="col-8 btn my-3 ">AJOUTER AU PANIER</button>
</div>
</form>
</div>
</div>
</div>
<textarea hidden class='photo2js' name="" id="" cols="30" rows="10">{{ photos }}</textarea>
{% endblock %}
{% block javascripts %}
<script>// expension des div Taille, matière et entretien( code à réduire)
function expandTaille(element){
let expander = element.getAttribute('expand')
let elt = document.querySelector('#tailles')
if (expander == '+') {
elt.setAttribute('class','d-block')
element.setAttribute('expand','-')
element.innerHTML = '<i class="far fa-caret-square-up"></i>'
}else {
elt.setAttribute('class','d-none')
element.setAttribute('expand','+')
element.innerHTML = '<i class="far fa-caret-square-down">'
}
}
function expandMatiere(element){
let expander = element.getAttribute('expand')
let elt = document.querySelector('#matieres')
if (expander == '+') {
elt.setAttribute('class','d-block')
element.setAttribute('expand','-')
element.innerHTML = '<i class="far fa-caret-square-up"></i>'
}else {
elt.setAttribute('class','d-none')
element.setAttribute('expand','+')
element.innerHTML = '<i class="far fa-caret-square-down">'
}
}
function expandEntretien(element){
let expander = element.getAttribute('expand')
let elt = document.querySelector('#entretien')
if (expander == '+') {
elt.setAttribute('class','d-block')
element.setAttribute('expand','-')
element.innerHTML = '<i class="far fa-caret-square-up"></i>'
}else {
elt.setAttribute('class','d-none')
element.setAttribute('expand','+')
element.innerHTML = '<i class="far fa-caret-square-down">'
}
}
</script>
<script>// bootstap caroussel
$(document).ready(function () {
$('.carousel').carousel({
interval: false,
keyboad: true,
touch:true
})
//$('.carousel').bcSwipe({ threshold: 50 });
});
</script>
<script>// vignettes photos dans les indicateurs du caroussel
let indicator =document. querySelector('.carousel-indicators')
let indicators = indicator.childNodes
let photos = JSON.parse(document.querySelector('.photo2js').value)
let indicatorsArray= Array.from(indicators)
let cheminPhoto = "{{ asset('img/photoProduitUpload/') }}"
indicatorsArray.pop()
for(i=0; i < indicatorsArray.length; i++ ){
if(i%2 !== 0){
var n=(i+1)/2
if (2* n< (indicatorsArray.length+1)){
elt =indicatorsArray [i]
elt.style.backgroundImage = 'url('+cheminPhoto+photos[n-1]+')'
}
}
}
</script>
<script> // Bootstrap Carousel Swipe v1.1 not used
/**
* Bootstrap Carousel Swipe v1.1
*
* jQuery plugin to enable swipe gestures on Bootstrap 3 carousels.
* Examples and documentation: https://github.com/maaaaark/bcSwipe
*
* Licensed under the MIT license.
*/
(function($) {
$.fn.bcSwipe = function(settings) {
var config = { threshold: 50 };
if (settings) {
$.extend(config, settings);
}
this.each(function() {
var stillMoving = false;
var start;
if ('ontouchstart' in document.documentElement) {
this.addEventListener('touchstart', onTouchStart, false);
}
function onTouchStart(e) {
if (e.touches.length == 1) {
start = e.touches[0].pageX;
stillMoving = true;
this.addEventListener('touchmove', onTouchMove, false);
}
}
function onTouchMove(e) {
if (stillMoving) {
var x = e.touches[0].pageX;
var difference = start - x;
if (Math.abs(difference) >= config.threshold) {
cancelTouch();
if(isCarouselEmpty($(this))) return;
if (difference > 0) {
$(this).carousel('next');
}
else {
$(this).carousel('prev');
}
}
}
}
function isCarouselEmpty(carousel){
return carousel.find(".item.active").length < 1
}
function cancelTouch() {
this.removeEventListener('touchmove', onTouchMove);
start = null;
stillMoving = false;
}
});
return this;
};
})(jQuery);
</script>
{% endblock %}