This commit is contained in:
zadam
2019-05-01 23:06:18 +02:00
parent 7e03f14e01
commit 63ab82a076
11 changed files with 100 additions and 92 deletions

View File

@@ -44,11 +44,22 @@ async function reload() {
}
async function switchToNote(noteId) {
if (getActiveNoteId() !== noteId) {
if (Object.keys(noteContexts).length === 0) {
const tabContent = $("#note-tab-content-template").clone();
tabContent.removeAttr('id');
tabContent.attr('data-note-id', noteId);
$noteTabsContainer.append(tabContent);
noteContexts[noteId] = new NoteContext(noteId);
}
//if (getActiveNoteId() !== noteId) {
await saveNotesIfChanged();
await loadNoteDetail(noteId);
}
//}
}
function getActiveNoteContent() {
@@ -60,7 +71,7 @@ function onNoteChange(func) {
}
async function saveNotesIfChanged() {
for (const ctx of noteContexts) {
for (const ctx of Object.values(noteContexts)) {
await ctx.saveNoteIfChanged();
}
@@ -103,7 +114,7 @@ function getActiveContext() {
}
function showTab(noteId) {
for (const ctx of noteContexts) {
for (const ctx of Object.values(noteContexts)) {
ctx.$noteTab.toggle(ctx.noteId === noteId);
}
}