diff --git a/main/webapp/modules/core/scripts/dialogs/templating-exporter-dialog.js b/main/webapp/modules/core/scripts/dialogs/templating-exporter-dialog.js index acd027837..279b885ed 100644 --- a/main/webapp/modules/core/scripts/dialogs/templating-exporter-dialog.js +++ b/main/webapp/modules/core/scripts/dialogs/templating-exporter-dialog.js @@ -64,6 +64,28 @@ TemplatingExporterDialog.prototype._createDialog = function() { self._updatePreview(); }); + 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._level = DialogSystem.showDialog(dialog); }; @@ -117,6 +139,8 @@ TemplatingExporterDialog.prototype._scheduleUpdate = function() { TemplatingExporterDialog.prototype._dismiss = function() { DialogSystem.dismissUntil(this._level - 1); + $(document).off('click'); + $(window).off('keydown'); }; TemplatingExporterDialog.prototype._updatePreview = function() {