From dc241ce246e213b922d778aba55d67dfbe17d4c7 Mon Sep 17 00:00:00 2001 From: l_samenv Date: Fri, 30 Aug 2024 10:36:56 +0200 Subject: [PATCH] Close menu when clicking on export, dates and canvas --- client/components/action_entry/action_entry.js | 4 +++- client/jsFiles/SEAWebClientGraphics.js | 10 ++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/client/components/action_entry/action_entry.js b/client/components/action_entry/action_entry.js index 7b79049..39303ec 100644 --- a/client/components/action_entry/action_entry.js +++ b/client/components/action_entry/action_entry.js @@ -1,11 +1,13 @@ class ActionEntry extends HTMLElement{ - constructor(title, actionCallback){ + constructor(title, actionCallback, hideMenuCallback){ super(); this.title = title; this.actionCallback = actionCallback; + this.hideMenuCallback = hideMenuCallback; } performActionCallback(){ + this.hideMenuCallback(); this.actionCallback() } diff --git a/client/jsFiles/SEAWebClientGraphics.js b/client/jsFiles/SEAWebClientGraphics.js index 477c10d..7bcf7bb 100644 --- a/client/jsFiles/SEAWebClientGraphics.js +++ b/client/jsFiles/SEAWebClientGraphics.js @@ -239,6 +239,9 @@ let globalIndicators = (function (){ function loadIndicators(panel){ let leftDate = Date.now() - 30*60*1000; let datesIndicator = new DateIndicator(leftDate, graphs.gotoNow, graphs.jumpToDate); + datesIndicator.addEventListener("click", function () { + menuGraphicsPopup.hide() + }) panel.appendChild(datesIndicator); datesIndicator.style.marginLeft = "auto"; @@ -258,10 +261,12 @@ let globalIndicators = (function (){ })() +let menuGraphicsPopup = undefined; + function loadGraphicsMenu(panel){ - let menuGraphicsPopup = new MenuPopup(); - let exportActionEntry = new ActionEntry("Export", graphs.displayExportPopup); + menuGraphicsPopup = new MenuPopup(); + let exportActionEntry = new ActionEntry("Export", graphs.displayExportPopup, () => {menuGraphicsPopup.hide()}); let removeCursorHelpEntry = new HelpEntry("How to remove the cursor", "You can double click/tap on any graph."); menuGraphicsPopup.addEntry(exportActionEntry) menuGraphicsPopup.addHorizontalDivider(); @@ -605,6 +610,7 @@ let graphs = (function (){ legendFlag = true; let trect = evt.target.getBoundingClientRect(); let X = evt.clientX - trect.x, Y = evt.clientY - trect.y; + menuGraphicsPopup.hide(); showLegends(true, false); cursorLine(X); setLiveMode();