From 91058de64fc7d71dc16c050995076346b7d754f1 Mon Sep 17 00:00:00 2001 From: Lisa Chandra Date: Thu, 27 Feb 2020 18:59:16 +0530 Subject: [PATCH] closes cluster dialog when a click is made outside the dialog box and when escape key is pressed --- .../core/scripts/dialogs/clustering-dialog.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/main/webapp/modules/core/scripts/dialogs/clustering-dialog.js b/main/webapp/modules/core/scripts/dialogs/clustering-dialog.js index c399dbddc..4cb38dbf6 100644 --- a/main/webapp/modules/core/scripts/dialogs/clustering-dialog.js +++ b/main/webapp/modules/core/scripts/dialogs/clustering-dialog.js @@ -120,6 +120,22 @@ ClusteringDialog.prototype._createDialog = function() { this._elmts.applyCloseButton.click(function() { self._onApplyClose(); }); this._elmts.closeButton.click(function() { self._dismiss(); }); + var clickOutside = function(event) { + $target = $(event.target); + var dist = $target.closest(dialog).length; + if(dist == 0 && $(dialog).is(':visible')) { + self._dismiss(); + } + } + $(document).click(clickOutside); + + var escapeKey = function(event) { + if (event.keyCode == 27) { + self._dismiss(); + } + } + $(window).keydown(escapeKey); + // Fill in all the keyers and distances $.get("command/core/get-clustering-functions-and-distances") .success(function(data) { @@ -433,6 +449,8 @@ ClusteringDialog.prototype._export = function() { ClusteringDialog.prototype._dismiss = function() { DialogSystem.dismissUntil(this._level - 1); + $(document).off('click'); + $(window).off('keydown'); }; ClusteringDialog.prototype._getBaseClusters = function() {