mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
expand/collapse all
This commit is contained in:
parent
1369603ed9
commit
489e064932
@ -99,6 +99,12 @@ const TPL = `
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div class="btn-group floating-button" style="right: 20px; top: 10px;">
|
<div class="btn-group floating-button" style="right: 20px; top: 10px;">
|
||||||
|
<button type="button"
|
||||||
|
class="collapse-all-button btn icon-button bx bx-layer-minus"
|
||||||
|
title="Collapse all notes"></button>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<button type="button"
|
<button type="button"
|
||||||
class="expand-children-button btn icon-button bx bx-move-vertical"
|
class="expand-children-button btn icon-button bx bx-move-vertical"
|
||||||
title="Expand all children"></button>
|
title="Expand all children"></button>
|
||||||
@ -119,27 +125,36 @@ const TPL = `
|
|||||||
<div class="note-list-container"></div>
|
<div class="note-list-container"></div>
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
|
async function toggleCards(cards, expand) {
|
||||||
|
for (const card of cards) {
|
||||||
|
const $card = $(card);
|
||||||
|
const noteId = $card.attr('data-note-id');
|
||||||
|
const note = await treeCache.getNote(noteId);
|
||||||
|
|
||||||
|
await toggleContent($card, note, expand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function renderList(notes, parentNote = null) {
|
async function renderList(notes, parentNote = null) {
|
||||||
const $noteList = $(TPL);
|
const $noteList = $(TPL);
|
||||||
|
|
||||||
// $zoomInButton.on('click', () => this.setZoom(this.zoomLevel - 1));
|
$noteList.find('.expand-children-button').on('click', async () => {
|
||||||
// $zoomOutButton.on('click', () => this.setZoom(this.zoomLevel + 1));
|
for (let i = 1; i < 30; i++) { // protection against infinite cycle
|
||||||
//
|
const $unexpandedCards = $noteList.find('.note-book-card:not(.expanded)');
|
||||||
// $expandChildrenButton.on('click', async () => {
|
|
||||||
// for (let i = 1; i < 30; i++) { // protection against infinite cycle
|
if ($unexpandedCards.length === 0) {
|
||||||
// const $unexpandedLinks = this.$content.find('.note-book-open-children-button:visible');
|
break;
|
||||||
//
|
}
|
||||||
// if ($unexpandedLinks.length === 0) {
|
|
||||||
// break;
|
await toggleCards($unexpandedCards, true);
|
||||||
// }
|
}
|
||||||
//
|
});
|
||||||
// for (const link of $unexpandedLinks) {
|
|
||||||
// const $card = $(link).closest(".note-book-card");
|
$noteList.find('.collapse-all-button').on('click', async () => {
|
||||||
//
|
const $expandedCards = $noteList.find('.note-book-card.expanded');
|
||||||
// await this.expandCard($card);
|
|
||||||
// }
|
await toggleCards($expandedCards, false);
|
||||||
// }
|
});
|
||||||
// });
|
|
||||||
|
|
||||||
$noteList.on('click', '.note-book-hide-children-button', async ev => {
|
$noteList.on('click', '.note-book-hide-children-button', async ev => {
|
||||||
const $card = $(ev.target).closest('.note-book-card');
|
const $card = $(ev.target).closest('.note-book-card');
|
||||||
@ -198,7 +213,7 @@ async function renderNoteContent(note) {
|
|||||||
async function renderNote(note, expand) {
|
async function renderNote(note, expand) {
|
||||||
const notePath = /*this.notePath + '/' + */ note.noteId;
|
const notePath = /*this.notePath + '/' + */ note.noteId;
|
||||||
|
|
||||||
const $expander = $('<span class="note-expander bx bx-chevron-right" href="javascript:"></span>');
|
const $expander = $('<span class="note-expander bx bx-chevron-right"></span>');
|
||||||
|
|
||||||
const $card = $('<div class="note-book-card">')
|
const $card = $('<div class="note-book-card">')
|
||||||
.attr('data-note-id', note.noteId)
|
.attr('data-note-id', note.noteId)
|
||||||
@ -209,7 +224,7 @@ async function renderNote(note, expand) {
|
|||||||
.append(await linkService.createNoteLink(notePath, {showTooltip: false}))
|
.append(await linkService.createNoteLink(notePath, {showTooltip: false}))
|
||||||
);
|
);
|
||||||
|
|
||||||
$expander.on('click', async () => await toggleContent($card, note, !$expander.hasClass("expanded")));
|
$expander.on('click', () => toggleContent($card, note, !$card.hasClass("expanded")));
|
||||||
|
|
||||||
await toggleContent($card, note, expand);
|
await toggleContent($card, note, expand);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user