summaryrefslogtreecommitdiff
path: root/static/js/dropdown.js
diff options
context:
space:
mode:
Diffstat (limited to 'static/js/dropdown.js')
-rw-r--r--static/js/dropdown.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/static/js/dropdown.js b/static/js/dropdown.js
new file mode 100644
index 0000000..00b7ee6
--- /dev/null
+++ b/static/js/dropdown.js
@@ -0,0 +1,30 @@
+document.addEventListener('DOMContentLoaded', function () {
+ // Handle dropdown clicks
+ document.querySelectorAll('.options-subitem > a').forEach(function (item) {
+ item.addEventListener('click', function (e) {
+ e.preventDefault();
+ const parent = this.parentElement;
+
+ if (parent.classList.contains('disabled')) {
+ return;
+ }
+
+ document.querySelectorAll('.options-subitem.open').forEach(function (other) {
+ if (other !== parent) {
+ other.classList.remove('open');
+ }
+ });
+
+ parent.classList.toggle('open');
+ });
+ });
+
+ // Close dropdowns when clicking outside
+ document.addEventListener('click', function (e) {
+ if (!e.target.closest('.options-subitem')) {
+ document.querySelectorAll('.options-subitem.open').forEach(function (item) {
+ item.classList.remove('open');
+ });
+ }
+ });
+}); \ No newline at end of file