closes templating export dialog when a click is made outside the dialog box or when escape key is pressed

This commit is contained in:
Lisa Chandra 2020-02-27 21:42:11 +05:30
parent 7e86197339
commit 2de7015645

View File

@ -64,6 +64,28 @@ TemplatingExporterDialog.prototype._createDialog = function() {
self._updatePreview(); 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); this._level = DialogSystem.showDialog(dialog);
}; };
@ -117,6 +139,8 @@ TemplatingExporterDialog.prototype._scheduleUpdate = function() {
TemplatingExporterDialog.prototype._dismiss = function() { TemplatingExporterDialog.prototype._dismiss = function() {
DialogSystem.dismissUntil(this._level - 1); DialogSystem.dismissUntil(this._level - 1);
$(document).off('click');
$(window).off('keydown');
}; };
TemplatingExporterDialog.prototype._updatePreview = function() { TemplatingExporterDialog.prototype._updatePreview = function() {