Commit 7d93ba37 authored by Ivar Derksen's avatar Ivar Derksen
Browse files

Updated irma-frontend version

parent da6e3030
Pipeline #45868 passed with stage
in 7 seconds
This diff is collapsed.
(function ($) { (function ($) {
"use strict" "use strict"
// Mobile Nav toggle // Mobile Nav toggle
$('.menu-toggle > a').on('click', function (e) { $('.menu-toggle > a').on('click', function (e) {
e.preventDefault(); e.preventDefault();
$('#responsive-nav').toggleClass('active'); $('#responsive-nav').toggleClass('active');
}) })
// Fix cart dropdown from closing // Fix cart dropdown from closing
$('.cart-dropdown').on('click', function (e) { $('.cart-dropdown').on('click', function (e) {
e.stopPropagation(); e.stopPropagation();
}); });
///////////////////////////////////////// /////////////////////////////////////////
// Products Slick // Products Slick
$('.products-slick').each(function () { $('.products-slick').each(function () {
var $this = $(this), var $this = $(this),
$nav = $this.attr('data-nav'); $nav = $this.attr('data-nav');
$this.slick({ $this.slick({
slidesToShow: 4, slidesToShow: 4,
slidesToScroll: 1, slidesToScroll: 1,
autoplay: true, autoplay: true,
infinite: true, infinite: true,
speed: 300, speed: 300,
dots: false, dots: false,
arrows: true, arrows: true,
appendArrows: $nav ? $nav : false, appendArrows: $nav ? $nav : false,
responsive: [{ responsive: [{
breakpoint: 991, breakpoint: 991,
settings: { settings: {
slidesToShow: 2, slidesToShow: 2,
slidesToScroll: 1, slidesToScroll: 1,
} }
}, },
{ {
breakpoint: 480, breakpoint: 480,
settings: { settings: {
slidesToShow: 1, slidesToShow: 1,
slidesToScroll: 1, slidesToScroll: 1,
} }
}, },
] ]
}); });
}); });
// Product Main img Slick // Product Main img Slick
$('#product-main-img').slick({ $('#product-main-img').slick({
infinite: true, infinite: true,
speed: 300, speed: 300,
dots: false, dots: false,
arrows: true, arrows: true,
fade: true, fade: true,
asNavFor: '#product-imgs', asNavFor: '#product-imgs',
}); });
// Product imgs Slick // Product imgs Slick
$('#product-imgs').slick({ $('#product-imgs').slick({
slidesToShow: 3, slidesToShow: 3,
slidesToScroll: 1, slidesToScroll: 1,
arrows: true, arrows: true,
centerMode: true, centerMode: true,
focusOnSelect: true, focusOnSelect: true,
centerPadding: 0, centerPadding: 0,
vertical: true, vertical: true,
asNavFor: '#product-main-img', asNavFor: '#product-main-img',
responsive: [{ responsive: [{
breakpoint: 991, breakpoint: 991,
settings: { settings: {
vertical: false, vertical: false,
arrows: false, arrows: false,
dots: true, dots: true,
} }
}, ] }, ]
}); });
// Product img zoom // Product img zoom
var zoomMainProduct = document.getElementById('product-main-img'); var zoomMainProduct = document.getElementById('product-main-img');
if (zoomMainProduct) { if (zoomMainProduct) {
$('#product-main-img .product-preview').zoom(); $('#product-main-img .product-preview').zoom();
} }
// Go to age verification page // Go to age verification page
$('.add-to-cart-btn').on('click', function (element) { $('.add-to-cart-btn').on('click', function (element) {
sessionStorage.setItem('minage', element.currentTarget.getAttribute('data-minage')); sessionStorage.setItem('minage', element.currentTarget.getAttribute('data-minage'));
sessionStorage.setItem('productname', element.currentTarget.getAttribute('data-productname')); sessionStorage.setItem('productname', element.currentTarget.getAttribute('data-productname'));
sessionStorage.setItem('productid', element.currentTarget.id); sessionStorage.setItem('productid', element.currentTarget.id);
window.location.href = 'cart.html'; window.location.href = 'cart.html';
}); });
// If no product is chosen yet, return to the index page. // If no product is chosen yet, return to the index page.
if (location.pathname.includes('cart.html') && !sessionStorage.getItem('productid')) if (location.pathname.includes('cart.html') && !sessionStorage.getItem('productid'))
location.href = 'index.html'; location.href = 'index.html';
// Age verification with IRMA // Age verification with IRMA
if ( window.irma ) { if ( window.irma ) {
console.log("Age verification started"); console.log("Age verification started");
irma.new({ irma.newWeb({
element: '#irma-web-element', element: '#irma-web-element',
session: { session: {
url: '', url: '',
start: { start: {
url: o => `start_session.php?type=` + sessionStorage.getItem('minage') + 'plus', url: o => `start_session.php?type=` + sessionStorage.getItem('minage') + 'plus',
body: null, },
headers: [], result: {
method: 'GET', url: (o, {sessionPtr, sessionToken}) => `${sessionPtr.u.split('/irma')[0]}/session/${sessionToken}/result`,
}, }
result: { },
url: (o, {sessionPtr, sessionToken}) => `${sessionPtr.u.split('/irma')[0]}/session/${sessionToken}/result`,
} translations: {
}, 'success': 'Gegevens ontvangen.'
},
translations: { });
'success': 'Gegevens ontvangen.'
}, let success = function (data) {
}); console.log("Session successful!");
console.log("Result:", data);
let success = function (data) { // Continue to order page if user is 18+
console.log("Session successful!"); if (data.disclosed[0][0].rawvalue.toLowerCase() === 'yes') {
console.log("Result:", data); setTimeout(() => {
// Continue to order page if user is 18+ $('#phase-agecheck').hide();
if (data.disclosed[0][0].rawvalue.toLowerCase() === 'yes') { $('#phase-finished').show();
setTimeout(() => { $('#breadcrumb').show();
$('#phase-agecheck').hide(); $('html').scrollTop(0);
$('#phase-finished').show(); }, 1000);
$('#breadcrumb').show(); } else {
$('html').scrollTop(0); $('#snackbar-content').html('U hebt niet de juiste leeftijd om dit artikel te mogen bestellen.');
}, 1000); $('#snackbar').addClass('show');
} else { }
$('#snackbar-content').html('U hebt niet de juiste leeftijd om dit artikel te mogen bestellen.'); };
$('#snackbar').addClass('show');
} let error = function (data) {
}; console.log("Session failed!");
console.log("Error data:", data);
let error = function (data) { $('#snackbar-content').html('Er is een fout opgetreden bij de leeftijdsverificatie via IRMA.');
console.log("Session failed!"); $('#snackbar').addClass('show');
console.log("Error data:", data); };
$('#snackbar-content').html('Er is een fout opgetreden bij de leeftijdsverificatie via IRMA.');
$('#snackbar').addClass('show'); irma.start().then(success, error);
}; }
irma.start().then(success, error); })(jQuery);
}
})(jQuery);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment