{% block javascripts %}
<script src="{{ asset('assets/js/jquery-3.6.3.min.js') }}" crossorigin="anonymous"></script>
<script src="{{ asset('assets/js/jquery-ui.js') }}"></script>
<script src="{{ asset('assets/js/bootstrap.bundle.min.js') }}"></script>
<script src="{{ asset('assets/js/aos.js') }}"></script>
<script src="{{ asset('assets/js/jquery-animated-headline.min.js') }}"></script>
<script src="{{ asset('assets/js/slick.min.js') }}?v=1"></script>
<script src="{{ asset('assets/js/scripts.js') }}?v=8"></script>
{% if captcha_enabled %}
<script src="https://www.google.com/recaptcha/api.js?hl=fr" async="" defer=""></script>
{% endif %}
<script type="text/javascript">
// set cookie
$(document).ready(function () {
if (!document.cookie.includes("Estiam France")) {
$('.cookie-consent-banner').fadeIn();
}
$('.cookie-consent-banner').on('click', '.cookie-action', function () {
let $this = $(this);
let $cookie_consent = $this.closest('.cookie-consent-banner');
let action = $this.attr('data-action');
console.log('cookie action ', action);
$cookie_consent.fadeOut();
switch (action) {
case 'accept':
document.cookie = "cookieBy= Estiam France; max-age=" + 60 * 60 * 24 * 365;
break;
case 'refuse':
default:
document.cookie = "cookieBy= Estiam France; max-age=" + 60 * 60 * 24 * 30;
break;
}
});
});
// Login form
$('#login-form').on('submit', function (event) {
event.preventDefault();
let data = $(this).serialize();
let $button = $(this).find('#btn-login');
$button.prepend('<i class="fas fa-spinner fa-pulse mr-1"></i>');
$button.prop('disabled', true);
$.ajax({
url: "{{ path('user.login') }}",
type: "POST",
dataType: 'json',
data : data,
success: function(res) {
if(res.success){
$('#signinModal .user-error').hide();
window.location.href = res.target_url;
}else{
$('#signinModal .user-error').show();
}
}
}).always(function () {
$button.find('.fa-pulse').remove();
$button.prop('disabled', false);
});
});
// Forgot password
$('.btn-forgot').click(function (){
if($('#forgotPasswordModal #field-email').val() == '') return;
$('.valid-email-forgot').hide();
let $button = $('#forgotPasswordModal').find('.btn-forgot');
$button.prepend('<i class="fas fa-spinner fa-pulse mr-1"></i>');
$button.prop('disabled', true);
var emailReset = $('#forgotPasswordModal').find('#field-email').val();
$.ajax({
url: "{{ path('user.request_reset_password') }}",
type: "POST",
dataType: 'json',
data : {email: $('#forgotPasswordModal').find('#field-email').val()},
success: function(res) {
if(res.status == 'failed'){
$('.valid-email-forgot').show();
}
else{
$('.append-email').text(emailReset);
$('.sent-email-forgot').show();
$('.hide-success').hide();
}
}
}).always(function () {
$button.find('.fa-pulse').remove();
$button.prop('disabled', false);
});
});
function checkFile(inputFile) {
if (inputFile[0].files[0].name.match(/.(pdf|docx|doc|png|jpg)$/i)) {
var size = parseInt(inputFile[0].files[0].size) / 1024;
if (size > 110485760) {
return "{% trans %}Grande taille de fichier. Vous pouvez télécharger un maximum de 5 Mo{% endtrans %}";
}
} else {
return "{% trans %}Type de fichier invalide. Vous ne pouvez télécharger que des fichiers PDF/Word{% endtrans %}";
}
}
function DataURIToBlob(dataURI) {
const splitDataURI = dataURI.split(',')
const byteString = splitDataURI[0].indexOf('base64') >= 0 ? atob(splitDataURI[1]) : decodeURI(splitDataURI[1])
const mimeString = splitDataURI[0].split(':')[1].split(';')[0]
const ia = new Uint8Array(byteString.length)
for (let i = 0; i < byteString.length; i++)
ia[i] = byteString.charCodeAt(i)
return new Blob([ia], { type: mimeString })
}
function showMessage(text) {
$('.notification-error').text(text).show();
handleNotification($('.notification-error'));
removeLoadButton($('#btn-submit'));
}
function handleNotification(element) {
setTimeout(function () {
element.fadeOut();
}, 3000);
}
function loadButton(element) {
element.find('i').removeClass('far fa-arrow-right');
element.find('i').addClass('fas fa-spinner fa-pulse ml-1');
element.prop('disabled', true);
}
function removeLoadButton(element) {
element.find('i').removeClass('fas fa-spinner fa-pulse ml-1');
element.find('i').addClass('far fa-arrow-right');
element.prop('disabled', false);
}
function isChecked(element){
if($(element).find('input:checkbox:checked').length > 0){
return 0;
}
return 1;
}
function requiredFile(element){
let error = 0;
if(!$(`#${element}`).val()){
$(`.${element}`).addClass('text-red');
error = 1;
removeLoadButton($('#btn-submit'));
}
if(!error){
$(`.${element}`).removeClass('text-red');
}
return error;
}
</script>
{% endblock %}