mirror of
https://github.com/zadam/trilium.git
synced 2025-11-06 21:36:05 +01:00
added TabCachingWidget
This commit is contained in:
32
src/public/javascripts/widgets/tab_caching_widget.js
Normal file
32
src/public/javascripts/widgets/tab_caching_widget.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import TabAwareWidget from "./tab_aware_widget.js";
|
||||
|
||||
export default class TabCachingWidget extends TabAwareWidget {
|
||||
constructor(appContext, widgetFactory) {
|
||||
super(appContext);
|
||||
|
||||
this.widgetFactory = widgetFactory;
|
||||
/** @type {JQuery} */
|
||||
this.$parent = null;
|
||||
this.widgets = {};
|
||||
}
|
||||
|
||||
renderTo($parent) {
|
||||
this.$parent = $parent;
|
||||
}
|
||||
|
||||
activeTabChanged() {
|
||||
for (const widget of Object.values(this.widgets)) {
|
||||
widget.toggle(false);
|
||||
}
|
||||
|
||||
let widget = this.widgets[this.tabContext.tabId];
|
||||
|
||||
if (!widget) {
|
||||
widget = this.widgets[this.tabContext.tabId] = this.widgetFactory();
|
||||
widget.renderTo(this.$parent);
|
||||
widget.activeTabChangedListener();
|
||||
}
|
||||
|
||||
widget.toggle(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user