From cd01e380e0850490c54f2103c1311146cb4cfe4c Mon Sep 17 00:00:00 2001 From: elliot_ <112902069+akatiggerx04@users.noreply.github.com> Date: Wed, 7 Sep 2022 01:00:22 +0300 Subject: First Main Commit --- static/js/scripts.js | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 static/js/scripts.js (limited to 'static/js/scripts.js') diff --git a/static/js/scripts.js b/static/js/scripts.js new file mode 100644 index 0000000..e1380cd --- /dev/null +++ b/static/js/scripts.js @@ -0,0 +1,54 @@ +/*! +* Start Bootstrap - Grayscale v7.0.5 (https://startbootstrap.com/theme/grayscale) +* Copyright 2013-2022 Start Bootstrap +* Licensed under MIT (https://github.com/StartBootstrap/startbootstrap-grayscale/blob/master/LICENSE) +*/ +// +// Scripts +// + +window.addEventListener('DOMContentLoaded', event => { + + // Navbar shrink function + var navbarShrink = function () { + const navbarCollapsible = document.body.querySelector('#mainNav'); + if (!navbarCollapsible) { + return; + } + if (window.scrollY === 0) { + navbarCollapsible.classList.remove('navbar-shrink') + } else { + navbarCollapsible.classList.add('navbar-shrink') + } + + }; + + // Shrink the navbar + navbarShrink(); + + // Shrink the navbar when page is scrolled + document.addEventListener('scroll', navbarShrink); + + // Activate Bootstrap scrollspy on the main nav element + const mainNav = document.body.querySelector('#mainNav'); + if (mainNav) { + new bootstrap.ScrollSpy(document.body, { + target: '#mainNav', + offset: 74, + }); + }; + + // Collapse responsive navbar when toggler is visible + const navbarToggler = document.body.querySelector('.navbar-toggler'); + const responsiveNavItems = [].slice.call( + document.querySelectorAll('#navbarResponsive .nav-link') + ); + responsiveNavItems.map(function (responsiveNavItem) { + responsiveNavItem.addEventListener('click', () => { + if (window.getComputedStyle(navbarToggler).display !== 'none') { + navbarToggler.click(); + } + }); + }); + +}); \ No newline at end of file -- cgit v1.2.3