
<\/div>\r\n <\/div>"},"mobileOn":false,"caisseOn":false,"bookingsOn":true};
var config = moduleParams.productsInfiniteLoadingConfig;
var loading = false; // Indique s'il y a un chargement en cours
var containerSelector = (config.moduleVersion == 'v1') ? '.liste_produits_produits:last' : '.liste_produits_produits_v16';
if (config.moduleVersion == 'v1' && config.button != '') $(containerSelector).after(config.button); // En v1, le bouton est chargé en JS.
$('body').on('click', '.products_infinite_loading a', function () {
var $This = $(this);
if (!loading && $This.data('nextpagenum') <= $This.data('lastpagenum')) { // Si pas de chargement en cours et toutes les pages non chargées
var href = $This.attr('href');
var $listeProduitsLoader = $('.products_infinite_loading_loader'); // Loader
loading = true;
$listeProduitsLoader.show(); // On affiche le loader
$This.hide(); // On masque le lien
$.ajax({
url: href,
complete: function (data) {
$('.liste-produits-pages, .liste_produits_pages_v16').hide();
var newNextPageNum = $This.data('nextpagenum') + 1;
if (newNextPageNum <= $This.data('lastpagenum')) { // S'il y a encore des pages à charger, on modifie le href et on ré-affiche le bouton
$This.attr('href', href.replace('page=' + $This.data('nextpagenum'), 'page=' + newNextPageNum)); // On change le numéro de page
$This.show(); // On affiche le lien
}
$This.data('nextpagenum', newNextPageNum);
// On affiche le nouveau listing produits
if (config.moduleVersion == 'v1') {
$(containerSelector).after(data.responseText);
} else {
$(containerSelector).append(data.responseText);
}
$('body').trigger('ajaxListingProductsLoaded'); // Chargement de leurs images
$listeProduitsLoader.hide(); // On masque le loader
loading = false;
}
});
}
return false;
});
if (config.mode == 'scroll') {
$(window).scroll(function () {
var $loading = $('.products_infinite_loading');
if ($loading.length > 0 && ($loading.offset().top - $(this).height()) < $(this).scrollTop()) {
$loading.find('a').trigger('click');
}
});
}
}(jQuery));
(function ($) {
var moduleParams = {"markupMode":"div","autoSwitchDevice":true,"mobileStatus":true,"mobileIsV16":true,"languagesCode":"fr","pwaEnabled":true,"isSnapchatiOs":0,"httpServer":"","mobileOn":false,"caisseOn":false,"bookingsOn":true};
// Lazy loading
var jQueryUnveil = jQuery().unveil;
function lazyLoad() {
if (jQueryUnveil) {
$("img.lazy").unveil();
}
};
$('body').on('ajaxListingProductsLoaded', function () {
lazyLoad();
});
$(window).on('load', function () {
lazyLoad();
});
// Smooth Scroll marquee
if ($('marquee.defilante-smooth').length > 0) {
$('marquee.defilante-smooth').on('load', function () {
$('marquee.defilante-smooth').marquee().mouseover(function () {
$(this).trigger('stop');
})
.mouseout(function () {
$(this).trigger('start');
})
.mousemove(function (event) {
if ($(this).data('drag') == true) {
this.scrollLeft = $(this)
.data('scrollX') + ($(this)
.data('x') - event.clientX);
}
})
.mousedown(function (event) {
$(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
})
.mouseup(function () {
$(this).data('drag', false);
});
});
}
// https://developers.google.com/recaptcha/docs/display#explicit_render
CaptchaCallback = function () {
$('.g-recaptcha').each(function () {
var $this = $(this);
grecaptcha.render(this, {'sitekey': $this.data('sitekey'), 'stoken': $this.data('stoken')});
});
};
/*
* RECAPTCHA V2
*/
recaptchaV2CurrentIndex = 0; // index du captcha qui est traité
// Fonction exécutée par le recaptcha v2 si valide
CaptchaV2Submit = function (token) {
var $form = $('#recaptcha_' + recaptchaV2CurrentIndex).closest('form');
$form.find('input[name="g-recaptcha-response"]').val(token); // On rempli le champ qui sert de traitement en PHP.
$form.submit(); // On renvoi le formulaire après validation
}
// Fonction exécutée au chargement de la page si le captcha v2 est activé
CaptchaV2Callback = function () {
// Envoi du formulaire recaptcha v2
$('.g-recaptcha').closest('form').submit(function () {
var $form = $(this);
recaptchaV2CurrentIndex = $form.find('.g-recaptcha').data('index');
if ($form.find('input[name="g-recaptcha-response"]').val() != '') {
return true; // Si captcha validé, tout est OK, on peut envoyer le formulaire
}
grecaptcha.execute(recaptchaV2CurrentIndex); // Contrôle de captcha. Si c'est OK, CaptchaV2Submit sera appelé et cette même fonction (submit) sera appelée
return false;
});
}
/*
* RECAPTCHA V2 - FIN
*/
//Chargement de la version mobile à la volée en dessous de 768px et chargement de la version PC sur mobile si > 768px
//Ne fonctionne que sur PC , le device MObile prend le dessus.
//Ne fonctionne pas si la version mobile est à OFF ou en V1
if (moduleParams.autoSwitchDevice && moduleParams.mobileStatus && moduleParams.mobileIsV16 && $.browser.desktop) {
function checkWidth() {
if ((window.innerWidth < 768 && !moduleParams.mobileOn) || (window.innerWidth >= 768 && moduleParams.mobileOn)) {
$(window).unbind('resize');
$.get("/ajax.php?page=switchDevice", function () {
}).done(function () {
$('HTML').css({
'background-image': 'url("/images/loading.gif")',
'background-repeat': 'no-repeat',
'background-position': 'center center',
'background-color': 'white!important',
'height': '100%'
});
$('BODY').fadeOut('slow');
}).always(function () {
setTimeout(function () {
location.reload(true);
}, 400);
});
}
}
$(window).resize(checkWidth);
$(window).trigger('resize');
}
if (moduleParams.mobileOn && moduleParams.pwaEnabled) {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('js/service-worker.js')
.then(function (registration) {
console.log('Registration successful, scope is:', registration.scope);
})
.catch(function (error) {
console.log('Service worker registration failed, error:', error);
});
}
}
/**
* BDC n°16021 - Sessions sur Snapchat iOS
* Si l'user agent contient "iPhone OS" et "Snapchat" alors les sessions ne sont pas conservées
* (le cookie navigateur générique "session" est remis à 0 mais pas les cookies faits maison).
* Donc on crée un cookie fait maison "sa-session" pour stocker le premier session_id créé.
* Comme ça si l'utilisateur revient sur le site on récupère ce "sa-session"
* en back via $_COOKIE pour récupérer la session
*/
if (moduleParams.isSnapchatiOs) {
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
if (!getCookie('sa-session')) {
setCookie('sa-session', getCookie('session'), 30, moduleParams.httpServer)
}
}
}(jQuery));