more refactoring ...

This commit is contained in:
zadam
2020-01-12 23:03:55 +01:00
parent bf7541bfb9
commit 17e2627a34
6 changed files with 27 additions and 16 deletions

View File

@@ -8,6 +8,7 @@ import TabContext from "./tab_context.js";
import server from "./server.js";
import keyboardActionService from "./keyboard_actions.js";
import TabRowWidget from "./tab_row.js";
import NoteTitleWidget from "../widgets/note_title.js";
class AppContext {
constructor() {
@@ -27,6 +28,9 @@ class AppContext {
$("#global-menu-wrapper").after(contents);
this.noteTitleWidget = new NoteTitleWidget(this);
$("#center-pane").prepend(this.noteTitleWidget.render());
this.noteTreeWidget = new NoteTreeWidget(this);
this.widgets = [
@@ -41,14 +45,26 @@ class AppContext {
$leftPane.append($widget);
}
this.widgets.push(this.noteTitleWidget);
}
trigger(name, data) {
this.eventReceived(name, data);
for (const widget of this.widgets) {
widget.eventReceived(name, data);
}
}
eventReceived(name, data) {
const fun = this[name + 'Listener'];
if (typeof fun === 'function') {
fun.call(this, data);
}
}
/** @return {TabContext[]} */
getTabContexts() {
return this.tabContexts;