dismiss context menu when click outside of it
@@ -755,11 +755,6 @@ function bindFileBrowserItemEvents() {
}
});
- // Dismiss right click menu when mouse down outside of it
- $("#fb-files-container, #fb-files-container li, #hsDropzone").mousedown(function () {
- $(".selection-menu").hide();
- });
-
var timer = 0;
var delay = 200;
var prevent = false;
@@ -940,6 +935,18 @@ function bindFileBrowserItemEvents() {
$(".selection-menu").hide(); // Hide other menus
+ // register a listener for clicks outside of the context menu
+ $(document).on('click.menu', function(event) {
+ var $target = $(event.target);
+ console.log(this);
+ if(!$target.closest('#right-click-menu').length &&
+ $('#right-click-menu').css("display") !== "none") {
+ $('#right-click-menu').hide();
+ }
+ // de-register listener to allow bubbling
+ $(document).off('click.menu');
+ });
+
var top = event.pageY;
var left = event.pageX;
