templates/index.html.twig line 1

Open in your IDE?
  1. {% extends 'include/base.html.twig' %}
  2. {% set bodyClass = 'home' %}
  3. {% set canvasHeight = 397 %}
  4. {% set canvasWidth = 297 %}
  5. {% set canvasExportScale = 2 %}
  6. {% set bodyClass = 'paso1' %}
  7. {% set paises = [
  8.     {
  9.         'name': 'Arabia Saudi',
  10.         'key': 'arabiasaudi',
  11.     },
  12.     {
  13.         'name': 'Alemania',
  14.         'key': 'alemania',
  15.     },
  16.     {
  17.         'name': 'Argentina',
  18.         'key': 'argentina',
  19.     },
  20.     {
  21.         'name': 'Australia',
  22.         'key': 'australia',
  23.     },
  24.     {
  25.         'name': 'Bélgica',
  26.         'key': 'belgica',
  27.     },
  28.     {
  29.         'name': 'Brasil',
  30.         'key': 'brasil',
  31.     },
  32.     {
  33.         'name': 'Camerun',
  34.         'key': 'camerun',
  35.     },
  36.     {
  37.         'name': 'Canadá',
  38.         'key': 'canada',
  39.     },
  40.     {
  41.         'name': 'Corea del Sur',
  42.         'key': 'coreasur',
  43.     },
  44.     {
  45.         'name': 'Costa Rica',
  46.         'key': 'costarica',
  47.     },
  48.     {
  49.         'name': 'Croacia',
  50.         'key': 'croacia',
  51.     },
  52.     {
  53.         'name': 'Dinamarca',
  54.         'key': 'dinamarca',
  55.     },
  56.     {
  57.         'name': 'Ecuador',
  58.         'key': 'ecuador',
  59.     },
  60.     {
  61.         'name': 'España',
  62.         'key': 'espana',
  63.     },
  64.     {
  65.         'name': 'Francia',
  66.         'key': 'francia',
  67.     },
  68.     {
  69.         'name': 'Gales',
  70.         'key': 'gales',
  71.     },
  72.     {
  73.         'name': 'Ghana',
  74.         'key': 'ghana',
  75.     },
  76.     {
  77.         'name': 'Inglaterra',
  78.         'key': 'inglaterra',
  79.     },
  80.     {
  81.         'name': 'Iran',
  82.         'key': 'iran',
  83.     },
  84.     {
  85.         'name': 'Japón',
  86.         'key': 'japon',
  87.     },
  88.     {
  89.         'name': 'Marruecos',
  90.         'key': 'marruecos',
  91.     },
  92.     {
  93.         'name': 'Mexico',
  94.         'key': 'mexico',
  95.     },
  96.     {
  97.         'name': 'Paises Bajos',
  98.         'key': 'paisesbajos',
  99.     },
  100.     {
  101.         'name': 'Polonia',
  102.         'key': 'polonia',
  103.     },
  104.     {
  105.         'name': 'Portugal',
  106.         'key': 'portugal',
  107.     },
  108.     {
  109.         'name': 'Qatar',
  110.         'key': 'qatar',
  111.     },
  112.     {
  113.         'name': 'Senegal',
  114.         'key': 'senegal',
  115.     },
  116.     {
  117.         'name': 'Serbia',
  118.         'key': 'serbia',
  119.     },
  120.     {
  121.         'name': 'Suiza',
  122.         'key': 'suiza',
  123.     },
  124.     {
  125.         'name': 'Tunez',
  126.         'key': 'tunez',
  127.     },
  128.     {
  129.         'name': 'Uruguay',
  130.         'key': 'uruguay',
  131.     },
  132.     {
  133.         'name': 'USA',
  134.         'key': 'usa',
  135.     },
  136. ] %}
  137. {% block body %}
  138.     <div class="ventana ventana-1 home">
  139.         <div class="body-content">
  140.             <h1><a href="{{ path('program_campaigns') }}" title="">Entrez dans le club</a></h1>
  141.             <h2>Jeu Selfie Coupe du monde</h2>
  142.             <p>Du 21 novembre 2022 au 18 décembre 2022, prends-toi en selfie, personnalise-le aux couleurs de ton équipe, et tente de gagner</p>
  143.             <p><strong>l'une des 5.000 récompenses en jeu</strong></p>
  144.             <form method="post" action="" onsubmit="muestraVentana(2);return false;">
  145.                 <input type="submit" value="Je participe" />
  146.                 <label for="check1">
  147.                     <input type="checkbox" name="check1" id="check1" required /> J’accepte la <a href="{{ path('confidencialidad') }}" title="Politique de confidentialité">politique de confidentialité</a>
  148.                 </label>
  149.                 <label for="check2">
  150.                     <input type="checkbox" name="check2" id="check2" required /> J’accepte le <a href="{{ path('reglamento') }}" title="Règlement">règlement</a>
  151.                 </label>
  152.             </form>
  153.         </div>
  154.         <footer>
  155.             <ul>
  156.                 <li><a href="{{ path('reglamento') }}" title="Règlement">Règlement</a></li>
  157.                 <li> - <a href="{{ path('confidencialidad') }}" title="Politique de confidentialité">Politique de confidentialité</a></li>
  158.                 <li> - <a href="{{ path('contacto') }}" title="Contact">Contact</a></li>
  159.             </ul>
  160.         </footer>
  161.     </div>
  162.     <div class="ventana ventana-2 participar">
  163.         <h1><a href="{{ path('program_campaigns') }}" title="">Entrez dans le club</a></h1>
  164.         <div class="box">
  165.             <h2>Comment ça marche ?<br/>C’est très simple</h2>
  166.             <ul>
  167.                 <li><strong>1</strong> <span>Achète une boisson pour un minimum de 5 €</span></li>
  168.                 <li><strong>2</strong> <span>Créée ton selfie personnalisé</span></li>
  169.                 <li><strong>3</strong> <span>Poste ton ticket de caisse</span></li>
  170.                 <li><strong>4</strong> <span>Découvre immédiatement si tu as gagné un lot de 10 tirages photos Cheerz, livrées directement chez toi</span></li>
  171.             </ul>
  172.         </div>
  173.         <div class="wrapper-btn">
  174.             <a href="#" title="C’est parti !" class="btn ir-a-ventana" numero-ventana="3">C’est parti !</a>
  175.         </div>
  176.         <footer>
  177.             <ul>
  178.                 <li><a href="{{ path('reglamento') }}" title="Règlement">Règlement</a></li>
  179.                 <li> - <a href="{{ path('confidencialidad') }}" title="Politique de confidentialité">Politique de confidentialité</a></li>
  180.                 <li> - <a href="{{ path('contacto') }}" title="Contact">Contact</a></li>
  181.             </ul>
  182.         </footer>
  183.     </div>
  184.     <div class="ventana ventana-3 ">
  185.         <h1><a href="{{ path('program_campaigns') }}" title="">Entrez dans le club</a></h1>
  186.         <div class="pasos paso1 visible">
  187.             <h3>Télécharge ta photo</h3>
  188.             <ul class="numero-paso">
  189.                 <li class="actual">1</li>
  190.                 <li>2</li>
  191.                 <li>3</li>
  192.             </ul>
  193.             <ul class="opciones">
  194.                 <li class="box seleccionar"><a href="#" id="fileSelect" title="Sélectionner une photo">Sélectionner une photo</a></li>
  195.                 <li class="box camara"><a href="#" id="pictureFromCamera" title="Prendre une photo<">Prendre une photo</a></li>
  196.             </ul>
  197.             <!-- De galería -->
  198.             <input type="file" id="fileElem" accept="image/*" style="display:none" />
  199.             <script>
  200.                 const fileSelect = document.getElementById("fileSelect"),
  201.                     fileElem = document.getElementById("fileElem");
  202.                 fileSelect.addEventListener("click", (e) => {
  203.                     if (fileElem) {
  204.                         fileElem.click();
  205.                     }
  206.                     e.preventDefault(); // prevent navigation to "#"
  207.                 }, false);
  208.                 fileElem.addEventListener("change", handleFiles, false);
  209.                 function handleFiles() {
  210.                     if (this.files.length) {
  211.                         for (let i = 0; i < this.files.length; i++) {
  212.                             urlImagenFondo = window.URL.createObjectURL(this.files[i]);
  213.                         }
  214.                         reloadCanvas();
  215.                         irPaso(2);
  216.                     }
  217.                 }
  218.             </script>
  219.             <!-- De galeria -->
  220.             <input id="cameraFileInput" type="file" accept="image/*" capture="environment" style="display:none"/>
  221.             <img id="pictureFromCamera" />
  222.             <script>
  223.                 const fileSelectCamera = document.getElementById("pictureFromCamera"),
  224.                     fileElemCamara = document.getElementById("cameraFileInput");
  225.                 fileSelectCamera.addEventListener("click", (e) => {
  226.                     if (fileElemCamara) {
  227.                         fileElemCamara.click();
  228.                     }
  229.                     e.preventDefault(); // prevent navigation to "#"
  230.                 }, false);
  231.                 document
  232.                     .getElementById("cameraFileInput")
  233.                     .addEventListener("change", function () {
  234.                         urlImagenFondo = window.URL.createObjectURL(this.files[0]);
  235.                         reloadCanvas();
  236.                         irPaso(2);
  237.                     });
  238.             </script>
  239.         </div>
  240.         <div class="pasos paso2">
  241.             <h3>Porte les couleurs de ton drapeau</h3>
  242.             <ul class="numero-paso">
  243.                 <li>1</li>
  244.                 <li class="actual">2</li>
  245.                 <li>3</li>
  246.             </ul>
  247.             <div class="box">
  248.                 <canvas hidden width="{{ canvasWidth }}" height="{{ canvasHeight }}" id="presize"></canvas>
  249.                 <img hidden id="imagenFondo"/>
  250.                 <div class="preview">
  251.                     <canvas id="canvas" width="{{ canvasWidth }}" height="{{ canvasHeight }}"></canvas>
  252.                 </div>
  253.                 <div id="wrapper-paises" class="wrapper-paises">
  254.                     <ul class="paises" style="width: {{paises|length * 65}}px;">
  255.                         {% for pais in paises %}
  256.                             <li
  257.                                     pais="{{ pais.key }}"
  258.                                     nombre="{{ pais.name }}"
  259.                                     banda="{{ asset('assets/c68ae7b1-8ad2-4ee1-ba95-34dcc54e4181/images/bandas/' ~ pais.key ~ '.png') }}"
  260.                                     cara="{{ asset('assets/c68ae7b1-8ad2-4ee1-ba95-34dcc54e4181/images/caras/' ~ pais.key ~ '.png') }}">
  261.                                 <img src="{{ asset('assets/c68ae7b1-8ad2-4ee1-ba95-34dcc54e4181/images/banderas/' ~ pais.key ~ '.png') }}"/>
  262.                                 <span>{{ pais.name }}</span>
  263.                             </li>
  264.                         {% endfor %}
  265.                     </ul>
  266.                 </div>
  267.             </div>
  268.             <a href="javascript:irPaso(3);exportFullres()" title="Suivant" class="btn">Suivant</a>
  269.             <div hidden id="exportImageContainer">
  270.                 <img id="exportImagePreview">
  271.                 <button id="exportPreview" onclick="exportFullres()">Vista previa imagen exportada</button>
  272.                 <canvas hidden id="exportCanvas"></canvas>
  273.             </div>
  274.             <script>
  275.                 const canvasHeight = {{ canvasHeight }} || 300;
  276.                 const canvasWidth = {{ canvasWidth }} || 300;
  277.                 const canvasExportScale = {{ canvasExportScale }} || 1;
  278.                 //http://fabricjs.com/customization
  279.                 var canvas = new fabric.Canvas('canvas');
  280.                 var imageFabricCara1 = null;
  281.                 var imageFabricCara2 = null;
  282.                 var imageFabricBanda = null;
  283.                 var textboxFabric = null;
  284.                 var imageFabricCara1Coords = null;
  285.                 var imageFabricCara2Coords = null;
  286.                 var selectableOpts = {
  287.                     ml: false, //middle left
  288.                     mr: false, //middle right
  289.                     mt: false, //middle top
  290.                     mb: false //middle bottom
  291.                 };
  292.                 const queryString = window.location.search;
  293.                 const urlParams = new URLSearchParams(queryString);
  294.                 //si existe un parametro tal que debug=1, se muestra el boton para ver la imagen exportada
  295.                 if (urlParams.get("debug")) {
  296.                     document.getElementById("exportImageContainer").removeAttribute("hidden");
  297.                 }
  298.                 /* metodo alternativo
  299.                 const coverImg = (ctx, img, type) => {
  300.                     const imgRatio = img.height / img.width
  301.                     const winRatio = canvasHeight / canvasWidth
  302.                     if ((imgRatio < winRatio && type === 'contain') || (imgRatio > winRatio && type === 'cover')) {
  303.                         const h = canvasWidth * imgRatio
  304.                         ctx.drawImage(img, 0, (canvasHeight - h) / 2, canvasWidth, h)
  305.                     }
  306.                     if ((imgRatio > winRatio && type === 'contain') || (imgRatio < winRatio && type === 'cover')) {
  307.                         const w = canvasWidth * winRatio / imgRatio
  308.                         ctx.drawImage(img, (canvasWidth - w) / 2, 0, w, canvasHeight)
  309.                     }
  310.                 }
  311.                 */
  312.                 function exportFullres() {
  313.                     const imagenFondo = document.getElementById("imagenFondo");
  314.                     //cogemos un canvas, y pintamos la imagen modo 'cover'. Exportamos el canvas a una imagen temporal.
  315.                     const cv = document.getElementById("exportCanvas");
  316.                     cv.setAttribute("width", canvasWidth * canvasExportScale);
  317.                     cv.setAttribute("height", canvasHeight * canvasExportScale);
  318.                     drawImageProp(cv.getContext("2d"), imagenFondo);
  319.                     const exportBackgroundImg = document.createElement("img");
  320.                     exportBackgroundImg.src = cv.toDataURL("image/png", 1);
  321.                     //con esta imagen temporal ya centrada, creamos un canvas instancia de fabricJS y la ponemos de fondo:
  322.                     const fabricExportCanvas = new fabric.Canvas('exportCanvas');
  323.                     function addObjectToExportCanvas(object) {
  324.                         return new Promise(resolve => {
  325.                             object.clone(function (clonedObject) {
  326.                                 fabricExportCanvas.add(clonedObject);
  327.                                 clonedObject.set({
  328.                                     top: clonedObject.top * canvasExportScale,
  329.                                     left: clonedObject.left * canvasExportScale,
  330.                                     scaleY: clonedObject.scaleX * canvasExportScale,
  331.                                     scaleX: clonedObject.scaleY * canvasExportScale
  332.                                 });
  333.                                 resolve(true);
  334.                             });
  335.                         });
  336.                     }
  337.                     fabric.Image.fromURL(exportBackgroundImg.src, async function (img) {
  338.                         fabricExportCanvas.setBackgroundImage(img, fabricExportCanvas.renderAll.bind(fabricExportCanvas));
  339.                         //ahora recorremos todos los elementos del canvas principal, y los clonamos. Debemos modificar todos sus parametros acorde a la
  340.                         //escala que hayamos elegido. Clonar y modificar un elemento del canvas es una operacion asincrona.
  341.                         const canvasObjects = canvas.getObjects();
  342.                         for (let i = 0; i < canvasObjects.length; i++) {
  343.                             await addObjectToExportCanvas(canvasObjects[i]);
  344.                             fabricExportCanvas.renderAll.bind(fabricExportCanvas)
  345.                         }
  346.                         const base64Img = document.getElementById("base64Img");
  347.                         const base64ExportImg = fabricExportCanvas.toDataURL({format: 'png', quality: 1});
  348.                         document.getElementById("exportImagePreview").src = base64ExportImg; //cargamos la imagen en el contenedor de previsualizacion para debug
  349.                         base64Img.setAttribute("value", base64ExportImg);
  350.                     });
  351.                 }
  352.                 function drawImageProp(ctx, img, x, y, w, h, offsetX, offsetY) {
  353.                     if (arguments.length === 2) {
  354.                         x = y = 0;
  355.                         w = ctx.canvas.width;
  356.                         h = ctx.canvas.height;
  357.                     }
  358.                     // default offset is center
  359.                     offsetX = typeof offsetX === "number" ? offsetX : 0.5;
  360.                     offsetY = typeof offsetY === "number" ? offsetY : 0.5;
  361.                     // keep bounds [0.0, 1.0]
  362.                     if (offsetX < 0) offsetX = 0;
  363.                     if (offsetY < 0) offsetY = 0;
  364.                     if (offsetX > 1) offsetX = 1;
  365.                     if (offsetY > 1) offsetY = 1;
  366.                     var iw = img.width,
  367.                         ih = img.height,
  368.                         r = Math.min(w / iw, h / ih),
  369.                         nw = iw * r,   // new prop. width
  370.                         nh = ih * r,   // new prop. height
  371.                         cx, cy, cw, ch, ar = 1;
  372.                     // decide which gap to fill
  373.                     if (nw < w) ar = w / nw;
  374.                     if (Math.abs(ar - 1) < 1e-14 && nh < h) ar = h / nh;  // updated
  375.                     nw *= ar;
  376.                     nh *= ar;
  377.                     // calc source rectangle
  378.                     cw = iw / (nw / w);
  379.                     ch = ih / (nh / h);
  380.                     cx = (iw - cw) * offsetX;
  381.                     cy = (ih - ch) * offsetY;
  382.                     // make sure source rectangle is valid
  383.                     if (cx < 0) cx = 0;
  384.                     if (cy < 0) cy = 0;
  385.                     if (cw > iw) cw = iw;
  386.                     if (ch > ih) ch = ih;
  387.                     // fill image in dest. rectangle
  388.                     ctx.drawImage(img, cx, cy, cw, ch,  x, y, w, h);
  389.                 }
  390.                 function reloadCanvas() {
  391.                     if (!urlImagenFondo) return;
  392.                     imageFabricCara1Coords = imageFabricCara1 ? imageFabricCara1.getCoords() : null;
  393.                     imageFabricCara2Coords = imageFabricCara2 ? imageFabricCara2.getCoords() : null;
  394.                     const preImg = document.getElementById("imagenFondo");
  395.                     const base64Img = document.getElementById("base64Img");
  396.                     preImg.src = urlImagenFondo;
  397.                     //se carga primero la imagen en un canvas oculto, se centra y la exportamos
  398.                     //en el segundo canvas cargamos la imagen ya manipulada
  399.                     preImg.addEventListener('load', e => {
  400.                         const preCanvas = document.getElementById("presize");
  401.                         drawImageProp(preCanvas.getContext("2d"), preImg);
  402.                         fabric.Image.fromURL(preCanvas.toDataURL("image/png", 1), function(img) {
  403.                             canvas.setBackgroundImage(img, canvas.renderAll.bind(canvas), {
  404.                                 scaleX: canvas.width / img.width,
  405.                                 scaleY: canvas.height / img.height,
  406.                             });
  407.                             canvas.renderAll.bind(canvas);
  408.                         });
  409.                     });
  410.                     if (!textboxFabric) {
  411.                         textboxFabric = new fabric.Textbox(nombrePais, {
  412.                             selectable: false,
  413.                             left: 0,
  414.                             top: canvas.height - 40,
  415.                             width: canvas.width,
  416.                             fontSize: 30,
  417.                             fill: '#FFF',
  418.                             textAlign: 'center'
  419.                         });
  420.                         canvas.add(textboxFabric);
  421.                     }
  422.                     textboxFabric.text = nombrePais;
  423.                     const imgCara1 = new Image();
  424.                     imgCara1.src = urlImagenCara1;
  425.                     imgCara1.onload = function() {
  426.                         if (!imageFabricCara1) {
  427.                             imageFabricCara1 = new fabric.Image();
  428.                             imageFabricCara1.set({left: 150, top: 210});
  429.                             imageFabricCara1.setControlsVisibility(selectableOpts);
  430.                             canvas.add(imageFabricCara1);
  431.                         }
  432.                         imageFabricCara1.setSrc(urlImagenCara1, function (img) {
  433.                             imageFabricCara1.setCoords(imageFabricCara1Coords);
  434.                             canvas.renderAll();
  435.                         });
  436.                     }
  437.                     const imgCara2 = new Image();
  438.                     imgCara2.src = urlImagenCara2;
  439.                     imgCara2.onload = function(){
  440.                         if (!imageFabricCara2) {
  441.                             imageFabricCara2 = new fabric.Image();
  442.                             imageFabricCara2.set({right: 230, top: 210});
  443.                             imageFabricCara2.setControlsVisibility(selectableOpts);
  444.                             canvas.add(imageFabricCara2);
  445.                         }
  446.                         imageFabricCara2.setSrc(urlImagenCara2, function (img) {
  447.                             imageFabricCara2.setCoords(imageFabricCara2Coords);
  448.                             canvas.renderAll();
  449.                         });
  450.                     }
  451.                     const imgBanda = new Image();
  452.                     imgBanda.src = urlImagenBanda;
  453.                     imgBanda.onload = function(){
  454.                         if (!imageFabricBanda) {
  455.                             imageFabricBanda = new fabric.Image();
  456.                             canvas.add(imageFabricBanda);
  457.                         }
  458.                         imageFabricBanda.set({
  459.                             selectable: false,
  460.                             top: 0,
  461.                             left: 0,
  462.                             angle: 0,
  463.                             padding: 10,
  464.                             cornersize: 10,
  465.                             height: 113,
  466.                             width: 140,
  467.                         });
  468.                         imageFabricBanda.setElement(imgBanda);
  469.                         canvas.renderAll();
  470.                     }
  471.                     //ahora la imagen se exporta al clickar el boton de submit, en lugar de generarla cada vez que se cambia el canvas!
  472.                     //base64Img.setAttribute("value", exportFullres());
  473.                     //document.write('<img src="'+exportFullres()+'"/>');
  474.                     canvas.renderAll();
  475.                 }
  476.             </script>
  477.         </div>
  478.         <div class="pasos paso3">
  479.             <h3>Validation</h3>
  480.             <ul class="numero-paso">
  481.                 <li>1</li>
  482.                 <li>2</li>
  483.                 <li class="actual">3</li>
  484.             </ul>
  485.             <div class="box">
  486.                 <p>Valide ta participation et tente de gagner 10 tirages photos de ton choix, imprimées et livrées directement chez toi!</p>
  487.             </div>
  488.             <form method="post" action="" onsubmit="muestraVentana(4);return false;">
  489.                 <div class="wrapper-btn"><input type="submit" value="Valider" class="btn" /></div>
  490.             </form>
  491.         </div>
  492.         <footer>
  493.             <ul>
  494.                 <li><a href="{{ path('reglamento') }}" title="Règlement">Règlement</a></li>
  495.                 <li> - <a href="{{ path('confidencialidad') }}" title="Politique de confidentialité">Politique de confidentialité</a></li>
  496.                 <li> - <a href="{{ path('contacto') }}" title="Contact">Contact</a></li>
  497.             </ul>
  498.         </footer>
  499.     </div>
  500.     <div class="ventana ventana-4 formulario">
  501.         <h1><a href="{{ path('program_campaigns') }}" title="">Entrez dans le club</a></h1>
  502.         <form id="participation-form" method="POST" action="{{ path('formulario_ok') }}">
  503.             <input type="hidden" name="base64Img" id="base64Img" value="" />
  504.             <div class="box">
  505.                 <h2>Dernière étape</h2>
  506.                 <p>Quelques  informations à remplir pour obtenir ta récompense</p>
  507.                 <label for="nombre">
  508.                     <span>Prénom *</span>
  509.                     <input type="text" name="nombre" id="nombre" required />
  510.                 </label>
  511.                 <label for="apellidos">
  512.                     <span>Nom *</span>
  513.                     <input type="text" name="apellidos" id="apellidos" required />
  514.                 </label>
  515.                 <label for="email">
  516.                     <span>Email *</span>
  517.                     <input type="email" name="email" id="email" required />
  518.                 </label>
  519.                 <label for="confirmemail">
  520.                     <span>Confirmer Email *</span>
  521.                     <input type="email" name="confirmemail" id="confirmemail" required />
  522.                 </label>
  523.                 <label for="fichero">
  524.                     <span>Preuve d’achat *</span>
  525.                     <input type="file" name="fichero" id="fichero" required />
  526.                 </label>
  527.                 <label class="recaptcha-wrapper">
  528.                     <div id="recaptcha_container"></div>
  529.                     <input type="hidden" class="hiddenRecaptcha required" name="hiddenRecaptcha" id="hiddenRecaptcha">
  530.                     <span></span>
  531.                 </label>
  532.                 <label for="check2" class="checkbox">
  533.                     <input type="checkbox" name="check2" id="check2" required /> <span>J’accepte le <a href="{{ path('reglamento') }}" title="Règlement">règlement</a></span>
  534.                 </label>
  535.                 <label for="check1" class="checkbox">
  536.                     <input type="checkbox" name="check1" id="check1" required /> <span>J’accepte la <a href="{{ path('confidencialidad') }}" title="Politique de confidentialité">politique de confidentialité</a></span>
  537.                 </label>
  538.                 <label for="check3" class="checkbox">
  539.                     <input type="checkbox" name="check3" id="check3" /> <span>Je souhaite recevoir de l'information commerciale</span>
  540.                 </label>
  541.             </div>
  542.             <div class="wrapper-btn">
  543.                 <input type="submit" value="Valider" class="btn" onclick="return onSubmit();" />
  544.             </div>
  545.         </form>
  546.         <footer>
  547.             <ul>
  548.                 <li><a href="{{ path('reglamento') }}" title="Règlement">Règlement</a></li>
  549.                 <li> - <a href="{{ path('confidencialidad') }}" title="Politique de confidentialité">Politique de confidentialité</a></li>
  550.                 <li> - <a href="{{ path('contacto') }}" title="Contact">Contact</a></li>
  551.             </ul>
  552.         </footer>
  553.         <script>
  554.             let recaptched = false;
  555.             function onLoadedRecaptcha(response){
  556.                 if (response){
  557.                     recaptched = true;
  558.                     var $recaptcha = $('#g-recaptcha-response');
  559.                     if ($recaptcha.length > 0) {
  560.                         $('#hiddenRecaptcha').valid();
  561.                         $recaptcha.removeAttr('required');
  562.                     }
  563.                     onSubmit(false);
  564.                 }
  565.             }
  566.             function onLoadRecaptcha(){
  567.                 grecaptcha.render('recaptcha_container', {
  568.                     sitekey: '6LeePFwiAAAAAL_hz7XBow_OlyZQ-CXLUtjO8YqA',
  569.                     hl: '{{ app.request.locale }}',
  570.                     callback: onLoadedRecaptcha
  571.                 });
  572.             }
  573.             function onSubmit(submit = true) {
  574.                 jQuery.validator.addMethod(
  575.                     "regex",
  576.                     function(value, element, regexp) {
  577.                         if (regexp.constructor != RegExp)
  578.                             regexp = new RegExp(regexp);
  579.                         else if (regexp.global)
  580.                             regexp.lastIndex = 0;
  581.                         return this.optional(element) || regexp.test(value);
  582.                     },"Error en expresión regular"
  583.                 );
  584.                 $("#participation-form").validate({
  585.                     errorPlacement: function(error, element) {
  586.                         error.insertAfter( element.parents("label").find("span") );
  587.                     },
  588.                     ignore: ".ignore",
  589.                     rules: {
  590.                         nombre : {
  591.                             required: true
  592.                         },
  593.                         apellidos : {
  594.                             required: true
  595.                         },
  596.                         email: {
  597.                             required: true,
  598.                             regex: /^(([^<>()\[\]\\.,;:\s@”]+(\.[^<>()\[\]\\.,;:\s@”]+)*)|(“.+”))@((\[[0–9]{1,3}\.[0–9]{1,3}\.[0–9]{1,3}\.[0–9]{1,3}])|(([a-zA-Z\-0–9]+\.)+[a-zA-Z]{2,}))$/
  599.                         },
  600.                         confirmemail: {
  601.                             required: true,
  602.                             regex: /^(([^<>()\[\]\\.,;:\s@”]+(\.[^<>()\[\]\\.,;:\s@”]+)*)|(“.+”))@((\[[0–9]{1,3}\.[0–9]{1,3}\.[0–9]{1,3}\.[0–9]{1,3}])|(([a-zA-Z\-0–9]+\.)+[a-zA-Z]{2,}))$/,
  603.                             equalTo : "#email"
  604.                         },
  605.                         fichero: {
  606.                             required: true,
  607.                         },
  608.                         check1: {
  609.                             required: true,
  610.                         },
  611.                         check2: {
  612.                             required: true,
  613.                         },
  614.                         hiddenRecaptcha: {
  615.                             required: function () {
  616.                                 if (grecaptcha.getResponse() == '') {
  617.                                     return true;
  618.                                 } else {
  619.                                     return false;
  620.                                 }
  621.                             }
  622.                         }
  623.                     },
  624.                     messages : {
  625.                         nombre: {
  626.                             required: "Merci de bien vouloir introduire un prénom valide"
  627.                         },
  628.                         apellidos: {
  629.                             required: "Merci de bien vouloir introduire un nom valide"
  630.                         },
  631.                         email: {
  632.                             required: "Merci de bien vouloir introduire une email valide",
  633.                             regex: "Merci de bien vouloir introduire une email valide"
  634.                         },
  635.                         confirmemail: {
  636.                             required: "Merci de bien vouloir introduire une email valide",
  637.                             regex: "Merci de bien vouloir introduire une email valide",
  638.                             equalTo: "Les e-mails ne correspondent pas"
  639.                         },
  640.                         fichero: {
  641.                             required: "Merci de bien vouloir télécharger un fichier valide",
  642.                         },
  643.                         check1: {
  644.                             required: "Vous devez cocher la case",
  645.                         },
  646.                         check2: {
  647.                             required: "Vous devez cocher la case",
  648.                         },
  649.                         hiddenRecaptcha: {
  650.                             required: "Campo de preenchimento obrigatório",
  651.                         }
  652.                     },
  653.                     errorClass: 'inp-error'
  654.                 });
  655.             }
  656.         </script>
  657.     </div>
  658.     <div class="modal modal-aviso" id="modal-aviso-cookies">
  659.         <div class="modal-content">
  660.             <h2>INFORMATIONS IMPORTANTES SUR LES COOKIES</h2>
  661.             <p>Ce site utilise des cookies propres et tiers pour analyser votre navigation, afin de vous fournir un contenu personnalisé et conforme à vos intérêts. Pour un service de navigation optimal, veuillez accepter notre politique de cookies</p>
  662.             <p class="acciones">
  663.                 <a href="#" title="J’accepte" class="close-modal btn" onclick="aceptarCookies();">J’accepte</a>
  664.             </p>
  665.         </div>
  666.     </div>
  667. {% endblock %}
  668. {% block externalsjs %}
  669.     <script src="https://www.google.com/recaptcha/api.js?onload=onLoadRecaptcha&render=explicit" async defer></script>
  670. {% endblock %}