From e6850dc9f71d18416db39afa475d244a38d81ae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20K=C5=82os?= Date: Mon, 18 Jan 2021 13:55:08 +0100 Subject: [PATCH] notebookbar: show context tabs if needed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I4deb132600ef34654dba665683a248691691e03d Signed-off-by: Szymon Kłos --- loleaflet/src/control/Control.Notebookbar.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/loleaflet/src/control/Control.Notebookbar.js b/loleaflet/src/control/Control.Notebookbar.js index d865dfede..b0c4e3c44 100644 --- a/loleaflet/src/control/Control.Notebookbar.js +++ b/loleaflet/src/control/Control.Notebookbar.js @@ -380,19 +380,32 @@ L.Control.Notebookbar = L.Control.extend({ return; var tabs = this.getTabs(); + var contextTab = null; + var defaultTab = null; for (var tab in tabs) { if (tabs[tab].context) { + var tabElement = $('#' + tabs[tab].name + '-tab-label'); + tabElement.hide(); var contexts = tabs[tab].context.split('|'); for (var context in contexts) { if (contexts[context] === event.context) { - var tabElement = $('#' + tabs[tab].name + '-tab-label'); + tabElement.show(); if (!tabElement.hasClass('selected')) - tabElement.click(); + contextTab = tabElement; + } else if (contexts[context] === 'default') { + tabElement.show(); + if (!tabElement.hasClass('selected')) + defaultTab = tabElement; } } } } + if (contextTab) + contextTab.click(); + else if (defaultTab) + defaultTab.click(); + this.lastContext = event.context; },