Skip to content

Commit

Permalink
Replicate commit 151878b 'Prevent Matrix/Label menu closing immediate…
Browse files Browse the repository at this point in the history
…ly in Safari. See issue #529.'
  • Loading branch information
ChrisWakefield committed Jun 19, 2024
1 parent eb68ddf commit 68212b0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
4 changes: 2 additions & 2 deletions NGCHM/WebContent/javascript/DetailHeatMapEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ DEV.dblClick = function(e) {
*********************************************************************************************/
DEV.matrixRightClick = function (e) {
e.preventDefault();
LNK.labelHelpClose("Matrix");
LNK.labelHelpClose("Matrix", e);
LNK.labelHelpOpen("Matrix",e);
let selection = window.getSelection();
selection.removeAllRanges();
Expand Down Expand Up @@ -1109,7 +1109,7 @@ DEV.detailDataZoomIn = function (mapItem) {
function labelRightClick (e) {
e.preventDefault();
const axis = e.target.dataset.axis;
LNK.labelHelpClose(axis);
LNK.labelHelpClose(axis, e);
LNK.labelHelpOpen(axis,e);
let selection = window.getSelection();
selection.removeAllRanges();
Expand Down
22 changes: 14 additions & 8 deletions NGCHM/WebContent/javascript/Linkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,14 +501,20 @@ var linkoutsVersion = 'undefined';
}
}

LNK.labelHelpCloseAll = function(){
LNK.labelHelpClose("Matrix");
LNK.labelHelpClose("Column");
LNK.labelHelpClose("Row");
LNK.labelHelpCloseAll = function(ev){
ev = ev || {};
LNK.labelHelpClose("Matrix", ev);
LNK.labelHelpClose("Column", ev);
LNK.labelHelpClose("Row", ev);
}


LNK.labelHelpClose = function(axis){
LNK.labelHelpClose = function(axis, ev){
if (ev.ctrlKey || ev.metaKey) {
// Prevent extra ctrl-click event sent by Safari from closing newly opened label menus.
// See issue #539.
return;
}
var labelMenu = axis !== "Matrix" ? document.getElementById(axis + 'LabelMenu') : document.getElementById("MatrixMenu");
var tableBody = labelMenu.getElementsByTagName("TBODY")[0];
var tempClass = tableBody.className;
Expand All @@ -523,7 +529,7 @@ var linkoutsVersion = 'undefined';
LNK.labelHelpOpen = function(axis, e){
menuOpenCanvas = e.currentTarget;
const heatMap = MMGR.getHeatMap();
LNK.labelHelpCloseAll();
LNK.labelHelpCloseAll(e);
//Get the label item that the user clicked on (by axis) and save that value for use in LNK.selection
var index = e.target.dataset.index;
LNK.selection = '';
Expand Down Expand Up @@ -584,7 +590,7 @@ var linkoutsVersion = 'undefined';
topDiv.classList.add("labelMenuCaption");
topDiv.innerHTML = axis !== "Matrix" ? axis.replace("Covar"," Covariate") + ' Label Menu:' : axis + ' Menu';
const closeMenu = UTIL.newElement ('DIV.buttonGroup', {}, UTIL.newElement ("BUTTON.labelMenuClose", {}, UTIL.newElement('SPAN.button', {}, 'Close')));
closeMenu.addEventListener('click', function(){LNK.labelHelpClose(axis)},false);
closeMenu.addEventListener('click', function(ev){LNK.labelHelpClose(axis, ev)},false);
var table = document.createElement("TABLE");
table.id = axis !== "Matrix" ? axis + 'LabelMenuTable' : axis+'MenuTable';
var tableHead = table.createTHead();
Expand All @@ -595,7 +601,7 @@ var linkoutsVersion = 'undefined';
labelMenu.appendChild(closeMenu);
var tableBody = table.createTBody();
tableBody.classList.add('labelMenuBody');
var labelHelpCloseAxis = function(){ LNK.labelHelpClose(axis)};
var labelHelpCloseAxis = function(ev){ LNK.labelHelpClose(axis, ev)};
document.addEventListener('click', labelHelpCloseAxis);
labelMenu.addEventListener("contextmenu",function(e){e.preventDefault()},true);
}
Expand Down

0 comments on commit 68212b0

Please sign in to comment.