$(document).ready(function () { const headerGeneral = $('#headerGeneral'); if (/android/i.test(userAgent) || /iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) { configureBanner(); const urlsArray = [ '/', '/suivi-de-colis/', '/suivi-de-colis', '/trouver-le-point-relais-le-plus-proche-de-chez-moi/', '/trouver-le-point-relais-le-plus-proche-de-chez-moi' ]; let smartbanner_exited = getCookie("smartbanner_exited"); if (!smartbanner_exited) { if (urlsArray.includes(window.location.pathname)) { $(".smartbanner").show(); headerGeneral.css('padding-top', '75px'); //$(".smartbanner__whitness").show() // avoid the sticky btn being hidden $(".btn-send-pedago").css('margin-top', '100px') } } } $(".smartbanner__exit").click((e) => { e.preventDefault(); setCookie("smartbanner_exited", 1, 365); $(".smartbanner").hide(); $(".smartbanner__whitness").hide(); // reset sticky btn's style $(".btn-send-pedago").css('margin-top', 'unset') }) }); var setCookie = (cName, cValue, expDays) => { let now = new Date(); let expireTime = new Date(now.getTime() + (expDays * 24 * 60 * 60 * 1000)); const expires = "expires=" + expireTime.toUTCString(); document.cookie = cName + "=" + cValue + "; " + expires + "; path=/"; } var getCookie = (cName) => { const name = cName + "="; const cDecoded = decodeURIComponent(document.cookie); const cArr = cDecoded.split("; "); let value; cArr.forEach(val => { if (val.indexOf(name) === 0) { value = val.substring(name.length); } }) return value; } const userAgent = navigator.userAgent || navigator.vendor || window.opera; function configureBanner() { let marketUrl; if (/android/i.test(userAgent)) { marketUrl = `market://details?id=com.mondialrelay.mobile`; if (window.location.pathname.includes("suivi-de-colis")) { marketUrl = `https://8a9s.adj.st?adj_t=1b2a841i_1bhhfmzq`; } if (window.location.pathname.includes("trouver-le-point-relais-le-plus-proche-de-chez-moi")) { marketUrl = `https://8a9s.adj.st?adj_t=1i9mw6n6_1iwa471t`; } $(".smartbanner").addClass("smartbanner--android"); } else if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) { marketUrl = `https://8a9s.adj.st?adj_t=1b24s115_1ba0kocj`; if (window.location.pathname.includes("suivi-de-colis")) { marketUrl = `https://8a9s.adj.st?adj_t=1b2a841i_1bhhfmzq`; } if (window.location.pathname.includes("trouver-le-point-relais-le-plus-proche-de-chez-moi")) { marketUrl = `https://8a9s.adj.st?adj_t=1i9mw6n6_1iwa471t`; } $(".smartbanner").addClass("smartbanner--ios"); } else { return; } $(".smartbanner__button").attr("href", marketUrl); } $(document).ready(function () { const headerGeneral = $('#headerGeneral'); const target = document.querySelector('.js_smartbanner'); if (target) { const observer = new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { if (mutation.attributeName === 'style' || mutation.attributeName === 'class') { if ($(target).is(':visible')) { headerGeneral.css('padding-top', '75px'); } else { headerGeneral.css('padding-top', '0px') } } }); }); observer.observe(target, { attributes: true }); } const buttonMenu = $("#mobile-btn") buttonMenu.on('click', changePadding); function changePadding() { if ($(target).is(':visible')) { headerGeneral.css('padding-top', '75px'); } else { headerGeneral.css('padding-top', '0px') } } });