]> git.ipfire.org Git - thirdparty/google/fonts.git/commitdiff
tags.html: close open dropdown when user clicks elsewhere 8518/head
authorMarc Foley <m.foley.88@gmail.com>
Thu, 21 Nov 2024 10:26:52 +0000 (10:26 +0000)
committerMarc Foley <m.foley.88@gmail.com>
Thu, 21 Nov 2024 10:26:52 +0000 (10:26 +0000)
.ci/tags.html

index 0f533513c5ace6587ae251b2762673d8d5da65df..6bf7a8428f0006cda1be85cb9727e42df6f01757 100644 (file)
       }
     } // methods
   )
+  // close open navbar dropdowns when user clicks elsewhere
+  var details = [...document.querySelectorAll('details')];
+  document.addEventListener('click', function(e) {
+  if (!details.some(f => f.contains(e.target))) {
+    details.forEach(f => f.removeAttribute('open'));
+  } else {
+    details.forEach(f => !f.contains(e.target) ? f.removeAttribute('open') : '');
+  }
+})
 </script>