From 12e3c9ac3a333e2259ab6f75c2946559b61492c3 Mon Sep 17 00:00:00 2001
From: weru <onewesh@gmail.com>
Date: Sun, 29 Nov 2020 13:24:37 +0000
Subject: [PATCH] edit resource

---
 assets/js/index.js |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/assets/js/index.js b/assets/js/index.js
index 2d0bd9c..e72bce6 100644
--- a/assets/js/index.js
+++ b/assets/js/index.js
@@ -8,10 +8,30 @@
   const target = event.target;
   const isToggleControl = target.matches(`.${toggleId}`);
   const isWithToggleControl = target.closest(`.${toggleId}`);
+  const showInstances = elems(`.${showId}`) ? Array.from(elems(`.${showId}`)) : [];
+  const menuInstance = target.closest(`.${menu}`);
+
+  function showOff(target, self = false) {
+    showInstances.forEach(function(showInstance){
+      if(!self) {
+        deleteClass(showInstance, showId);
+      }
+      if(showInstance !== target.closest(`.${menu}`)) {
+        deleteClass(showInstance, showId);
+      }
+    });
+  }
+
   if(isToggleControl || isWithToggleControl) {
     const menu = isWithToggleControl ? isWithToggleControl.parentNode.parentNode : target.parentNode.parentNode;
     event.preventDefault();
     modifyClass(menu, showId);
+  } else {
+    if(!menuInstance) {
+      showOff(target);
+    } else {
+      showOff(target, true);
+    }
   }
 }
 

--
Gitblit v1.10.0