Преглед изворни кода

close modal when clicking outside area

YutaMatsushima пре 6 година
родитељ
комит
aed6b2bb47
2 измењених фајлова са 8 додато и 5 уклоњено
  1. 6 0
      src/main/webapp/js/help.js
  2. 2 5
      src/main/webapp/js/search.js

+ 6 - 0
src/main/webapp/js/help.js

@@ -10,6 +10,12 @@ $(function() {
     return true;
   });
 
+  $(document).on("click touchend", function(e) {
+    if (!$(e.target).closest("#searchOptions, #searchOptionsButton").length) {
+      $("#searchOptions").removeClass("active");
+    }
+  });
+
   $("[data-toggle='control-options']").click(function(e) {
     e.preventDefault();
     var target = $(this).attr("data-target") || $(this).attr("href");

+ 2 - 5
src/main/webapp/js/search.js

@@ -14,11 +14,8 @@ $(function() {
     return true;
   });
 
-  $("#content").on("click touchend", function(e) {
-    if (
-      !$(e.target).closest("#searchOptions, [data-toggle='control-options']")
-        .length
-    ) {
+  $(document).on("click touchend", function(e) {
+    if (!$(e.target).closest("#searchOptions, #searchOptionsButton").length) {
       $("#searchOptions").removeClass("active");
     }
   });