AOS.init({ once: true })
new WOW().init();
$(document).ready(function () {
var url = window.location.pathname;
var filename = "/" + url.substring(url.lastIndexOf('/') + 1);
$("header .nav-item .nav-link").removeClass("active");
$(`header .nav-item .nav-link[href="${filename}"]`).addClass("active")
});
$(window).scroll(function (e) {
var scroll = $(window).scrollTop();
if (scroll >= 75) {
$("header").addClass("scroll");
} else {
$("header").removeClass("scroll");
}
});
// $(document).ready(function(){
// if(location.href.includes("cart=open")){
// console.log("cart open")
// const cartOffcanvas = new bootstrap.Offcanvas('#view-cart-offcanvas')
// cartOffcanvas.show()
// }
// })
$("#packages-slider").owlCarousel({
loop: true,
margin: 30,
dots: false,
navText: ['<i class="fa-solid fa-chevron-left"></i>', '<i class="fa-solid fa-chevron-right"></i>'],
responsiveClass: true,
responsive: {
0: {
items: 1,
nav: true
},
600: {
items: 2,
nav: true,
},
1000: {
items: 3,
nav: true,
loop: true,
}
}
})
function dataURLtoFile(dataurl, filename) {
var arr = dataurl.split(','),
mime = arr[0].match(/:(.*?);/)[1],
bstr = atob(arr[arr.length - 1]),
n = bstr.length,
u8arr = new Uint8Array(n);
while(n--){
u8arr[n] = bstr.charCodeAt(n);
}
return new File([u8arr], filename, {type:mime});
}
// toast message
setTimeout(() => {
$(".toast").remove()
}, 5000);
function createToast(message, type = 'success') {
let toast = document.createElement("div")
$(toast).append(`<div class="toast ${type} align-items-center show" role="alert" aria-live="assertive" aria-atomic="true">
<div class="d-flex">
<div class="toast-body">${message}</div>
<button type="button" class="close-btn me-2 m-auto" data-bs-dismiss="toast" aria-label="Close">
<i class="fa-regular fa-xmark"></i>
</button>
</div>
</div>`)
$(".toast-container").append(toast)
setTimeout(() => {
$(toast).remove()
}, 5000);
}
$("#cer-anonymously").change(function () {
if ($(this).prop("checked")) {
$(this).parent().prev().hide()
$(this).parent().prev().children().val("Someone")
}
else {
$(this).parent().prev().show()
$(this).parent().prev().children().val("")
}
})
$(".cerf-reason").change(function(){
if(this.selectedIndex == 1){
$(".reason-other-inp").attr("required",true).parent().slideDown()
}else{
$(".reason-other-inp").removeAttr("required").val("").parent().slideUp()
}
})
$("#send-anonymously").change(function(){
if($(this).prop("checked")){
$("#sender-name-ecard").prev().hide()
$("#sender-name-ecard").attr("readonly",true).hide().val("Someone")
}else{
$("#sender-name-ecard").prev().show()
$("#sender-name-ecard").removeAttr("readonly").show().val("")
}
})
$(".select-custom a").click(function(){
$(this).next().toggle()
})
$(".select-custom .select-options li").click(function(){
$(this).parent().hide()
const val = $(this).data("value")
const lbl = $(this).html()
$(this).parents(".select-custom").find("input").val(val)
$(this).parents(".select-custom").find("a").html(lbl)
if(!val){
$(this).parents(".select-custom").next().slideDown()
$(this).parents(".select-custom").next().children().attr("required",true)
}else{
$(this).parents(".select-custom").next().slideUp()
$(this).parents(".select-custom").next().children().removeAttr("required")
}
})
$("#E-Card-Message").keydown(function(e){
const count = $(this).val().length + 1
if(count == 300 && (e.keyCode !== 8 || e.key !== "Backspace")){
e.preventDefault()
}
$(".text-counter").html(`(Remaining: ${300 - count} characters)`)
})
$("body").click(function(e){
if($(e.target).parents(".select-custom").length == 0){
$(".select-custom .select-options").hide()
}
})
$(".modal").each((ind,elem)=>{
const myModal = elem;
myModal.addEventListener('hide.bs.modal', function (event) {
$(myModal).find('*[name]').val('')
});
})
// (function ($) {
// let classes = ['outline-primary', 'outline-dark', 'outline-danger', 'info', 'secondary'];
// let selects = $('select');
// selects.each(function (i, e) {
// let randomClass = classes[Math.floor(Math.random() * classes.length)];
// $(this).bsSelectDrop({
// // btnClass: 'btn btn-'+classes[i],
// btnClass: 'select-multiple',
// btnWidth: 'auto',
// darkMenu: false,
// showSelectionAsList: false,
// showActionMenu: true,
// // showSelectedText: (count, total) => {return `${count} von ${total} Städte ausgewählt`}
// });
// })
// }(jQuery));