@@ -22013,8 +22013,13 @@ <h2>Download Other Formats</h2>
2201322013 }, 10);
2201422014 });
2201522015
22016- // Navigation click handlers
22016+ // Combined click handler for navigation and sidebar control
2201722017 document.addEventListener('click', function(e) {
22018+ const sidebar = document.getElementById('sidebar');
22019+ const mainContent = document.getElementById('main-content');
22020+ const isMobile = window.innerWidth <= 1024;
22021+
22022+ // Handle navigation item clicks
2201822023 if (e.target.closest('.nav-item[data-target]')) {
2201922024 e.preventDefault();
2202022025 const navItem = e.target.closest('.nav-item[data-target]');
@@ -22029,29 +22034,25 @@ <h2>Download Other Formats</h2>
2202922034 }
2203022035
2203122036 // Close sidebar on mobile after navigation
22032- if (window.innerWidth <= 1024) {
22033- const sidebar = document.getElementById('sidebar');
22034- const mainContent = document.getElementById('main-content');
22037+ if (isMobile) {
2203522038 sidebar.classList.remove('open');
2203622039 mainContent.classList.remove('sidebar-open');
2203722040 }
22041+ return; // Exit early
2203822042 }
22039- });
22040-
22041- // Close sidebar when clicking outside on mobile
22042- document.addEventListener('click', function(e) {
22043- if (window.innerWidth <= 1024) {
22044- const sidebar = document.getElementById('sidebar');
22045- const mainContent = document.getElementById('main-content');
22043+
22044+ // Handle clicking outside sidebar on mobile
22045+ if (isMobile && sidebar.classList.contains('open')) {
2204622046 const sidebarToggle = document.querySelector('.sidebar-toggle');
2204722047
22048- if (!sidebar.contains(e.target) && !sidebarToggle.contains(e.target) && sidebar.classList.contains('open') ) {
22048+ if (!sidebar.contains(e.target) && !sidebarToggle.contains(e.target)) {
2204922049 sidebar.classList.remove('open');
2205022050 mainContent.classList.remove('sidebar-open');
2205122051 }
2205222052 }
2205322053 });
2205422054
22055+
2205522056 // Handle window resize
2205622057 let resizeTimeout;
2205722058 window.addEventListener('resize', function() {
0 commit comments