function bootnavbar(options) { const defaultOption = { selector: "main_navbar", animation: false, animateIn: "animate__fadeIn", }; const bnOptions = { ...defaultOption, ...options }; init = function () { var dropdowns = document.getElementById(bnOptions.selector).getElementsByClassName("dropdown"); Array.prototype.forEach.call(dropdowns, (item) => { //add animation if (bnOptions.animation) { const element = item.querySelector(".dropdown-menu"); element.classList.add("animate__animated"); element.classList.add(bnOptions.animateIn); } // if (navigator.maxTouchPoints || 'ontouchstart' in document.documentElement) { //hover effects item.addEventListener("mouseover", function () { this.classList.add("show"); const element = this.querySelector(".dropdown-menu"); element.classList.add("show"); }); item.addEventListener("mouseout", function () { this.classList.remove("show"); const element = this.querySelector(".dropdown-menu"); element.classList.remove("show"); }); // }else{ // item.addEventListener("onclick", function () { // this.classList.add("show"); // const element = this.querySelector(".dropdown-menu"); // element.classList.add("show"); // }); // } }); }; init(); }