From 91058de64fc7d71dc16c050995076346b7d754f1 Mon Sep 17 00:00:00 2001 From: Lisa Chandra Date: Thu, 27 Feb 2020 18:59:16 +0530 Subject: [PATCH 1/8] closes cluster dialog when a click is made outside the dialog box and when escape key is pressed --- .../core/scripts/dialogs/clustering-dialog.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/main/webapp/modules/core/scripts/dialogs/clustering-dialog.js b/main/webapp/modules/core/scripts/dialogs/clustering-dialog.js index c399dbddc..4cb38dbf6 100644 --- a/main/webapp/modules/core/scripts/dialogs/clustering-dialog.js +++ b/main/webapp/modules/core/scripts/dialogs/clustering-dialog.js @@ -120,6 +120,22 @@ 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) { @@ -433,6 +449,8 @@ ClusteringDialog.prototype._export = function() { ClusteringDialog.prototype._dismiss = function() { DialogSystem.dismissUntil(this._level - 1); + $(document).off('click'); + $(window).off('keydown'); }; ClusteringDialog.prototype._getBaseClusters = function() { From 7e86197339d15c905d5532d8ab7964419117c08a Mon Sep 17 00:00:00 2001 From: Lisa Chandra Date: Thu, 27 Feb 2020 21:26:07 +0530 Subject: [PATCH 2/8] 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() { From 2de7015645abf9e18284fb60619f8d6ea4729584 Mon Sep 17 00:00:00 2001 From: Lisa Chandra Date: Thu, 27 Feb 2020 21:42:11 +0530 Subject: [PATCH 3/8] closes templating export dialog when a click is made outside the dialog box or when escape key is pressed --- .../dialogs/templating-exporter-dialog.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) 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() { From 512aac8143fe4ab0997e2023df8e4e18c870415d Mon Sep 17 00:00:00 2001 From: Lisa Chandra Date: Thu, 27 Feb 2020 22:18:38 +0530 Subject: [PATCH 4/8] closes sql exporter dialog box when a click is made outside the dialog box or when escape key is pressed --- .../scripts/dialogs/sql-exporter-dialog.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/main/webapp/modules/core/scripts/dialogs/sql-exporter-dialog.js b/main/webapp/modules/core/scripts/dialogs/sql-exporter-dialog.js index cf10d1112..bcdfc8db4 100755 --- a/main/webapp/modules/core/scripts/dialogs/sql-exporter-dialog.js +++ b/main/webapp/modules/core/scripts/dialogs/sql-exporter-dialog.js @@ -289,6 +289,28 @@ function SqlExporterDialog(options) { this._elmts.cancelButton.click(function() { self._dismiss(); }); 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(); @@ -310,6 +332,8 @@ function SqlExporterDialog(options) { SqlExporterDialog.prototype._dismiss = function() { DialogSystem.dismissUntil(this._level - 1); + $(document).off('click'); + $(window).off('keydown'); }; SqlExporterDialog.prototype._previewDownload = function() { From e3f125dd9f506fea485b7b655a09495c69afe64b Mon Sep 17 00:00:00 2001 From: Lisa Chandra Date: Thu, 27 Feb 2020 22:35:20 +0530 Subject: [PATCH 5/8] closes reconcilation dialog when a click is made outsid the dialog box or when escape key is pressed --- .../scripts/reconciliation/recon-dialog.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/main/webapp/modules/core/scripts/reconciliation/recon-dialog.js b/main/webapp/modules/core/scripts/reconciliation/recon-dialog.js index 025159ae7..10d11621f 100644 --- a/main/webapp/modules/core/scripts/reconciliation/recon-dialog.js +++ b/main/webapp/modules/core/scripts/reconciliation/recon-dialog.js @@ -57,6 +57,28 @@ 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(); }; @@ -81,6 +103,8 @@ ReconDialog.prototype._dismiss = function() { this._serviceRecords = null; DialogSystem.dismissUntil(this._level - 1); + $(document).off('click'); + $(window).off('keydown'); }; ReconDialog.prototype._cleanDialog = function() { From ad017434dcbf28d60b6bcb13d2af528222839181 Mon Sep 17 00:00:00 2001 From: Lisa Chandra Date: Fri, 28 Feb 2020 01:54:16 +0530 Subject: [PATCH 6/8] closes reorder/remove dialog when a click is made outside or when escape key is presses --- .../dialogs/column-reordering-dialog.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/main/webapp/modules/core/scripts/dialogs/column-reordering-dialog.js b/main/webapp/modules/core/scripts/dialogs/column-reordering-dialog.js index 3343f8483..5de661475 100644 --- a/main/webapp/modules/core/scripts/dialogs/column-reordering-dialog.js +++ b/main/webapp/modules/core/scripts/dialogs/column-reordering-dialog.js @@ -67,10 +67,34 @@ 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() { From 07149d408386efb993ad1c81cea6e4de7cca9ba1 Mon Sep 17 00:00:00 2001 From: Lisa Chandra Date: Fri, 28 Feb 2020 18:40:15 +0530 Subject: [PATCH 7/8] removed closing of dialog box on an outside click and moved escape key logic to dialog.js --- .../core/scripts/dialogs/clustering-dialog.js | 18 -------------- .../dialogs/column-reordering-dialog.js | 24 ------------------- .../dialogs/custom-tabular-exporter-dialog.js | 24 ------------------- .../scripts/dialogs/sql-exporter-dialog.js | 24 ------------------- .../dialogs/templating-exporter-dialog.js | 24 ------------------- .../scripts/reconciliation/recon-dialog.js | 24 ------------------- .../modules/core/scripts/util/dialog.js | 12 ++++++++++ 7 files changed, 12 insertions(+), 138 deletions(-) diff --git a/main/webapp/modules/core/scripts/dialogs/clustering-dialog.js b/main/webapp/modules/core/scripts/dialogs/clustering-dialog.js index 4cb38dbf6..c399dbddc 100644 --- a/main/webapp/modules/core/scripts/dialogs/clustering-dialog.js +++ b/main/webapp/modules/core/scripts/dialogs/clustering-dialog.js @@ -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() { diff --git a/main/webapp/modules/core/scripts/dialogs/column-reordering-dialog.js b/main/webapp/modules/core/scripts/dialogs/column-reordering-dialog.js index 5de661475..3343f8483 100644 --- a/main/webapp/modules/core/scripts/dialogs/column-reordering-dialog.js +++ b/main/webapp/modules/core/scripts/dialogs/column-reordering-dialog.js @@ -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() { 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 4cf04e504..6620e39c2 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,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() { diff --git a/main/webapp/modules/core/scripts/dialogs/sql-exporter-dialog.js b/main/webapp/modules/core/scripts/dialogs/sql-exporter-dialog.js index bcdfc8db4..e1a41fdc7 100755 --- a/main/webapp/modules/core/scripts/dialogs/sql-exporter-dialog.js +++ b/main/webapp/modules/core/scripts/dialogs/sql-exporter-dialog.js @@ -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() { 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 279b885ed..acd027837 100644 --- a/main/webapp/modules/core/scripts/dialogs/templating-exporter-dialog.js +++ b/main/webapp/modules/core/scripts/dialogs/templating-exporter-dialog.js @@ -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() { diff --git a/main/webapp/modules/core/scripts/reconciliation/recon-dialog.js b/main/webapp/modules/core/scripts/reconciliation/recon-dialog.js index 10d11621f..025159ae7 100644 --- a/main/webapp/modules/core/scripts/reconciliation/recon-dialog.js +++ b/main/webapp/modules/core/scripts/reconciliation/recon-dialog.js @@ -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() { diff --git a/main/webapp/modules/core/scripts/util/dialog.js b/main/webapp/modules/core/scripts/util/dialog.js index c76e4df94..cfca17131 100644 --- a/main/webapp/modules/core/scripts/util/dialog.js +++ b/main/webapp/modules/core/scripts/util/dialog.js @@ -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 $('
').addClass("dialog-frame"); + }; DialogSystem.showBusy = function(message) { From e563885de1133c8f454480f3cc831c3c128c2d23 Mon Sep 17 00:00:00 2001 From: Lisa Chandra Date: Sat, 29 Feb 2020 22:16:29 +0530 Subject: [PATCH 8/8] moved escapeKey handler to global scope (to prevent only said handler from executing when a dialog is closed) --- .../scripts/dialogs/sql-exporter-dialog.js | 1 - .../modules/core/scripts/util/dialog.js | 20 +++++++++---------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/main/webapp/modules/core/scripts/dialogs/sql-exporter-dialog.js b/main/webapp/modules/core/scripts/dialogs/sql-exporter-dialog.js index e1a41fdc7..60c47b863 100755 --- a/main/webapp/modules/core/scripts/dialogs/sql-exporter-dialog.js +++ b/main/webapp/modules/core/scripts/dialogs/sql-exporter-dialog.js @@ -289,7 +289,6 @@ function SqlExporterDialog(options) { this._elmts.cancelButton.click(function() { self._dismiss(); }); this._elmts.downloadButton.click(function() { self._download(); }); this._elmts.downloadPreviewButton.click(function(evt) { self._previewDownload(); }); - this._configureUIFromOptionCode(options); this._updateOptionCode(); }; diff --git a/main/webapp/modules/core/scripts/util/dialog.js b/main/webapp/modules/core/scripts/util/dialog.js index cfca17131..8b3c6e339 100644 --- a/main/webapp/modules/core/scripts/util/dialog.js +++ b/main/webapp/modules/core/scripts/util/dialog.js @@ -35,6 +35,13 @@ DialogSystem = { _layers: [] }; +var escapeKey = function(event) { + var level = DialogSystem._layers.length; + if (event.keyCode == 27) { + DialogSystem.dismissUntil(level - 1); + } +} + DialogSystem.showDialog = function(elmt, onCancel) { var overlay = $('
 
') .addClass("dialog-overlay") @@ -61,14 +68,8 @@ 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; }; @@ -98,15 +99,12 @@ DialogSystem.dismissUntil = function(level) { for (var i = DialogSystem._layers.length - 1; i >= level; i--) { DialogSystem.dismissLevel(i); } - $(window).off('keydown'); + $(window).off('keydown', escapeKey); DialogSystem._layers = DialogSystem._layers.slice(0, level); - }; DialogSystem.createDialog = function() { - return $('
').addClass("dialog-frame"); - }; DialogSystem.showBusy = function(message) {