embedded init.js

This commit is contained in:
g7sim 2023-07-22 20:48:48 +02:00
parent 20ee404411
commit 1984cc52b7
2 changed files with 1 additions and 59 deletions

View file

@ -2,62 +2,3 @@
function externalLinks() { for(var c = document.getElementsByTagName("a"), a = 0;a < c.length;a++) { var b = c[a];
b.getAttribute("href") && b.hostname !== location.hostname && (b.rel = "nofollow noopener") } } ; externalLinks();
// menu -classes
//$( "div.gpMenu ul.dropdown-menu li a").addClass("dropdown-item");
//$( "div.gpMenu ul.navbar-nav li.nav-item a").addClass("nav-link");
$(document).ready(function() {
$("ul.navbar-nav > li > ul.dropdown-menu > li > ul.dropdown-menu").addClass("submenu");
});
document.addEventListener("DOMContentLoaded", function() {
var dropdownMenus = document.querySelectorAll("ul.navbar-nav > li > ul.dropdown-menu > li > ul.dropdown-menu");
for (var i = 0; i < dropdownMenus.length; i++) {
dropdownMenus[i].classList.add("submenu");
}
});
// Replace div.gpMenu ul.dropdown-menu li a with dropdown-item class
var dropdownItems = document.querySelectorAll("div.gpMenu ul.dropdown-menu li a");
for (var i = 0; i < dropdownItems.length; i++) {
dropdownItems[i].classList.add("dropdown-item");
}
// Replace div.gpMenu ul.navbar-nav li.nav-item a with nav-link class
var navLinks = document.querySelectorAll("div.gpMenu ul.navbar-nav li.nav-item a");
for (var i = 0; i < navLinks.length; i++) {
navLinks[i].classList.add("nav-link");
}
// JavaScript/jQuery code to handle dropdowns
document.addEventListener("DOMContentLoaded", function() {
var dropdownToggle = document.querySelector(".navbar .dropdown-toggle");
if (dropdownToggle) {
dropdownToggle.addEventListener("click", function(e) {
e.preventDefault();
var dropdownMenu = dropdownToggle.nextElementSibling;
if (dropdownMenu.style.display === "block") {
dropdownMenu.style.display = "none";
} else {
dropdownMenu.style.display = "block";
}
});
}
});
// (c) 2020-2022 Written by Simon Köhler in Panama
// github.com/koehlersimon
// simon-koehler.com
document.addEventListener('click',function(e){
// Hamburger menu
if(e.target.classList.contains('hamburger-toggle')){
e.target.children[0].classList.toggle('active');
}
})

View file

@ -21,5 +21,6 @@ $themeDir = dirname($page->theme_path);
//$page->head_js[] = $themeDir.'/assets/js/bootnavbar.js';
$page->head_js[] = $themeDir.'/assets/js/script.js';
$page->head_js[] = $themeDir.'/assets/js/init.js';