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() {