notebookbar: show context tabs if needed

Change-Id: I4deb132600ef34654dba665683a248691691e03d
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
This commit is contained in:
Szymon Kłos 2021-01-18 13:55:08 +01:00 committed by Szymon Kłos
parent bed804309a
commit e6850dc9f7

View file

@ -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;
},