trilium/src/public/javascripts/services/app_context.js

46 lines
1.1 KiB
JavaScript
Raw Normal View History

import GlobalButtonsWidget from "../widgets/global_buttons.js";
import SearchBoxWidget from "../widgets/search_box.js";
import SearchResultsWidget from "../widgets/search_results.js";
import NoteTreeWidget from "../widgets/note_tree.js";
2020-01-12 16:57:28 +08:00
class AppContext {
constructor() {
this.widgets = [];
}
trigger(name, data) {
for (const widget of this.widgets) {
widget.eventReceived(name, data);
}
}
showWidgets() {
const $leftPane = $("#left-pane");
2020-01-12 18:15:23 +08:00
this.noteTreeWidget = new NoteTreeWidget(this);
this.widgets = [
new GlobalButtonsWidget(this),
new SearchBoxWidget(this),
new SearchResultsWidget(this),
2020-01-12 18:15:23 +08:00
this.noteTreeWidget
];
for (const widget of this.widgets) {
const $widget = widget.render();
$leftPane.append($widget);
}
}
2020-01-12 18:15:23 +08:00
/**
* @return {NoteTreeWidget}
*/
getMainNoteTree() {
return this.noteTreeWidget;
}
2020-01-12 16:57:28 +08:00
}
const appContext = new AppContext();
export default appContext;