mirror of
https://github.com/zadam/trilium.git
synced 2025-01-15 19:51:57 +08:00
render note type dropdown lazily
This commit is contained in:
parent
8e4e0bd543
commit
02ab59c9e0
2 changed files with 7 additions and 3 deletions
|
@ -60,6 +60,8 @@ class NoteTypeContext {
|
||||||
constructor(ctx) {
|
constructor(ctx) {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
|
|
||||||
|
ctx.$tabContent.find('.note-type').on('show.bs.dropdown', () => this.renderDropdown());
|
||||||
|
|
||||||
this.$noteTypeDropdown = ctx.$tabContent.find(".note-type-dropdown");
|
this.$noteTypeDropdown = ctx.$tabContent.find(".note-type-dropdown");
|
||||||
this.$noteTypeButton = ctx.$tabContent.find(".note-type-button");
|
this.$noteTypeButton = ctx.$tabContent.find(".note-type-button");
|
||||||
this.$noteTypeDesc = ctx.$tabContent.find(".note-type-desc");
|
this.$noteTypeDesc = ctx.$tabContent.find(".note-type-desc");
|
||||||
|
@ -71,9 +73,11 @@ class NoteTypeContext {
|
||||||
this.$noteTypeButton.prop("disabled",
|
this.$noteTypeButton.prop("disabled",
|
||||||
() => ["file", "image", "search"].includes(this.ctx.note.type));
|
() => ["file", "image", "search"].includes(this.ctx.note.type));
|
||||||
|
|
||||||
this.$noteTypeDropdown.empty();
|
|
||||||
|
|
||||||
this.$noteTypeDesc.text(this.findTypeTitle(this.ctx.note.type));
|
this.$noteTypeDesc.text(this.findTypeTitle(this.ctx.note.type));
|
||||||
|
}
|
||||||
|
|
||||||
|
renderDropdown() {
|
||||||
|
this.$noteTypeDropdown.empty();
|
||||||
|
|
||||||
for (const noteType of NOTE_TYPES.filter(nt => nt.selectable)) {
|
for (const noteType of NOTE_TYPES.filter(nt => nt.selectable)) {
|
||||||
const $typeLink = $('<a class="dropdown-item">')
|
const $typeLink = $('<a class="dropdown-item">')
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="note-type-wrapper" style="display: flex;">
|
<div style="display: flex;">
|
||||||
<div class="dropdown note-type">
|
<div class="dropdown note-type">
|
||||||
<button type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="btn btn-sm dropdown-toggle note-type-button">
|
<button type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="btn btn-sm dropdown-toggle note-type-button">
|
||||||
Type: <span class="note-type-desc"></span>
|
Type: <span class="note-type-desc"></span>
|
||||||
|
|
Loading…
Reference in a new issue