Spaces:
Running
Running
When I click the purchasing button nothing happens
Browse files- dashboard.html +13 -13
dashboard.html
CHANGED
|
@@ -74,14 +74,14 @@
|
|
| 74 |
Dashboard
|
| 75 |
</a>
|
| 76 |
<div class="relative">
|
| 77 |
-
<button class="nav-link w-full text-left px-3 py-2 text-sm rounded-lg flex items-center justify-between">
|
| 78 |
<span class="flex items-center">
|
| 79 |
<i data-feather="shopping-cart" class="w-4 h-4 inline mr-2"></i>
|
| 80 |
Purchasing
|
| 81 |
</span>
|
| 82 |
-
<i data-feather="chevron-down" class="w-4 h-4 transition-transform duration-200"></i>
|
| 83 |
</button>
|
| 84 |
-
|
| 85 |
<a href="#" class="nav-link block px-3 py-2 text-sm rounded-lg">
|
| 86 |
<i data-feather="users" class="w-4 h-4 inline mr-2"></i>
|
| 87 |
Suppliers
|
|
@@ -310,30 +310,30 @@
|
|
| 310 |
sidebar.classList.toggle('-translate-x-64');
|
| 311 |
});
|
| 312 |
// Toggle purchasing submenu
|
| 313 |
-
const
|
|
|
|
| 314 |
const submenu = document.querySelector('.submenu');
|
| 315 |
|
| 316 |
-
|
| 317 |
e.stopPropagation();
|
| 318 |
-
|
| 319 |
submenu.classList.toggle('hidden');
|
| 320 |
-
|
| 321 |
});
|
| 322 |
|
| 323 |
-
// Close sidebar when clicking outside
|
| 324 |
-
|
| 325 |
if (window.innerWidth < 1024 &&
|
| 326 |
!sidebar.contains(e.target) &&
|
| 327 |
!sidebarToggle.contains(e.target)) {
|
| 328 |
sidebar.classList.add('-translate-x-64');
|
| 329 |
}
|
| 330 |
-
|
| 331 |
// Close submenu if clicking outside
|
| 332 |
-
if (!
|
| 333 |
submenu.classList.add('hidden');
|
| 334 |
-
|
| 335 |
}
|
| 336 |
-
|
| 337 |
</script>
|
| 338 |
</body>
|
| 339 |
</html>
|
|
|
|
| 74 |
Dashboard
|
| 75 |
</a>
|
| 76 |
<div class="relative">
|
| 77 |
+
<button class="nav-link w-full text-left px-3 py-2 text-sm rounded-lg flex items-center justify-between purchasing-menu-toggle">
|
| 78 |
<span class="flex items-center">
|
| 79 |
<i data-feather="shopping-cart" class="w-4 h-4 inline mr-2"></i>
|
| 80 |
Purchasing
|
| 81 |
</span>
|
| 82 |
+
<i data-feather="chevron-down" class="w-4 h-4 transition-transform duration-200 purchasing-menu-icon"></i>
|
| 83 |
</button>
|
| 84 |
+
<div class="mt-1 ml-6 hidden submenu">
|
| 85 |
<a href="#" class="nav-link block px-3 py-2 text-sm rounded-lg">
|
| 86 |
<i data-feather="users" class="w-4 h-4 inline mr-2"></i>
|
| 87 |
Suppliers
|
|
|
|
| 310 |
sidebar.classList.toggle('-translate-x-64');
|
| 311 |
});
|
| 312 |
// Toggle purchasing submenu
|
| 313 |
+
const purchasingMenuToggle = document.querySelector('.purchasing-menu-toggle');
|
| 314 |
+
const purchasingMenuIcon = document.querySelector('.purchasing-menu-icon');
|
| 315 |
const submenu = document.querySelector('.submenu');
|
| 316 |
|
| 317 |
+
purchasingMenuToggle.addEventListener('click', (e) => {
|
| 318 |
e.stopPropagation();
|
| 319 |
+
e.preventDefault();
|
| 320 |
submenu.classList.toggle('hidden');
|
| 321 |
+
purchasingMenuIcon.classList.toggle('rotate-180');
|
| 322 |
});
|
| 323 |
|
| 324 |
+
// Close sidebar and submenu when clicking outside
|
| 325 |
+
document.addEventListener('click', (e) => {
|
| 326 |
if (window.innerWidth < 1024 &&
|
| 327 |
!sidebar.contains(e.target) &&
|
| 328 |
!sidebarToggle.contains(e.target)) {
|
| 329 |
sidebar.classList.add('-translate-x-64');
|
| 330 |
}
|
|
|
|
| 331 |
// Close submenu if clicking outside
|
| 332 |
+
if (!purchasingMenuToggle.contains(e.target) && !submenu.contains(e.target)) {
|
| 333 |
submenu.classList.add('hidden');
|
| 334 |
+
purchasingMenuIcon.classList.remove('rotate-180');
|
| 335 |
}
|
| 336 |
+
});
|
| 337 |
</script>
|
| 338 |
</body>
|
| 339 |
</html>
|