document.addEventListener('DOMContentLoaded', function () { const dropdowns = document.querySelectorAll('.dropdown-hover'); // dropdowns.forEach((dropdown) => { // const dropdownToggle = dropdown.querySelector('.dropdown-toggle'); // const dropdownMenu = dropdown.querySelector('.dropdown-menu'); // // Initialize Bootstrap Dropdown instance. // // Even without data-bs-toggle, we still need this to programmatically show/hide. // const bsDropdown = new bootstrap.Dropdown(dropdownToggle); // // No need to prevent default click, as the 'a' tag should now navigate // // and we removed data-bs-toggle="dropdown" from the HTML. // // Show dropdown on hover // dropdown.addEventListener('mouseenter', function () { // bsDropdown.show(); // }); // // Hide dropdown when mouse leaves the dropdown area // dropdown.addEventListener('mouseleave', function () { // bsDropdown.hide(); // }); // // Optional: Close dropdown if an item is clicked (standard behavior) // dropdownMenu?.querySelectorAll('.dropdown-item')?.forEach((item) => { // item.addEventListener('click', function () { // bsDropdown.hide(); // }); // }); // }); }); document.addEventListener('DOMContentLoaded', () => { if (window.location.hash) { const target = document.querySelector(window.location.hash); if (target) { const offsetPosition = target.getBoundingClientRect().top + window.scrollY; console.log('offset top ', target.offsetTop); window.scrollTo({ top: offsetPosition, behavior: 'smooth' }); } } }); $(function () { $(window).scroll(function () { if ($(this).scrollTop() > 200) { $('#back-top').fadeIn(300); } else { $('#back-top').fadeOut(500); } }); }); $('#oMenu').on('click', function () { $('body').toggleClass('fixed'); $('.hamburger').toggleClass('is-active'); }); $('.dropdown-item').each(function () { $(this).click(function () { let itemText = $(this).text(); $('body').removeClass('fixed'); $('.hamburger').removeClass('is-active'); $('.navbar-collapse ').removeClass('show'); }); }); function updateTitle(title){ document.title = title; updateMetaTag('og:title' , title); } function updateMetaTag(tagName, tagContent) { // Update the meta description tag let metaTag = document.querySelector('meta[name="'+tagName+'"]'); if (metaTag) { metaTag.setAttribute("content", tagContent); } else { let newMetaTag = document.createElement('meta'); newMetaTag.name = tagName; newMetaTag.content = tagContent; document.head.appendChild(newMetaTag); console.log(newMetaTag) } } $(document).ready(function() { if (typeof meta_title !== 'undefined' && meta_title) { updateTitle(meta_title) } if (typeof meta_description !== 'undefined' && meta_description) { updateMetaTag("description", meta_description) } if (typeof meta_image !== 'undefined' && meta_image) { updateMetaTag("og:image", meta_image) } }); document.addEventListener('DOMContentLoaded', () => { const fontSwitcherButtons = document.querySelectorAll('.btn-fontsize'); const body = document.body; const storageKey = 'selectedFontSize'; // Key for localStorage // Function to set the font size const setFontSize = (size) => { // Remove existing font size classes body.classList.remove('font-small', 'font-medium', 'font-large'); // Add the new font size class body.classList.add(`font-${size}`); // Update active state of buttons fontSwitcherButtons.forEach(button => { if (button.dataset.size === size) { button.classList.add('active'); } else { button.classList.remove('active'); } }); // Save the selected font size to localStorage localStorage.setItem(storageKey, size); }; // Event listeners for the buttons fontSwitcherButtons.forEach(button => { button.addEventListener('click', (event) => { const size = event.target.dataset.size; setFontSize(size); }); }); // Check localStorage for a previously selected font size on page load const storedFontSize = localStorage.getItem(storageKey); if (storedFontSize) { setFontSize(storedFontSize); } else { // If no size is stored, set the default (medium) setFontSize('medium'); } });