From 7e86197339d15c905d5532d8ab7964419117c08a Mon Sep 17 00:00:00 2001 From: Lisa Chandra Date: Thu, 27 Feb 2020 21:26:07 +0530 Subject: [PATCH] closes custom export tab when a click is made outside the tab or when escape key is pressed --- .../dialogs/custom-tabular-exporter-dialog.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/main/webapp/modules/core/scripts/dialogs/custom-tabular-exporter-dialog.js b/main/webapp/modules/core/scripts/dialogs/custom-tabular-exporter-dialog.js index 6620e39c2..4cf04e504 100644 --- a/main/webapp/modules/core/scripts/dialogs/custom-tabular-exporter-dialog.js +++ b/main/webapp/modules/core/scripts/dialogs/custom-tabular-exporter-dialog.js @@ -241,6 +241,28 @@ CustomTabularExporterDialog.prototype._createDialog = function(options) { this._elmts.downloadButton.click(function() { self._download(); }); this._elmts.downloadPreviewButton.click(function(evt) { self._previewDownload(); }); + var justOpened = true; + var clickOutside = function(event) { + $target = $(event.target); + var dialog = $('.dialog-frame'); + var dist = $target.closest(dialog).length; + if(justOpened) { + justOpened = false; + return; + } + if(dist == 0 && $(dialog).is(':visible') && !justOpened) { + self._dismiss(); + } + } + $(document).click(clickOutside); + + var escapeKey = function(event) { + if (event.keyCode == 27) { + self._dismiss(); + } + } + $(window).keydown(escapeKey); + this._configureUIFromOptionCode(options); this._updateOptionCode(); }; @@ -275,6 +297,8 @@ CustomTabularExporterDialog.prototype._configureUIFromOptionCode = function(opti CustomTabularExporterDialog.prototype._dismiss = function() { DialogSystem.dismissUntil(this._level - 1); + $(document).off('click'); + $(window).off('keydown'); }; CustomTabularExporterDialog.prototype._previewDownload = function() {