%PDF- %PDF-
Direktori : /var/www/maraton.eco-n-tech.co.uk/wp-content/themes/maraton/src/js/ |
Current File : /var/www/maraton.eco-n-tech.co.uk/wp-content/themes/maraton/src/js/app.js |
import $ from "jquery"; import Swiper, { Autoplay } from 'swiper'; Swiper.use([Autoplay]); import 'swiper/scss'; // import select2 from 'select2' // import 'select2/dist/css/select2.css' import { gsap } from "gsap"; import { ScrollTrigger } from "gsap/ScrollTrigger"; import { ScrollToPlugin } from "gsap/ScrollToPlugin"; gsap.registerPlugin(ScrollTrigger); gsap.registerPlugin(ScrollToPlugin); // import Masonry from "masonry-layout"; // import axios from "axios"; // import mobile from 'is-mobile'; import '@fortawesome/fontawesome-free/js/fontawesome'; // import '@fortawesome/fontawesome-free/js/solid' // import '@fortawesome/fontawesome-free/js/regular' import '@fortawesome/fontawesome-free/js/brands'; // import "./utils/bootstrapGrid" import { Accordion, Modal } from 'bootstrap'; import "../scss/main.scss"; // jQuery { $(function($) { $(document).ready(() => { if ($('.s-header').length > 0) { $('body').addClass('has-header-section'); } // Gsap ScrollTrigger replace animate.css classes for animation gsap.utils.toArray('[data-animate]').forEach((elem) => { ScrollTrigger.create({ trigger: elem, end: 'bottom -25%', onEnter: () => window.innerWidth > 768 && elem.classList.add('animate__animated', 'animate__' + elem.dataset.animate), // onLeaveBack: () => window.innerWidth > 768 && elem.classList.remove('animate__animated', 'animate__' + elem.dataset.animate), onEnterBack: () => window.innerWidth > 768 && elem.classList.add('animate__animated', 'animate__' + elem.dataset.animate), // onLeave: () => window.innerWidth > 768 && elem.classList.remove('animate__animated', 'animate__' + elem.dataset.animate), }); }); }); // Header scrolled class const checkScroll = () => { const scroll = $(window).scrollTop(); if (scroll >= 95) { $(".header").addClass("scrolled"); } else { $(".header").removeClass("scrolled"); } } checkScroll(); // check on load $(window).scroll(checkScroll); // check on scroll // Add id to links with anchor $('a[href^="#"]').each(function() { if (this.hash !== "") { $(this).attr('id', this.hash.replace('#', '')); } }); const modal = new Modal(document.querySelector('#boka-ett-mode--modal')); // Document click event document.addEventListener('click', e => { // click on #main-nav--toggle to toggle the menu if (e.target.closest('#main-nav--toggle')) { document.querySelector('body').classList.toggle('navigation-active'); const menuItems = document.querySelectorAll('#nav-main ul li'); let showIter = menuItems.length * 100; menuItems.forEach(li => { li.classList.remove('animate__animated', 'animate__fadeInDown'); li.style.opacity = 0; setTimeout(() => { li.classList.add('animate__animated', 'animate__fadeInDown'); li.style.opacity = 1; }, showIter); showIter -= 100; }) } if (e.target.hash == '#boka-ett-mote') { e.preventDefault(); modal.toggle(); } }); // Contact Form 7 { document.querySelectorAll('.s-contact_form__form-arrow').forEach(el => { el.parentNode.querySelector('.s-contact_form__form-footer > div').prepend(el); }); // } Contact Form 7 // Cookies { const setCookie = function(name,value,days) { var expires = ""; if (days) { var date = new Date(); date.setTime(date.getTime() + (days*24*60*60*1000)); expires = "; expires=" + date.toUTCString(); } document.cookie = name + "=" + (value || "") + expires + "; path=/"; } const getCookie = function(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } const eraseCookie = function(name) { document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'; } const cookiePopup = document.querySelector('.cookies-popup'); if(cookiePopup) { setTimeout(() => { if(!getCookie('cookiePopup')) { cookiePopup.classList.remove('cookies-popup--hidden'); } }, 1000); } const closeCookiePopup = document.querySelectorAll('.cookies--header--close, .cookies-popup--footer--accept, .cookies-popup--footer--close'); closeCookiePopup.forEach(button => { button.addEventListener('click', e => { cookiePopup.classList.add('cookies-popup--hidden'); if(button.classList.contains('cookies-popup--footer--accept')) { setCookie('cookiePopup',1,180); } }); }); // } Cookies }); // } jQuery