removed closing of dialog box on an outside click and moved escape key logic to dialog.js

This commit is contained in:
Lisa Chandra 2020-02-28 18:40:15 +05:30
parent ad017434dc
commit 07149d4083
7 changed files with 12 additions and 138 deletions

View File

@ -120,22 +120,6 @@ 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) {
@ -449,8 +433,6 @@ ClusteringDialog.prototype._export = function() {
ClusteringDialog.prototype._dismiss = function() {
DialogSystem.dismissUntil(this._level - 1);
$(document).off('click');
$(window).off('keydown');
};
ClusteringDialog.prototype._getBaseClusters = function() {

View File

@ -67,34 +67,10 @@ ColumnReorderingDialog.prototype._createDialog = function() {
connectWith: '.column-reordering-dialog-column-container'
})
.disableSelection();
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);
};
ColumnReorderingDialog.prototype._dismiss = function() {
DialogSystem.dismissUntil(this._level - 1);
$(document).off('click');
$(window).off('keydown');
};
ColumnReorderingDialog.prototype._commit = function() {

View File

@ -241,28 +241,6 @@ 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();
};
@ -297,8 +275,6 @@ CustomTabularExporterDialog.prototype._configureUIFromOptionCode = function(opti
CustomTabularExporterDialog.prototype._dismiss = function() {
DialogSystem.dismissUntil(this._level - 1);
$(document).off('click');
$(window).off('keydown');
};
CustomTabularExporterDialog.prototype._previewDownload = function() {

View File

@ -290,28 +290,6 @@ function SqlExporterDialog(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();
};
@ -332,8 +310,6 @@ function SqlExporterDialog(options) {
SqlExporterDialog.prototype._dismiss = function() {
DialogSystem.dismissUntil(this._level - 1);
$(document).off('click');
$(window).off('keydown');
};
SqlExporterDialog.prototype._previewDownload = function() {

View File

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

View File

@ -57,28 +57,6 @@ ReconDialog.prototype._createDialog = function() {
this._elmts.reconcileButton.click(function() { self._onOK(); });
this._elmts.cancelButton.click(function() { self._dismiss(); });
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._populateDialog();
};
@ -103,8 +81,6 @@ ReconDialog.prototype._dismiss = function() {
this._serviceRecords = null;
DialogSystem.dismissUntil(this._level - 1);
$(document).off('click');
$(window).off('keydown');
};
ReconDialog.prototype._cleanDialog = function() {

View File

@ -61,6 +61,14 @@ DialogSystem.showDialog = function(elmt, onCancel) {
var level = DialogSystem._layers.length;
var escapeKey = function(event) {
if (event.keyCode == 27) {
DialogSystem.dismissUntil(level - 1);
}
}
$(window).keydown(escapeKey);
return level;
};
@ -90,11 +98,15 @@ DialogSystem.dismissUntil = function(level) {
for (var i = DialogSystem._layers.length - 1; i >= level; i--) {
DialogSystem.dismissLevel(i);
}
$(window).off('keydown');
DialogSystem._layers = DialogSystem._layers.slice(0, level);
};
DialogSystem.createDialog = function() {
return $('<div></div>').addClass("dialog-frame");
};
DialogSystem.showBusy = function(message) {