1let supportsPassive = false; 2try { 3 let opts = Object.defineProperty({}, 'passive', { 4 get: function () { 5 supportsPassive = true; 6 }, 7 }); 8 window.addEventListener("testPassive", null, opts); 9 window.removeEventListener("testPassive", null, opts); 10} catch (e) { /* -- */ 11} 12 13function hamburgerAndMobileMenu() 14{ 15 let hamburger = document.querySelector(".hamburger"); 16 let navbar = document.getElementById("navbarSupportedContent"); 17 if (!hamburger) { 18 return; 19 } 20 hamburger.addEventListener("click", function () { 21 this.classList.toggle("is-active"); 22 navbar.classList.toggle("collapsed"); 23 }, supportsPassive ? {passive: true} : false); 24 25 let subMenus = document.querySelectorAll(".navbar-collapse .menu-item-has-children > a"); 26 if (subMenus) { 27 subMenus.forEach((item) => { 28 //console.log(item); 29 item.addEventListener("click", function (evt) { 30 if (-1 === evt.target.href.search('#')) { 31 window.location = evt.target.href; 32 return; 33 } 34 35 evt.preventDefault(); 36 evt.stopImmediatePropagation(); 37 38 item.nextElementSibling.classList.toggle("is-active"); 39 }); 40 }) 41 } 42} 43 44function swiper() 45{ 46 [...document.querySelectorAll('.swiper')].map((swiperElem) => { 47 let dataView = swiperElem.getAttribute('data-view'); 48 let dataInit = swiperElem.getAttribute('data-init'); 49 let dataAutoPlay = swiperElem.getAttribute('data-autoplay'); 50 let dataLoop = swiperElem.getAttribute('data-loop'); 51 52 if (! dataInit) { 53 return false; 54 } 55 56 let args = { 57 slidesPerView: dataView ?? "auto", 58 spaceBetween: 0, 59 loop: true, 60 speed: 800, 61 // If we need pagination 62 pagination: { 63 el: '.swiper-pagination', 64 clickable: true 65 }, 66 67 // Navigation arrows 68 navigation: { 69 nextEl: '.swiper-button-next', 70 prevEl: '.swiper-button-prev', 71 }, 72 breakpoints: { 73 // when window width is >= 320px 74 0: { 75 slidesPerView: 1, 76 spaceBetween: 20 77 }, 78 // when window width is >= 640px 79 640: { 80 slidesPerView: 2, 81 spaceBetween: 10 82 }, 83 // when window width is >= 991px 84 991: { 85 slidesPerView: dataView, 86 spaceBetween: 0 87 } 88 } 89 }; 90 91 // Default loop is true 92 if (dataLoop && '0' === dataLoop) { 93 args.loop = false; 94 } 95 96 if ('1' === dataAutoPlay) { 97 args.autoplay = { 98 delay: 2000, 99 disableOnInteraction: false, 100 } 101 } 102 103 console.log('Swiper args', args); 104 105 let elemClass = ".swiper." + dataInit; 106 new Swiper(elemClass, args); 107 }) 108} 109 110/** 111 * Init functions 112 */ 113function init() 114{ 115 hamburgerAndMobileMenu(); 116 swiper(); 117} 118 119init();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.