Add event listener to activate a day note on click

This commit is contained in:
Arne Keller 2022-07-19 16:39:07 +00:00
parent 26da3db508
commit ffb3c7baf2

View File

@ -145,6 +145,24 @@ async function renderTimeline() {
// Add present time marker based on "timeline_present" label
timeline.setCurrentTime(timeline_options.timeline_present);
// Add event listener to activate a day note on click
timeline.on("click", async (e) => {
const timelineHeight = timeline.dom.centerContainer.getBoundingClientRect().height;
if (e.y <= timelineHeight) {
// ignore clicks on the timeline
return;
}
const effectiveY = e.y - timelineHeight;
if (effectiveY > timeline.dom.bottom.children[0].children[0].getBoundingClientRect().height) {
// ignore clicks on the month axis
return;
}
const day = e.time.toISOString().substr(0, 10);
const todayNote = await api.getDayNote(day);
api.waitUntilSynced();
await api.openTabWithNote(todayNote.noteId, true);
});
// Create UI menu buttons from added groups (that are not forced into another group)
menu.innerHTML = '';
const toggle_groups = groups.get({filter:function(item){return(item.forceGroup===null && item.id!=='default')}});