From 02ab59c9e075d7cf2ab1a08618740bec4ab9532c Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 25 Aug 2019 23:09:22 +0200 Subject: [PATCH] render note type dropdown lazily --- src/public/javascripts/services/note_type.js | 8 ++++++-- src/views/title.ejs | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/public/javascripts/services/note_type.js b/src/public/javascripts/services/note_type.js index 74492d894..3d0b9b59d 100644 --- a/src/public/javascripts/services/note_type.js +++ b/src/public/javascripts/services/note_type.js @@ -60,6 +60,8 @@ class NoteTypeContext { constructor(ctx) { this.ctx = ctx; + ctx.$tabContent.find('.note-type').on('show.bs.dropdown', () => this.renderDropdown()); + this.$noteTypeDropdown = ctx.$tabContent.find(".note-type-dropdown"); this.$noteTypeButton = ctx.$tabContent.find(".note-type-button"); this.$noteTypeDesc = ctx.$tabContent.find(".note-type-desc"); @@ -71,9 +73,11 @@ class NoteTypeContext { this.$noteTypeButton.prop("disabled", () => ["file", "image", "search"].includes(this.ctx.note.type)); - this.$noteTypeDropdown.empty(); - this.$noteTypeDesc.text(this.findTypeTitle(this.ctx.note.type)); + } + + renderDropdown() { + this.$noteTypeDropdown.empty(); for (const noteType of NOTE_TYPES.filter(nt => nt.selectable)) { const $typeLink = $('') diff --git a/src/views/title.ejs b/src/views/title.ejs index 1d4ead560..bf3e3331e 100644 --- a/src/views/title.ejs +++ b/src/views/title.ejs @@ -37,7 +37,7 @@     -
+